Skip to content

Add a deterministic light or full review classifier for docs PRs - #378

Closed
theletterf wants to merge 2 commits into
mainfrom
review-classifier
Closed

theletterf wants to merge 2 commits into
mainfrom
review-classifier

Conversation

@theletterf

@theletterf theletterf commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Docs repositories can now label each pull request as light review or full review, and post one comment that links to the matching review checklist. Each repository keeps its rules in its own .github/review-classifier.yml. The rules use only the diff, file paths, and GitHub metadata. The caller templates start in a manual dry-run mode, so nothing is posted until a maintainer asks for it.

Prompt summary: Implement the classifier that elastic/docs-content-internal#1943 specifies, with the Google Doc spec as its source. Put it in docs-actions as reusable workflows with caller templates. Include Vale by default, apply review labels with human overrides, and start with a dry-run mode that targets one PR. Keep the rules in the caller repository, so teams can maintain them without a docs-actions release.

Why

Reviewers in docs-content have no shared, visible signal for when a PR needs the full review checklist instead of the light one. elastic/docs-content-internal#1943 defines nine deterministic triggers for that decision. The team also wants to check the trigger rates on real PRs, and to tune the rules, before the classifier comments on every PR.

What

Nine full review triggers

classify.py checks for new or deleted pages, new redirects, more than 5 changed files, 3 or more changed images, and snippets that pages in more than one folder include. It also checks for heading changes or a size-based share of changed lines, changed or removed applies_to values, and new external links. It reads base versions of files from git through a blobless checkout, so it makes no API call per file. It ignores whitespace-only and rewrapped lines, code blocks, and frontmatter.

Rules in the caller repository

The caller repository keeps its rules in .github/review-classifier.yml. The file can change each value, turn off any trigger, and add custom rules that ask for a full review when a changed file matches a path. It also sets the label names, the checklist links, and the Vale settings. Both phases read the file from the default branch, never from the PR head, so a PR cannot change the rules that classify it. A dispatch run reads the file from its own branch, so maintainers can test a rule change in a dry run. The loader rejects unknown keys and wrong types with a clear error. review-classifier/config.yml is an example file with the defaults, and a test keeps it equal to the built-in defaults.

Two phases that are safe for fork PRs

review-classifier.yml runs with read-only permissions and uploads a decision artifact that holds data only. review-classifier-comment.yml runs on workflow_run, validates the artifact against a strict schema and the config, and builds the comment from fixed templates. It skips the run if the PR head changed. It trusts the PR number in the artifact only for workflow_dispatch runs.

Labels, overrides, dry run, and Vale

The comment workflow sets review: light or review: full to show the final tier. A person who applies the other label overrides the rules, and the comment says so. The caller template starts with workflow_dispatch only, with pr-number and dry-run: true inputs. A dry run writes a preview to the job summary and posts nothing. By default, the classification job also runs vale/lint, and the comment shows counts and the first 10 findings on changed lines.

Backtest

backtest.py runs the rules from a config file on recently merged PRs in a local clone, and prints the rate of each trigger. On 185 recent docs-content PRs, 53% get a full review with the rules from the issue. With substantial-change.headings: false, 42% get a full review. I will share the numbers on elastic/docs-content-internal#1943 before the team chooses values.

Risk: The comment workflow has pull-requests: write and reads an artifact that a fork PR can influence. It inserts only validated trigger IDs, numbers, sanitized paths, and text from the trusted config into the comment. It changes only the two configured labels. The Vale file list includes only paths with safe characters, because vale/lint puts that list into a shell script.

Out of scope: The no-review tier from elastic/docs-content-internal#1940. The docs-content callers and config are in elastic/docs-content#8604.

Verify

cd review-classifier
python3 -m unittest test_classify test_render
node --test scripts/publish.test.js

# Trigger rates on real PRs; needs local clones of docs-content and the #8604 branch
git -C ../../docs-content fetch origin main
python3 backtest.py --repo elastic/docs-content --repo-root ../../docs-content --limit 200 \
  --config ../../docs-content/.github/review-classifier.yml

The workflows have not run on GitHub yet. The next step is to test them in elastic/docs-actions-sandbox, including a fork PR.

🤖 Generated with Claude Code

Related to #402

Reviewers have no shared signal for when a docs PR needs the full review
checklist. The classifier applies the rules from
elastic/docs-content-internal#1943 to the diff, posts one comment with the
matching checklist, and sets a review label that people can override.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The rules lived in workflow inputs, so every threshold change needed a
docs-actions release and two callers had to repeat labels and links. The
caller repo now keeps them in .github/review-classifier.yml, read from the
default branch so a PR cannot change the rules that classify it. The file
can also turn off triggers and add custom path rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@theletterf theletterf self-assigned this Sep 30, 2026
@theletterf

Copy link
Copy Markdown
Member Author

Replaced by #382. The branch name review-classifier is the same as the new review-classifier/ directory, so the gh-aw PR Review checkout (git checkout review-classifier) failed because git could not tell the branch from the path. The new PR has the same commits on feat/review-classifier.

@theletterf theletterf closed this Sep 30, 2026
@theletterf
theletterf deleted the review-classifier branch September 30, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant