Skip to content

The pull request sync reads every repository and keeps pages GitHub answers in part - #993

Open
nambok wants to merge 3 commits into
mainfrom
prs-first-read
Open

nambok wants to merge 3 commits into
mainfrom
prs-first-read

Conversation

@nambok

@nambok nambok commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

The pull requests view could stay empty for two reasons. A field the installation may not read made GitHub answer the sync's search in part, and the sync threw the whole page away. The sync also read only repositories enabled for CoderHelm's work, and repository rows are stored not enabled. This keeps partial answers, reads every repository the installation can see, and asks for a team's first read as soon as the page is opened.

Changes

  • worker/src/clients/github.rs: graphql_read_partial returns the data with its errors; only an answer with no data fails.
  • common/src/pr_record.rs:
    • split_graphql and strip_refused: each field GitHub refused (FORBIDDEN, per node) is taken out of its node, so the record keeps what webhooks stored. Conversations refused read as unknown, never as none open.
    • search_query(omit): following pages leave the refused fields out, and a page whose nodes were nulled by one is read again without it.
    • FirstRead (PRFIRST), its due rule and a conditional claim, one ask per ten minutes.
  • worker/src/passes/pr_records.rs:
    • Reads every repository row of the team, with no enabled filter and nothing filtered by author or label. The history backfill uses the same partial reads.
    • Records the first read's progress per organization.
    • Logs one INFO line per team ("Pull request sync: team read") with the repositories, pull requests written, completeness and fields unavailable.
  • gateway/src/routes/prs.rs, prs_overview.rs: return first_read {reading, repos_read, repos_total, done}. When the team's first read never finished and no ask is in flight, they ask the worker for it (PrRecordsSync), under the shared sweep:dashboard_prs budget.
  • Docs: docs/pull-requests.md, docs/pull-requests/api_contract.md.

Verification

  • cargo fmt --check, cargo clippy -p common -p worker -p gateway --all-targets -- -D warnings: clean.
  • cargo test -p common -p worker -p gateway: all passed, apart from one new test whose expectation was then corrected. That test was re-run with the rest of the pr_record tests (19 passed).
  • New tests:
    • A page with GitHub's exact FORBIDDEN error per node keeps every pull request, and the refused field keeps its stored value and reads as unknown.
    • An answer with no data is still an error.
    • The next pages' query leaves refused fields out and stays read-only and balanced.
    • The first read is asked until it finishes and never twice at once.
    • First-read progress counts repositories per organization.

…nswers in part

A field the installation's permissions don't cover comes back null with a
FORBIDDEN error per node; the sync threw the whole page away and paused the
backfill. It now keeps the data beside the errors: refused fields leave the
node, so the record keeps what webhooks stored and conversations read as
unknown, and the following pages leave them out of the query (a page whose
nodes were nulled is read again without them).

The sync read only repositories enabled for CoderHelm's work, and repository
rows are stored not enabled, so a team with none enabled was never read. It
now reads every repository the installation can see.

The pull requests page and the overview ask for the team's first read when
it never finished (installs from before the view never send an install
event), claimed so one ask goes out per ten minutes, and return its
progress as first_read (repositories read of all). One INFO line per team
says the repositories read, pull requests written and fields unavailable.
Two open conversations already stored still hold the merge; none known reads
as unknown.
@nambok nambok added the ch-review CoderHelm reviews this pull request label Dec 6, 2026
coderhelm[bot]

This comment was marked as outdated.

… nothing to read ends

A page with a pull request GitHub returned as null, or an error that names
no single refused field, no longer counts the listing complete: those pull
requests are read from the REST list of each repository's open pull
requests, and records are removed only when the listing is whole. The
history backfill pauses on such a page instead of passing the window over.

A team with no repositories stored, or whose GitHub can't be reached, ends
its first read with the reason, so the page says it rather than reading and
asking again every ten minutes.

@coderhelm coderhelm Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes: nothing blocks the merge; 1 note below is for a look.

Why approved: nothing blocks (no required rule broken, no failing check, no shown defect, no unproven critical path); 1 suggestion.

Details: PR Overview · 🎯 Risk · Also worth a look · Earlier comments

PR Overview

The pull request sync keeps GitHub's partial search answers, reads every stored repository of a team, and records and asks for each team's first read from the pull requests page.

Changes

  • graphql_read_partial returns data with its errors; only an answer with no data fails (split_graphql).
  • strip_refused removes each refused field from its node. apply_node keeps the stored value for an absent field, and refused conversations read as unknown.
  • search_query(omit) leaves refused fields out of the next pages. A page whose nodes were nulled by a newly refused field is read again.
  • page_whole decides whether a page was answered whole. A listing that was not whole never prunes, and null pull requests are filled from the REST open-pull-request list.
  • The sync reads every repository row of the team, with no enabled filter. It logs one INFO line per team and tracks the first read's progress per organization.
  • FirstRead (PRFIRST) has a due rule and a conditional claim. The gateway returns first_read and asks the worker for a read that never finished, under the shared sweep:dashboard_prs budget.
  • graphql_read_partial returns the data with its errors; only an answer with no data at all fails.
  • split_graphql, strip_refused and search_query(omit) take refused fields out per node and leave them out of later pages, so the stored value is kept and the field reads as unknown.

Reviewed Changes

7 changed files.

File Description
docs/pull-requests.md Documents the partial reads and the first read.
docs/pull-requests/api_contract.md Documents the first_read field of the API.
services/common/src/pr_record.rs Adds split_graphql, strip_refused, search_query, page_whole, apply_rest_pr and FirstRead with its claim and save. apply_node now keeps…
services/gateway/src/routes/prs.rs Returns first_read and asks the worker for the first read when it is due.
services/gateway/src/routes/prs_overview.rs Returns first_read and asks the worker for the first read when it is due.
services/worker/src/clients/github.rs Adds graphql_read_partial, which keeps data beside errors.
services/worker/src/passes/pr_records.rs Reads every repository, keeps partial pages, retries once per newly refused field, fills from REST, and prunes only after a whole…

I read the worker sync, the REST fill, the backfill and the new common helpers at this head. My earlier blocking finding is fixed. Pruning and the first read's completion now depend on page_whole and on a whole listing (REST fill included), so a null node or an unexplained error can no longer delete records. The backfill pauses on such a page instead of passing over its window.

🎯 Risk: MEDIUM (64/100)

  • ██████████ blast radius 100 — ~92 dependent refs; hottest: prs.rs (~25), github.rs (~25), pr_record.rs (~20) · cross-repo consumers: pull-requests.md to 1 repo(s)
  • ░░░░░░░░░░ sensitive area 0 — no sensitive areas touched
  • ████████░░ test coverage 80 — 7 source / 0 test file(s) changed
  • ███████░░░ size/spread 64 — 809 lines across 7 file(s), spread 56%

Also worth a look

On code that hasn't changed since my previous review, which missed them. They are notes, not part of the verdict:

  • services/common/src/pr_record.rs:1473 A refused commits field can leave a new head with checks that read as none

Earlier comments

1 settled and resolved · 0 still open


Was this review right? Rate it 👍 / 👎 so the reviewer learns · reply @coderhelm re-review or @coderhelm <question>

@coderhelm
coderhelm Bot dismissed their stale review December 6, 2026 06:54

Superseded by CoderHelm's latest review

@coderhelm

coderhelm Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Auto-merge · waiting

  • ✅ CoderHelm approved
  • ⏳ CI running: Analyze (rust)
    Commit into main. Merges on its own once every item is done.
    Stop auto-merge or comment @coderhelm stop auto-merge.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant