feat(maintainer): reconcile stored author_association to live GitHub roles#190
Merged
Conversation
added 2 commits
June 16, 2026 13:02
…roles author_association is snapshotted at mirror-ingest time and never refreshed. A contributor who becomes (or stops being) a maintainer after filing keeps a stale role on every historical PR/issue/review/comment row — e.g. on phase-rs/phase, matthewevans (MEMBER) and plind-junior (COLLABORATOR) have all historical rows stuck at CONTRIBUTOR because they were private collaborators at ingest. Scoring that reads the per-row snapshot therefore denies solvers the maintainer issue-bonus tier indefinitely. Add an hourly MaintainerRoleReconcileService that, for registered + installed repos only, pulls the live collaborator + org-member set from GitHub and rewrites the four association columns (pull_requests, issues, comments, reviews) to the current role. Promotes current maintainers and demotes departed ones to CONTRIBUTOR. Fetches both sets before any write and fails closed per repo, so a partial/failed fetch never reads as a mass demotion. Wires in @nestjs/schedule (@Cron) for the sweep. Two new GitHubFetcherService methods (fetchRepoCollaborators, fetchOrgMembers) reuse the existing installation-token + rate-limit plumbing.
The previous lockfile was regenerated with npm 11, which deduped chokidar to v4 and pruned the chokidar@3 transitive deps (readdirp@3.6.0, picomatch@2.3.2, binary-extensions@2.3.0) still required by @angular-devkit/core@17 via @nestjs/schematics@10. CI runs npm 10 (Node 20), which strictly rejects the missing entries, failing 'npm ci' before lint/build could run. Regenerated with npm 10 to match CI.
entrius
approved these changes
Jun 16, 2026
entrius
pushed a commit
that referenced
this pull request
Jun 17, 2026
…s table (#192) PR #190 reconciled author_association by rewriting the stored column across 4 tables hourly — write-amplification, an hour staleness window, and it corrupts the event-time meaning of the snapshot. Separately, the per-row label/review association resolution went through contributor_repo_roles, a plain view re-derived per row (~30ms each: sort + DISTINCT ON over ~8k rows), which times the validator out on high-volume miners. Both collapse into one primitive: a live, indexed maintainers table. - Add maintainers (repo_full_name, github_id, login, association, refreshed_at), PK (repo_full_name, github_id); repo_full_name stored lowercased so reads join as m.repo_full_name = LOWER(src.repo_full_name) and still hit the PK. - Convert the reconcile service into MaintainerPopulateService: same fetcher (direct collaborators + org members), same safety rules (fetch-before-write, fail-closed-per-repo, skip-on-empty), but atomically upserts the maintainers table per repo instead of rewriting 4 tables. Runs hourly + once on boot. - Repoint pr_labels_by_actor / issue_labels_by_actor actor_association and pr_linked_issues issue_author_association and pr_review_summary's maintainer filter off contributor_repo_roles onto maintainers (indexed lookup; ~10-20x). - Resolve PR/issue author_association at serve time in miners.service via COALESCE(maintainers.association, stored) — no new payload field, so the validator needs no change. - Repoint /repos/:repo/maintainers to the table. Mark stored association columns as ingest snapshots; leave contributor_repo_roles in place (no remaining hot-path consumers). Co-authored-by: anderdc <me@alexanderdc.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
author_associationis snapshotted at mirror-ingest time and never refreshed. If a contributor becomes (or stops being) a maintainer after a row is ingested, every stored PR/issue/review/comment row keeps the stale role forever. Scoring that reads the per-row snapshot (the issue-bonus tier inentrius/gittensor) is then permanently wrong for those authors.Concrete miss on
phase-rs/phase:matthewevans(id1388610, currentlyMEMBER) andplind-junior(id59729252, currentlyCOLLABORATOR) have every stored row stuck atCONTRIBUTOR— they were private collaborators when the rows were ingested. The/repos/:repo/maintainersview already reports the correct current role (it derives latest-known role), and themaintainer_cutcarve-out already trusts it, but the raw per-row columns scoring reads do not.Fix
A new
MaintainerRoleReconcileService(hourly@Cron) that, for registered + installed repos only (registered = true AND installation_id IS NOT NULL):GET /repos/{owner}/{repo}/collaborators?affiliation=direct) + org members (GET /orgs/{org}/members).pull_requests,issues,comments,reviews) — the same setcontributor_repo_rolesreads.OWNER/MEMBER/COLLABORATORwho is no longer in the live set is reset toCONTRIBUTOR.After this runs, the stored snapshot reflects current role, so the downstream validator check stays the trivial
author_association IN (...)— no validator-side workaround needed.Safety
RETURNING 1row-counts make promote/demote logging version-independent.GitHubFetcherService's existing installation-token cache + rate-limit-awaregithubFetch.What this does NOT change
author_associationis a scoring-support field, not an audit record).member/membership/organizationwebhook triggers are intentionally out of scope — the hourly sweep is the v1; webhooks can tighten the window later.Dependency
Adds
@nestjs/schedule@^4.1.2(Nest 10-compatible) +ScheduleModule.forRoot(). The existing reconcilers (PrReconcileService, etc.) self-schedule withsetInterval; this introduces@nestjs/scheduleas the cleaner standard going forward.Lockfile note
package-lock.jsonshows a large delete count becausenpm installalso pruned pre-existing extraneous entries that were stale ontest(redis/@redis/*,generic-pool, chokidar deps — not referenced by the currentpackage.jsontree; verifiedkeyv/@keyv/redisstill resolve). The only additions are@nestjs/schedule,cron,@types/luxon. Happy to split the pruning into a separate hygiene PR if preferred.Testing
npm run build— clean (tsc vianest build).npm run lint— clean (eslint + prettier).