Skip to content

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

Merged
theletterf merged 6 commits into
mainfrom
feat/review-classifier
Sep 30, 2026
Merged

theletterf merged 6 commits into
mainfrom
feat/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.

A pr-number input for vale/lint

vale/lint filters findings to changed lines, but it reads the PR number only from the pull_request event. A new optional pr-number input gives workflow_dispatch runs the same file list and line filtering. The input goes to the shell scripts through env:, and the scripts reject a value that is not a number. The classifier calls vale/lint with this input from the pinned docs-actions checkout, so the Vale results match the standard Vale check.

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.

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

theletterf and others added 2 commits September 30, 2026 13:50
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]>
git diff has no --pathspec-from-file option, so the step exited with a
usage error on every PR that changed an existing Markdown file. The step
now passes the paths to git diff through xargs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for correctness issues in trigger coverage and Vale line-range filtering that can produce incorrect review classification output.


What is this? | From workflow: PR Review

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

Comment thread review-classifier/classify.py Resolved
Comment thread review-classifier/classify.py Resolved
A new snippet that pages in two folders include has the same effect as
a changed one, so the shared-snippet trigger now checks added snippets.
Vale lints .mdx files, so the classifier now records their changed lines;
without them, the comment listed Vale findings on lines the PR did not
change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread review-classifier/classify.py Resolved
theletterf and others added 2 commits September 30, 2026 14:50
The classifier records changed lines for 300 files at most, but it sent
every changed Markdown file to Vale. For files past the cap, the comment
listed findings on unchanged lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vale/lint already keeps only the issues on changed lines, but it read the
PR number only from the pull_request event. A new pr-number input lets
workflow_dispatch runs use the same filtering. The review classifier now
calls vale/lint with that input and drops its own changed-line tracking,
the file-count cap, and the Vale file list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Elastic Docs Style Checker (Vale)

Summary: 21 warnings, 19 suggestions found

⚠️ Warnings (21): Fix when the suggestion improves clarity or correctness.
File Line Rule Message
vale/test-fixtures/sample-violations.md 2 Elastic.MappedPages Avoid editing mapped_pages unless you are preserving an existing URL mapping. Talk with your local technical writer before changing this key.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an FAQ' instead of 'a FAQ'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an SQL' instead of 'a SQL'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 7 Elastic.BritishSpellings Use American English spelling 'optimize' instead of British English 'optimise'.
vale/test-fixtures/sample-violations.md 7 Elastic.BritishSpellings Use American English spelling 'customize' instead of British English 'customise'.
vale/test-fixtures/sample-violations.md 7 Elastic.BritishSpellings Use American English spelling 'behavior' instead of British English 'behaviour'.
vale/test-fixtures/sample-violations.md 11 Elastic.DontUse Don't use 'just'. Choose a more precise or reader-focused term.
vale/test-fixtures/sample-violations.md 11 Elastic.DontUse Don't use 'please'. Choose a more precise or reader-focused term.
vale/test-fixtures/sample-violations.md 11 Elastic.DontUse Don't use 'aka'. Choose a more precise or reader-focused term.
vale/test-fixtures/sample-violations.md 20 Elastic.Articles Use 'an FAQ' instead of 'a FAQ'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 20 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 20 Elastic.Articles Use 'an SQL' instead of 'a SQL'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 24 Elastic.BritishSpellings Use American English spelling 'optimize' instead of British English 'optimise'.
vale/test-fixtures/sample-violations.md 24 Elastic.BritishSpellings Use American English spelling 'customize' instead of British English 'customise'.
vale/test-fixtures/sample-violations.md 24 Elastic.BritishSpellings Use American English spelling 'behavior' instead of British English 'behaviour'.
vale/test-fixtures/sample-violations.md 40 Elastic.DontUse Don't use 'just'. Choose a more precise or reader-focused term.
vale/test-fixtures/sample-violations.md 40 Elastic.DontUse Don't use 'please'. Choose a more precise or reader-focused term.
vale/test-fixtures/sample-violations.md 40 Elastic.DontUse Don't use 'aka'. Choose a more precise or reader-focused term.
vale/test-fixtures/sample-violations.md 48 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
💡 Suggestions (19): Optional style improvements. Apply when helpful.
File Line Rule Message
vale/test-fixtures/sample-violations.md 8 Elastic.WordChoice Consider using 'efficiently' instead of 'Simply', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 8 Elastic.WordChoice Consider using 'allowlist' instead of 'whitelist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 8 Elastic.WordChoice Consider using 'blocklist' instead of 'blacklist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 9 Elastic.OxfordComma Use the Oxford comma in 'reading, writing and executing.'.
vale/test-fixtures/sample-violations.md 10 Elastic.Wordiness Consider using 'to' instead of 'In order to'.
vale/test-fixtures/sample-violations.md 10 Elastic.Wordiness Consider using 'because' instead of 'due to the fact that'.
vale/test-fixtures/sample-violations.md 10 Elastic.Wordiness Consider using 'many' instead of 'a large number of'.
vale/test-fixtures/sample-violations.md 12 Elastic.Exclamation Use exclamation points sparingly. Remove the exclamation point unless it appears in UI text.
vale/test-fixtures/sample-violations.md 12 Elastic.Exclamation Use exclamation points sparingly. Remove the exclamation point unless it appears in UI text.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'efficiently' instead of 'Simply', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'allowlist' instead of 'whitelist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'blocklist' instead of 'blacklist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'efficient' instead of 'easy', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 32 Elastic.OxfordComma Use the Oxford comma in 'reading, writing and executing.'.
vale/test-fixtures/sample-violations.md 36 Elastic.Wordiness Consider using 'to' instead of 'In order to'.
vale/test-fixtures/sample-violations.md 36 Elastic.Wordiness Consider using 'because' instead of 'due to the fact that'.
vale/test-fixtures/sample-violations.md 36 Elastic.Wordiness Consider using 'many' instead of 'a large number of'.
vale/test-fixtures/sample-violations.md 44 Elastic.Exclamation Use exclamation points sparingly. Remove the exclamation point unless it appears in UI text.
vale/test-fixtures/sample-violations.md 44 Elastic.Exclamation Use exclamation points sparingly. Remove the exclamation point unless it appears in UI text.

