Repository navigation
Every open pull request has a record and one state, read by the merge gates and the new pull requests view - #985
Conversation
… gates and the new pull requests view A durable record per open pull request in the team's connected repositories, written from the webhooks already received for every author and kept honest by a bounded GraphQL sync under the shared GitHub budget (sweep:dashboard_prs). One function (pr_needs::decide) decides each pull request's state, its turn and what it needs next from whom; the run's watch stores its standing and the reviewer's auto-merge gate merges only what it calls ready. GET /api/prs and GET /api/prs/detail serve the dashboard's pull requests page under the "view" capability. Incident case xw holds it.
…for the org overview Every duration starts at ready for review, and human review leaves out the author and every bot. Records keep their state and turn change log, people's reviews and review requests, and check transitions. A merged or closed pull request leaves a history row kept 400 days with its run and session links and revert and follow-up links. A nightly job writes each org's and repository's snapshot and percentiles, team-scoped and bounded.
…nals A resumable 14-month backfill reads each organization's closed and merged pull requests into history under the shared budget, pausing on a held budget or rate limit and showing its progress per repository. Records keep separate author, reviewer and bot clocks, drift against the base, every check attempt (flaky reads as flaky), category and severity; history adds review coverage, bypass merges, suspect follow-ups with their reason, and CoderHelm's last run outcome and stop reason.
Superseded by CoderHelm's latest review
Superseded by CoderHelm's latest review
* The org's pull requests in one answer: GET /api/prs/overview Every pull request in the team's repositories counts, people's, CoderHelm's and other bots'; CoderHelm's are one slice. Computed facts only, with thresholds from the scope's own percentiles, no rate on fewer than 10 events, and what isn't stored yet named in `missing`. No per-person ranking, count or duration; a login appears only as one item's owner. The summary's numbers are all facts. GET /api/prs takes the overview's drill-down (stage, past p85/p95). Incident case xz pins it. * Overview: clippy's shapes, and words without hand-off phrases or loose numbers The stability line says "over the last month" so every number in the summary is a fact; the incident case reads the route's source without whitespace, so formatting can't hide a read. * A reopened change and a later alert recovery reach their waiting runs at once (#986) A run stopped because the change it built on closed now goes back to waiting as soon as GitHub reports the change reopened, not at the 15-minute sweep. The pull request handler sends the team's change check for a close or a reopen before any return a reopen reaches, naming the change, and the worker reads the runs that change's close stopped (the sweep stays the backstop for every team). A recovery posted after an alert route's quiet window now closes the run waiting on a person for that alert, through the same path a recovery posted at once uses (common::run_wake::alert_cleared, which the gateway's alert_delivery now calls too). Incident case xx_waits_never_outlive_their_event.
…re, the sync never undoes events, history is never thinned The repository's approval rule is GitHub's own review decision and the team's rule is a person's approval; a review no rule requires is named, never a hold. The sync never reopens a closed record, yields to events newer than its read, replaces the reviews and requests it lists, and marks lists cut by their page size. History rows merge by source, so the backfill never thins a row written from events. The review decision is worked out at review events and used for bypass only when fresh. Stacks join within one repository, and the detail decides with the list's own linked records.
Superseded by CoderHelm's latest review
Superseded by CoderHelm's latest review
…st event that wrote it A page read before an event could undo that event's queue entry, auto-merge or review decision. Every field both events and the sync write (state, title, draft, head, base, labels, review requests, reviews, review decision, checks, mergeability, auto-merge, the merge queue, size) now keeps the time an event last wrote it, and the sync writes that field only when its read is newer. Tests cover a queue, an auto-merge and a review decision event landing after the read and surviving the page.
| let data = match github.graphql_read(pr_record::SEARCH_QUERY, vars).await { | ||
| Ok(d) => d, | ||
| // A personal account's repositories are searched by user. | ||
| Err(_) if as_org && page == 0 => { |
There was a problem hiding this comment.
💬 FYI: Any error on the first search page switches the owner to a user: search (hardening, not verified)
Err(_) if as_org && page == 0 => { as_org = false; continue; } treats every failure on the first page as 'this is a personal account': a rate limit, a 5xx or a timeout all take it. The rest of this owner's sync, and the removal step, then run on the user: query. If that query returns nothing for an org owner, complete is true with an empty seen. The removal loop then deletes every open record of that owner that no event touched in the last hour. The same pattern is at line 340 for the backfill. I could not check from the repository whether user:<org> returns an org's pull requests. If it doesn't, one transient error costs the owner's records until the next webhooks rebuild them.
This blocks: On the sync/removal main path, a transient error on page 0 flips to a user: query that can yield empty seen and delete the owner's open records, data loss unverified in the PR
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| //! What happened to every pull request after it closed, kept long enough to | ||
| //! answer "how long do our pull requests usually take" from the org's own | ||
| //! history, and the nightly snapshot of each org and repository that the | ||
| //! overview reads instead of scanning pull requests on page load. |
There was a problem hiding this comment.
💬 FYI: Near-identical helpers added together (scope, not verified)
services/common/src/pr_history.rs adds load next to load_backfill, added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/common/src/pr_history.rs: <why>.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| if let Some(r) = &repo { | ||
| super::reviewer::validate_repo(r)?; | ||
| } | ||
| let days = |
There was a problem hiding this comment.
💬 FYI: Near-identical helpers added together (scope, not verified)
services/gateway/src/routes/prs_overview.rs adds day next to day_of (in services/common/src/pr_overview.rs), added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/gateway/src/routes/prs_overview.rs: <why>.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
Superseded by CoderHelm's latest review
|
Auto-merge |
Summary
A durable record for every open pull request in a team's connected repositories, people's as much as CoderHelm's, one shared function that decides each one's state and what it needs next from whom, and
GET /api/prsfor the dashboard's new Pull requests page.common::pr_record): one settings-table item per pull request, written from the webhooks already received (pull request, review, review and issue comments, check run, check suite, status, push) for every author, and kept honest by a bounded sync: one GraphQL search per organization at install and once an hour, under the shared GitHub budget. No expiry while the pull request is open.common::pr_needs::decide): a generalization ofmerge_standing. It returns exactly one of 19 states plus a visibleunknown, a turn (a person, CoderHelm, the machines, done), andnext{code, text, from, since, rule}. The sentence leads with the block, names who acts, and gives the rule's source (repo rule, CODEOWNERS, required check, team rule). For CoderHelm's own pull request it is the run's standing; typed hand-offs are shown as their own line, and CoderHelm's own limits stay CoderHelm's turn.pr_needsdecides (run_standing), and the reviewer's auto-merge gate merges only whatpr_needssays is ready.common::pr_history): every duration from ready for review, human review leaving out the author and every bot; each record's state and turn change log, people's reviews and review requests, and the checks turning red or green; links to CoderHelm's runs and review sessions, and revert and follow-up links; a history row for every merged or closed pull request, kept 400 days; and a nightly snapshot per org and repository with counts by stage and turn and the org's own percentiles (cycle p50/p85/p95, first human review p50/p85, each stage's p85), a repository under 30 merges in 90 days using its org's and an org under 8 weeks marked young. The overview's builder reads the shapes fromdocs/pull-requests/api_contract.md.GET /api/prs(filters for org, repo, turn, state, person, a query and the saved views; counts by turn, state, repo, org and view;limit/cursor/next) andGET /api/prs/detail(the path to merge, the wait ledger, the timeline with CoderHelm's runs). Under the "view" capability, scoped to the session's team.Changes
services/common/src/pr_needs.rs(new):State,Turn,Rule,Facts,decide,run_standing,checklist.services/common/src/pr_record.rs(new): the record, its pure event and sync appliers, the wait ledger, versioned writes, head and branch pointers, the sync's GraphQL search.services/common/src/pr_view.rs(new): rows, stacked and plan links, the viewer's turn, staleness from the repository's own waits (the 75th percentile per state, never a fixed number of days), filters, counts, paging, ledger and timeline.services/gateway/src/routes/prs.rs(new): the webhook writer and both endpoints; a 10 second cache keyed byread_key(installation_id, "prs#<team>").github_webhook.rs:dispatchwrites every pull request event's record before any handler's early return; installs and added repositories ask for a sync (PrRecordsSync). The "Only track our PRs" return stays for the run-only work below it.services/worker/src/passes/pr_records.rs(new): the sync.worker/src/main.rsruns it on the sweep tick and onPrRecordsSync.common/src/github_budget.rs: new callersweep:dashboard_prs, 30 requests an hour;sweep:deploysgives up 30 so every sweep at its cap still fits the background share.worker/src/passes/pr_watch.rs: storespr_needs::run_standing.worker/src/passes/await_merge.rs:gate_facts, and the merge happens only whenpr_needssays ready.permissions.rs:prs::list_prsandprs::get_prunder "view".bm_teams_never_cross: the new cache.xw_every_open_pr_has_one_state(.rsand.md): every open pull request appears; one state each, withunknownshown and counted; the gate and the list agree over every combination of what the gate weighs, and the run's stored standing reads to the same state; no record of another team reaches a row.services/common/src/pr_history.rs(new):History,Snapshot,Percentiles,stage_oflives inpr_needs; storage of history (400 days), revert and follow-up marks, and the snapshots. The gateway writes history when a pull request closes; the worker's sweep tick writes the snapshot once a day per team (bounded: 300 repositories, 25,000 history rows; no GitHub requests; no new process-wide cache).docs/pull-requests.md(new): the record, the history and snapshot, the states, the API and the cost.docs/pull-requests/api_contract.md(new): the API and stored shapes.Health signals stored for every pull request: separate author, reviewer and bot clocks (bots never reset the first two); drift as base commits touching the pull request's files; every check attempt, so failing then passing on one commit reads flaky; revert links (certain) and follow-up suspects with their reason; the review coverage state (human-approved, AI only, non-owner on owned paths, bypass or exempt, no review); bypass merges with the rule they went past and who merged (CoderHelm's own included); dependency and security category with severity, its clock from ready for review; and CoderHelm's last run outcome and stop reason. Every pull request means every author: the webhooks, the open sync and the 14-month history backfill keep people's, bots' and CoderHelm's alike, and nothing filters to CoderHelm's own pull requests.
Follow-ups, not in this change: CODEOWNERS versions and sensitive paths (non-owner coverage reads only GitHub's review decision today); policy events from the rule-suites API and the audit log; Dependabot and code-scanning alerts with KEV and EPSS, and the org's SLA table; default-branch CI episodes and a nightly flaky-check index; review comment counts; run cost and findings per pull request; the event feed; the digest and nudge settings.
Answers to the review on
afe30c7, each fixed at its cause and tested:APPROVEDcounts every approval GitHub counts, including an app's.pr_needs(optional asks, GitHub's decision), and incidentxw: the agreement loop now also varies requested reviewers, the review decision and the branch's count over 4,096 combinations. Two direct gate cases (an optional ask with the team rule off, and GitHub's approval with no person's) both merge.apply_nodenever reopens a record an event closed.read_at, taken before the request), the page adds only what events never carry.pageInfo. A cut list keeps the checks events reported, a required check that may be on a later page reads as unknown (never running), and a conversation rule with unread conversations reads as unknown.pr_recordcover each case.eventsorsearch), andpr_history::putmerges with the stored row: the events row wins, its empty fields are filled from the other, and revert and follow-up links come from both.a_search_row_never_thins_a_row_written_from_events.decision_at.a_review_event_refreshes_the_review_decisionanda_stale_review_decision_never_names_a_bypass.head_repo, from the event or the search). A fork's branch never stacks the repository's pull requests. Test:a_forks_branch_never_stacks_the_repositorys_pull_requests.pr_view::decidedis the one input builder (linked records, facts, decision, row);rowsanddetail_ofboth read it. Test:the_detail_decides_a_stacked_pull_request_as_the_list_does.pointer_sk(Pointer, repo, key)replaceshead_skandref_sk.pr_record::get_itemandget_docare the one read behind records, pointers, history rows and backfill progress (load,pointed,pr_history::load,load_backfill).PRRECBASE#), not every record of the repository.3dd8045was fixed onda7e4e7, which was green.Where the code differed from the plan:
## Compatibilityheading of the description, the same place the index's own check writes them.branch rule).selfhost/versions.jsondashboardRefbump follows as its own change once that merges:scripts/bump-dashboard.shpins a commit on the dashboard's main, which doesn't exist yet. Until then the hosted dashboard shows the page and an install's older dashboard simply doesn't link it.Cost bounds:
Verification
These checks were run on the branch after the review answers, merged with the org overview's read API (#988, merged into this branch) and with main (#986, #987).
cargo fmt --all --checkandrustfmt --check --edition 2021 worker/src/passes/incidents/*.rsare clean.cargo clippy -p common -p worker -p gateway --all-targets -- -D warningsis clean.cargo test --no-fail-fast -p common -p worker -p gatewaypassed with no failures: common 3,392, gateway 1,370 and worker 2,998 tests, plus the integration tests.a_review_no_rule_requires_never_holds_the_mergegithubs_decision_counts_every_approval_that_counts_therethe_sync_never_reopens_a_closed_record_or_overwrites_newer_eventsthe_sync_is_the_authority_for_the_reviews_it_listsa_list_cut_short_is_never_read_as_completea_review_event_refreshes_the_review_decisionone_pointer_helper_names_every_pointera_forks_branch_never_stacks_the_repositorys_pull_requeststhe_detail_decides_a_stacked_pull_request_as_the_list_doesa_search_row_never_thins_a_row_written_from_eventsa_stale_review_decision_never_names_a_bypassxw'sthe_merge_gates_and_the_list_read_one_decision, now over 4,096 combinations plus two direct gate casesawait_merge(includingthe_person_key_is_optional_when_the_repo_says_so),merge_standing,bm_teams_never_cross, the worker message contract and the GitHub budget caps.brand_spelling.py,domain_examples.pyandtext_guard.pyare clean on this description, the commit messages and the docs.