Skip to content

feat(signals): advisory reviewer routing via CODEOWNERS (#540) - #829

Closed
JSONbored wants to merge 1 commit into
mainfrom
feat/codeowners-reviewer-routing
Closed

feat(signals): advisory reviewer routing via CODEOWNERS (#540)#829
JSONbored wants to merge 1 commit into
mainfrom
feat/codeowners-reviewer-routing

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Part of #540 (advisory core; auto_request deferred — see follow-up).

What

Suggest reviewers from a repo's CODEOWNERS for a PR's changed files, ranked by ownership and de-weighted by each owner's current load — advisory only, surfaced in the maintainer-private PR panel. Opt-in via reviewerRoutingMode (off|advisory, default off).

How

  • src/github/codeowners.ts — pure parseCodeowners + matchCodeowners implementing GitHub's CODEOWNERS semantics: last-match-wins; a pattern with any slash (leading/internal/trailing) is root-anchored, a slash-free pattern matches anywhere; dir/ owns files under the dir (not a file named dir); * stays within a segment, ** crosses segments. loadRepoCodeowners fetches .github/CODEOWNERSCODEOWNERSdocs/CODEOWNERS via raw.githubusercontent.com/.../HEAD/... (mirrors the focus-manifest fetch), best-effort, [] on any failure.
  • src/signals/reviewer-routing.ts — pure buildReviewerRouting ranks individual owners by matched-file count, then load band (busy = ≥ 3 authored open PRs — the only available proxy, since PR records carry no requested-reviewer data), then login. Excludes the PR author, collects @org/team handles separately, caps at 5. Public-safe: output is login + file count + band + reason only — no trust/score/reward fields (asserted in tests).
  • Setting reviewerRoutingMode wired like mergeReadinessGateMode (types/schema/migration 0042/repositories/openapi/settings-preview) + .gittensory.yml settings: block parity. The gate path reuses the shared changed-file load (no double fetch); routing is advisory and never feeds the gate.
  • Panel gains a "Suggested reviewers (advisory)" section via sanitizePanelText.

Deferred (follow-up)

auto_request — actually assigning reviewers on GitHub — is outward-facing and intentionally split out for its own focused review (with the strict opt-in + first-time-external-contributor guard the issue calls for). The column is TEXT, so adding the value + action later needs no migration.

Tests

codeowners.test.ts (parser + matcher: comments, multiple owners, last-match-wins, leading-slash anchor, dir/, */**, bare-name-anywhere, no-match). reviewer-routing.test.ts (rank by match count; busy ranks below light at equal match; author-exclusion; teams separate; empty cases; public-safe assertion).

Verification

migration guard (0001..0042, no dup) · typecheck clean · full suite 2017 passed, 1 skipped (only the pre-existing pngjs visual-agent skip) · openapi regenerated + drift-clean · UI lint clean.

Relates #525/#528 (Phase 1).

Suggest reviewers from a repo's CODEOWNERS for a PR's changed files,
ranked by ownership and de-weighted by each owner's current load —
advisory only, surfaced in the maintainer-private PR panel.

- src/github/codeowners.ts: pure parseCodeowners + matchCodeowners
  (GitHub last-match-wins; a pattern with any slash is root-anchored,
  a slash-free pattern matches anywhere; dir/ owns files under it;
  ** crosses segments) + loadRepoCodeowners (raw.githubusercontent.com
  HEAD fetch of .github/CODEOWNERS|CODEOWNERS|docs/CODEOWNERS,
  best-effort, [] on any failure).
- src/signals/reviewer-routing.ts: pure buildReviewerRouting ranks
  individual owners by matched-file count then load band (busy = >= 3
  authored open PRs, the only available proxy — PRs carry no
  requested-reviewer data), excludes the PR author, collects teams
  separately, caps at 5. Public-safe: login + file count + band only.
- reviewerRoutingMode setting (off|advisory, default off) wired like
  mergeReadinessGateMode + .gittensory.yml settings-block parity;
  migration 0042. Gate path reuses the shared changed-file load.
- Panel section 'Suggested reviewers (advisory)' via sanitizePanelText.

auto_request (actually assigning reviewers on GitHub) is intentionally
deferred to a follow-up — it is outward-facing and warrants its own
review. The TEXT column means it needs no migration to add later.
@dosubot dosubot Bot added the size:L label Jun 17, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 1cd6e9a Commit Preview URL

Branch Preview URL
Jun 17 2026, 11:58 AM

@ghost

ghost commented Jun 17, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #829 is no longer open. No action.

💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.06723% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.32%. Comparing base (bc090a1) to head (1cd6e9a).

Files with missing lines Patch % Lines
src/github/codeowners.ts 67.27% 13 Missing and 5 partials ⚠️
src/signals/reviewer-routing.ts 85.10% 1 Missing and 6 partials ⚠️
src/queue/processors.ts 25.00% 5 Missing and 1 partial ⚠️
src/signals/engine.ts 0.00% 4 Missing and 1 partial ⚠️
src/db/repositories.ts 50.00% 0 Missing and 1 partial ⚠️
src/signals/focus-manifest.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #829      +/-   ##
==========================================
- Coverage   96.56%   96.32%   -0.24%     
==========================================
  Files          98      100       +2     
  Lines       14175    14292     +117     
  Branches     5169     5217      +48     
==========================================
+ Hits        13688    13767      +79     
- Misses        105      128      +23     
- Partials      382      397      +15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@ghost

ghost commented Jun 17, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 24 changed file(s) — two independent AI reviewers.

Changed files (24)
  • apps/gittensory-ui/public/openapi.json
  • migrations/0042_reviewer_routing.sql
  • src/db/repositories.ts
  • src/db/schema.ts
  • src/github/codeowners.ts
  • src/openapi/schemas.ts
  • src/queue/processors.ts
  • src/signals/engine.ts
  • src/signals/focus-manifest-loader.ts
  • src/signals/focus-manifest.ts
  • src/signals/reviewer-routing.ts
  • src/signals/settings-preview.ts
  • src/types.ts
  • test/unit/codeowners.test.ts
  • test/unit/maintainer-activation.test.ts
  • test/unit/policy-sanitizer.test.ts
  • test/unit/registration-readiness.test.ts
  • test/unit/repo-policy-readiness.test.ts
  • test/unit/reviewer-routing.test.ts
  • test/unit/self-dogfood-registration-pack.test.ts (+4 more)

Suggested action:Safe to merge — both reviewers found no blocking issues.

Reviewer A · gpt-oss-120b — recommends ✅ merge
The PR adds advisory reviewer routing based on CODEOWNERS, introducing parsing, routing logic, DB schema, settings, OpenAPI updates, UI comment rendering, and comprehensive tests. The implementation respects public safety, privacy, and appears functionally correct.

Suggestions

  • Consider clarifying in documentation whether the suggested reviewers are shown publicly or only in a maintainer‑private view, as the comment rendering currently adds them to the public PR comment.
  • Add a unit test for the comment rendering to ensure the reviewer routing section appears correctly when enabled.

Worth double-checking

  • Public exposure of reviewer suggestions may not match the intended private‑only visibility.
  • Future extensions (e.g., auto‑request mode) must ensure they do not inadvertently expose or act on private data.

Reviewer B · mistral-small-3.1-24b-instruct — recommends ✅ merge
This PR introduces a new feature for advisory reviewer routing based on CODEOWNERS files. It includes comprehensive changes across multiple files, adding new modules, updating existing ones, and ensuring the feature is well-tested. The implementation is thorough and adheres to the project's conventions.

Suggestions

  • Consider adding a detailed description in the migration file to explain the purpose and impact of the new reviewer_routing_mode column.
  • Ensure that the loadRepoCodeowners function handles edge cases where the CODEOWNERS file might be malformed or missing.
  • Review the parseCodeowners function to ensure it correctly handles all possible variations of CODEOWNERS file content, including comments and empty lines.
  • Add documentation for the new reviewerRoutingMode setting in the public API documentation to inform users about its purpose and usage.
  • Verify that the buildReviewerRouting function correctly handles cases where there are no CODEOWNERS rules or where all rules are for teams.

Worth double-checking

  • Ensure that the new feature does not introduce any performance bottlenecks, especially when fetching and parsing CODEOWNERS files from GitHub.
  • Verify that the sanitizePublicComment function correctly handles any new public-facing text generated by this feature to prevent the leakage of forbidden terms.
  • Check that the new feature is correctly integrated with the existing gate evaluation logic and does not interfere with other gates.

Before = production · After = this PR's preview deploy.

Route Viewport Before After
/ desktop before desktop after desktop
mobile before mobile after mobile

@JSONbored JSONbored linked an issue Jun 17, 2026 that may be closed by this pull request
@JSONbored JSONbored self-assigned this Jun 17, 2026
@JSONbored JSONbored closed this Jun 17, 2026
@JSONbored
JSONbored deleted the feat/codeowners-reviewer-routing branch June 29, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(signals): advisory reviewer routing via CODEOWNERS + load

1 participant