The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.

@theletterf
theletterf merged commit b90052d into main Sep 30, 2026
17 checks passed
@theletterf
theletterf deleted the feat/review-classifier branch September 30, 2026 13:04
stefnestor pushed a commit to stefnestor/docs-content that referenced this pull request Sep 30, 2026
This PR connects docs-content to the review classifier from
[elastic/docs-actions#382](elastic/docs-actions#382)
in dry-run mode only, and adds the rules file
`.github/review-classifier.yml`. Maintainers can classify one PR at a
time from the **Actions** tab. Nothing is posted on PRs until someone
sets `dry-run: false` or turns on the automatic trigger.

**Prompt summary:** Implement the light or full review classification
that
[elastic/docs-content-internal#1943](elastic/docs-content-internal#1943)
specifies. Start with a dry-run mode that targets one PR, and keep the
automatic `pull_request` trigger commented out. Keep the rules in this
repository, so the docs team can maintain them.

## Why

The team wants to see the classifier results on real docs-content PRs,
and possibly change the rules, before it comments on every PR. A
backtest on 185 recent PRs gives 53% full reviews with the rules from
the issue, so the rules possibly need changes first. A rules file in
this repo lets the team make those changes with a normal docs-content
PR.

## What

#### Rules file

`.github/review-classifier.yml` holds the values from
[elastic/docs-content-internal#1943](elastic/docs-content-internal#1943)
for all nine triggers. It also adds the files from `exclude:` in
`docset.yml` to `skip-paths`, so a new `AGENTS.md` does not count as a
new page. The classifier reads this file from `main`, so a PR cannot
change the rules that classify it.

#### Manual classification

`docs-review-classifier.yml` runs from `workflow_dispatch` with a
`pr-number` input and `dry-run: true` by default. A dry run writes the
tier, the reasons, the planned label changes, and a comment preview to
the job summary. The `pull_request` trigger is present but commented
out.

#### Comment and labels

`docs-review-classifier-comment.yml` runs after each classification. It
posts the comment and sets `review: light` or `review: full` only when a
run has `dry-run: false`.

**Stack:** 2 of 2, depends on
[elastic/docs-actions#382](elastic/docs-actions#382).
The callers use `@v1`, so this PR stays a draft until that PR merges and
a docs-actions release moves the `v1` tag.

**Out of scope:** Creating the `review: light` and `review: full`
labels. The comment workflow tries to create them on the first run that
is not a dry run.

## Verify

After the docs-actions release, open **Actions** > **Review
classification** > **Run workflow**. Enter a PR number and keep
`dry-run` selected. Check that the job summary shows the tier and the
comment preview, and that the PR gets no comment or labels.

To test a rule change before it merges, push the change to
`.github/review-classifier.yml` on a branch. Then run the workflow from
that branch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants