Repository navigation
Automated Testing: Add "Review Routing" internal package for decision model review assessment - #86325
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.61 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Undo restores the post selection when another synced entity is loaded in
|
| packages/theme/src/prebuilt/** linguist-generated=true | ||
| **/__snapshots__/** linguist-generated=true |
There was a problem hiding this comment.
Rather than maintaining a hard-coded list of files to exclude from the diff, I leaned into how GitHub collapses certain files that are generated as an indicator of files that produce a lot of noise that don't need to go in front of the decision model by default, the same as we don't put them in front of human reviewers in the file review tab.
This does mean that the prebuilt files and snapshots added here will also appear collapsed in GitHub moving forward for every pull request, and that was an intentional decision on my part.
We may eventually need to iterate on this with more ignored file patterns that could eventually resurface the need for a hardcoded list, such as excluding test files for example. Those aren't generated and I wouldn't want them to be collapsed by default in a GitHub pull request review, but they may not be strictly necessary for a decision model routing review. Then again, maybe there's a group of folks who would be interested in test files specifically 🤷
lancewillett
left a comment
There was a problem hiding this comment.
Direction looks good. 👍
A few suggestions:
Start by adding reviewers, not removing them. Fall back to CODEOWNERS for failures or lack of a good match.
Test on historical PRs before wiring into CI. Run it on a 100-200 merged PRs and compare against who actually reviewed them. Gives you a precision and recall number to adjust the 0.70 threshold.
Ask whether a review is needed at all, not just who. The same evidence could rate a change's risk, scope and complexity. A typo fix or a dependency bump might need no specialist, while a public API change does need someone more experiences.
This is something we can tackle as part of integrating into CI and updating existing CODEOWNERS. Just clarifying as not being within scope of this pull request. That being said, I think we can in a few ways, while also being aggressive in pushing toward the tool as the primary source of review assignments. For failures, we'll certainly want to "fail open". If the API requests fail, we should have a fallback. This also shouldn't stop individuals from assigning themselves as code owners over those paths if they still want direct notifications based on file pattern. This is more targeted at teams, or perhaps individuals who specifically want to opt in to this nuanced review assignment. I may have overstated the intent: I expect CODEOWNERS could still continue to serve a purpose and we may not replace it completely. It's still a good enough tool for reviewers who are primarily interested in changes affecting known file patterns.
That's a good idea, and I'm working on this locally. Of course, if I use AI to assist with this, there's naturally going to be some bias in whether it can establish relevancy and would probably follow similar results we could expect with the decisions models themselves. On "who actually reviewed them", this could similarly be biased by the fact that those people were requested at all on the pull request (i.e. someone whose review is requested is more likely to review it by the mere fact they were requested). We could be a little clever here using details like (a) whether review was requested to the group outside of the CODEOWNERS automation, and (b) whether review happened by a person in the group independent of whether the group was requested.
I agree, and I think this is covered already in how the review router works. If certain types of changes are risk or others don't need a specialist, those details should be written in the routing document. For example, the included design system routing document defines risk as including changes that affect public API, and explicitly calls out dependency updates as not needing review of the team. |
|
I don't want to get too bogged down by the details of tuning the design system routing rubric to be perfect in this pull request, since the point is to get tooling in place and that we'd tune this over time. But I was very curious to dig into the question of "Test on historical PRs before wiring into CI", and use it to inform potential improvements and identify gaps. This led to some further improvements of the content in 618c91f. I had a local agent spawn subagents to evaluate 100 pull requests over the past 6 months and, given my own hand-written guidance of what we're looking for along with a comparison of how it was reviewed, determine whether the decision model would give the same results. Full details of methods and findings (AI-generated)I tested the tool on 100 merged pull requests from the last six months, to compare it with CODEOWNERS and to find gaps in the design system rubric. Method
Baseline results
The tool's precision is very good. CODEOWNERS made 16 requests that the team did not need, for example the Jest update and dependency declarations in Gaps in the 16 misses
Improvements COMMIT adds the missing scope to the rubric. I ran the updated rubric again on 28 of the pull requests: the 8 decided cases, 13 cases that could become false requests, and the 7 earlier correct requests.
This gives an estimated recall of 48% (11 of 23) with 100% precision. It is an estimate, because I did not run the other 72 pull requests again. Next The remaining misses need more than wording: a stronger model, better evidence, or both. Shadow mode in the CI phase can measure these changes on real pull requests before we remove the CODEOWNERS lines. Raw data for all 100 pull requests
That leaves the remaining "misses" as far as pull requests that should tag the team but didn't. Notably not all of these would tag the team today either, but they're the sort of thing we'd hope could be incorporated in this review tooling. This could also improve over time by using different or updated models. Remaining "misses" (AI-generated)
|
Curious, I gave it a shot with Jev as well, which was pretty easy since it's designed to be interoperable. It looks like Jev performs quite a bit better! And even though it doesn't have a free tier, it is low cost, with the full run over 100 sample pull requests costing between $0.01 - $0.015 (so each pull request about $0.00015). Results with Jev (AI-generated)
|
|
There is a potential criticism against how this is designed to use System One models. Per TypeSafe's guidance on
We're doing the opposite of this currently: The guideline is combined into a single noul request, even though it includes many individual criteria. That being said, it makes it a lot easier to write and maintain a single document. And at the moment we don't really need to differentiate between individual aspects of each routing configuration, so maybe it's fine if it makes a combined judgment. |
… model review assessment
Thinking some more about this today: I actually think the current design could address this just fine. The problem isn't how the routing system is defined, it's more that we're cramming a bunch of different concerns into a single routing configuration. The routing is defined to support any number of review assignments for particular concerns, so we could solve this by breaking it up into individual configurations. So instead of expressing it like...
Having it instead be a series of individual configurations for A, B, and C.
This fragments things a bit more, but I think it does a good job of individualizing each point of concern, leaning into best practices for nouls, and also helps us tune because we could get relevancy data points for each individual item. Another option that my AI agent proposed was using a more rigid format for the configuration documents, so we could define the routing in a single document, with a list for what "Yes" looks like and what "No" looks like, and then the script could split up those bullet points to be passed to the decision model as individual nouls. I think this adds a bit of unnecessarily complexity and the rigid structure of the document moves a bit away from what I like about how we can express using natural language. |
618c91f to
b9900a3
Compare
Since it's pretty straightforward to test this, I gave it a shot, and the data seems to indicate this is a better direction. The fact that we have individualized data and can tune thresholds independently itself is quite a nice benefit. I pushed the split in b9900a3. Raw data per pull request (AI-generated)Per PR (label yes, or any score >= 0.5):
I also examined specific differences between how split rules flagged pull requests missed by the single rule, or vice-versa missed pull requests flagged by the single rule. It's a bit of a mixed bag, though with more improvements than regressions, and notably this gives us a lot of flexibility to tune at an individual rule level: Analysis of split rules improvements and regressions (AI-generated)Found by the split, missed by the single document (4):
Missed by the split, found by the single document (2):
False request removed by the split (1): 82940 (Icons: restore the dimmed box) scored 0.75 with the single document, and its best split score is There are no new false requests. 80573 (ExternalLink focus ring) is a false request in both designs: 0.81 with the single document, and So the net result is +2 correct requests and −1 false request. The two losses are both close:
The four gains are the important part. Three of them are from application code: a workaround, hard-coded colors and a token change. That was the weakest area of the single document with both models, and it is the main gap in CODEOWNERS. |
Rationale: 1. Decision models don't have the context of what's actually available in these packages 2. We're also interested to see where contributions are working around limitations of the design system (i.e. toward improving the design system itself)
|
Okay one final round of tuning in 22701c1 . This can be quite fun to see how small details of the phrasing can be quickly validated 😄 Specifically for these changes, it's meant to address two concerns:
The original set of 100 pull requests didn't match on this "bespoke UI" rule, but that's because it didn't actually include any real examples of bespoke UI. So I had an agent gather some examples and generate a score before and after for each.
|
|
Alright, having not heard any other feedback, let's get this merged and iterate. As it stands, this isn't really doing anything anyways, other than being available for someone to try it out in their own local environment. The next step will be to start integrating this in a CI environment. |
… model review assessment (WordPress#86325) * Automated Testing: Add "Review Routing" internal package for decision model review assessment * Update link for System One reference * Add component migration to review rubric for design systems * Prefix pull request title for clarity * Fix package.json ordering for lint * Refine review routing rubric for design system * Automated Testing: Split design system review routing to multiple documents * Automated Testing: Refine language of bespoke UI Rationale: 1. Decision models don't have the context of what's actually available in these packages 2. We're also interested to see where contributions are working around limitations of the design system (i.e. toward improving the design system itself) Co-authored-by: aduth <aduth@git.wordpress.org> Co-authored-by: lancewillett <lancewillett@git.wordpress.org>
What?
Adds a new internal package
@wordpress/review-routing-toolswhose purpose is to help route pull requests to appropriate reviewers. Routings are defined as individual documents written in natural language, which are used by the package in combination with System One-compatible model (like Jev or Cloudflare Clef) to determine the probability that the associated team is a relevant reviewer for the change.Why?
This is intended to be one incremental step toward improving contributor workflows by improving the relevance of how reviewers are assigned to pull requests. From the contributor standpoint, this helps get their work in front of subject-matter experts based on domain expertise. From a reviewer standpoint, it helps toward ensuring that they are only requested for reviews on pull requests that are truly relevant for their human judgment.
This is intended to eventually be a replacement for CODEOWNERS in many cases. While CODEOWNERS is limited to naive, file-pattern-based review assignments, using decision models allows for more nuanced judgment in the relevancy of code changes to a particular group. As proposed, this can be tuned over time, either providing more relevant context for the judgment, or improving the routing configuration documents to more accurately describe the types of changes that a team should review.
How?
Currently, this includes just the package implementation, and does not currently integrate the tool in any relevant processes, which would happen subsequently through additions to continuous integration (CI).
In its current form, the tool is largely useful for demonstrating how this would work, providing a command-line interface to test the judgment against various pull requests to assess its effectiveness.
What it includes now:
.github/review-routingwith YAML frontmatter assigning relevant teams and thresholds for a type of change, and the contents of the document describing whether the team would be a match for the changes. As implemented, it includes a configuration specific for design systems changes requesting review from @WordPress/gutenberg-components team.What comes later:
applyTofiltering so judgments only apply for specific file paths, generated context for rules like component or tokens lists.Testing Instructions
Test by pointing the CLI to specific pull requests and performing an assessment, observing that the outcome matches your own expectation of whether @WordPress/gutenberg-components should be requested for review on the given pull request.
You should be able to follow the usage instructions from the included
tools/review-routing/README.mdusing either Jev or Cloudflare.Create
tools/review-routing/.envwith API URL and API key. Example with Cloudflare, where you'd replace<account_id>and<api_key>with your own.Some examples:
Against #86199, as an example of a pull request which was not previously covered by CODEOWNERS and where the author explicitly requested review from @WordPress/gutenberg-components anyways:
Against #85741, as an example of a change that pinged @WordPress/gutenberg-components because it touched files within the package despite the pull request not being particularly relevant for design systems owners:
Use of AI Tools
Used Claude Code + Opus 5.5 to research and implement.