Plan: one source for GitHub data, typed HTML, data apart from views

All docs · The source is docs/architecture.md.

Status: all steps are done.

Two tracks. They touch different code, except model::Pr, so they can run in parallel. Each step is one commit that passes all checks and deploys on its own.

Track A: the archive is the one source of PRs and issues

Today

Two paths read issues and pull requests from GitHub:

PathWritesCadence
archive walk (archive::walk)archive/<owner>/<name>.sqlite, pr, issue, history, review_by300 s; a due pass 10 s after each due mark
live refresh (github::refresh_live)pr_live, pr.dataeach pass, 500 open PRs

The notifications poller and the event log only mark numbers due.

The archive holds every field of model::Pr, model::Issue and metrics::Facts, with no caps. Three fields change without a change to updatedAt, so the archive copy goes stale: mergeable, the CI state (statusCheckRollup) and authorAssociation.

Target

events, notifications, updatedAt listing, open listing, backfill
        │  (mark a number due)
        ▼
one fetcher ──► archive (raw JSON, the record)
        │
        ▼
projection ──► pr, issue, history tables ──► recompute ──► Snapshot
                     ▲
pr_live (mergeable, ci, association) ◄── live refresh of open PRs

Steps

  1. Projection, in shadow. Add project::pr, project::issue and project::facts. They apply the caps that the sync applies today (30 reviews, 5 inline comments per review, 30 comments, 30 pushes, 50 files), so the ledger and the queues do not change. A test compares the projection with the sync result for recorded items. On the server, count the items where the projection and the pr row differ, and show the count on /state?tab=status. Done. Step 5 removes the count: the projection is then the only writer of the rows.
  2. Open items first. Add an "open" listing to the fetcher, so a new deployment reads every open PR and issue first. The archive gives open_complete. Done.
  3. Due marks. The poller and the event log mark due with no delay and wake the fetcher. Done.
  4. pr_live. The live refresh writes mergeable, CI and authorAssociation of the merge candidates and then of 500 open PRs, oldest check first, to pr_live and to the pr row of the same head. A full read by the sync or the poller writes pr_live too. The shadow check compares the live fields where pr_live has the same head. Done.
  5. Switch. Each archive write of a nixpkgs item writes its pr, issue and history rows, with pr_live joined. A row with a newer updated_at stays. pr and issue get the open items and the items updated in the last 60 days; history gets every pull request, and review_by gets a row for each person who reviewed it, so a review record reaches past the 60 days. On the first start, and after a change of ROWS_VERSION, archive::backfill writes the rows of every stored item, seeds pr_live from the open pr rows, deletes the keys of the old walks and sets archive_projected and archive_rows. The sync walk, the history walk and the poller's fetch are deleted; the CLI sync runs archive passes. issues_complete is the archive's open_complete, and the history is complete when the walk reaches #1; items that fail and wait for a retry do not hold it back. The walk recomputes at most once every 30 s after rows change. Lent tokens pay for the listings and due items, and for the live fields of the merge candidates, only below RESERVE or with no server token, each at most a tenth of its budget per rate limit window (github::Client::lent). Done.
  6. Prune. Step 5 writes to pr only open PRs and PRs updated in the last 60 days (WINDOW_DAYS). After each full pass, Store::prune deletes the older closed rows. Done.
  7. API and docs. /api/v1/sync shows one fetcher. Step 5 removed the fields of the old walks (open_walk_done, up_to, last_pass, walk_every_seconds, archive[].shadow) and added rows_from_archive_at. The status page names the upkeep task. Done.

Decisions

Risks

Track B: typed HTML, and data apart from views

Today

Target

Named types replace the tuples and json! values that are built in several places today:

TypeReplaces
SubjectRowjson! subject rows in catalog, api, prpage and mine
PackageViewthe (Jobset, job, Last, dead) tuples, cache rows, advisories
ReviewListthe review page pipeline and api::prs_value
BlockerVec<(Level, String)> in prpanel; blockers reach the API
SetViewjson! in sets_value
Status enumthe follow-up status tuple
Pr (as is)pr_json and pr_value, which copy fields by hand

Steps

  1. Html and the ui.rs helpers. Page.sub, actions, body and heading become Html. Done.
  2. needs. It is already split. Make Item Serialize and render it with Html. Done.
  3. committer. Remove why_html; render why in the view. Done.
  4. review and api::prs_value. One ReviewList. Done.
  5. notify, sets, mine. Inbox, SetView, Interests::picked. Done.
  6. profile, home. Add SubjectRow. Done, with PrSummary.
  7. prpanel, then prpage. Blockers and checks reach the API. Done.
  8. catalog. Split it into package, module, area and maintains, one at a time. PackageView, ModuleView, AreaView, MaintainsView, with SubjectView for what they share. Done.
  9. Remove the bridges from String to Html, and web::esc. A string with no escaping does not compile as Html. Html::trusted stays for the icon sprite and the two Markdown renderers. Done.

Checks for each step

Order

  1. B1, the Html type. Small, and every later step uses it.
  2. B4, the review list. Done.
  3. A1 to A3 and B2, B3, B5 in parallel.
  4. A4 to A7, then B6 to B9.