3 Commits
Author SHA1 Message Date
Eva SarafianouandClaude Opus 5.5 bbbc593cb1 feat(docs-ai): remind authors when merged PRs still carry Docs/Needed (#40009)
* feat(docs-ai): remind authors when merged PRs still carry Docs/Needed

On the 8th and 12th of each month, comment on PRs merged in the last
180 days that still have Docs/Needed. Ask the author (or, for bot PRs,
the human assignee or merger) to submit and merge the docs, or to swap
the label for Docs/Done if that already happened. Link the writer's
open docs PR when one exists. One comment per PR per run date.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs-ai reminder: pace comment posts, default to 45-day lookback

- Space reminder comment posts one second apart and retry a rate-limited
  post with backoff; a post that still cannot go through is logged, the
  run continues with the next PR and exits non-zero at the end.
- Grant pull-requests: write alongside issues: write for the remind job.
- Default lookback is now 45 days (script, workflow input, README, tests).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs-ai reminder: wait per Retry-After / x-ratelimit-reset headers

The shared gh helper now attaches the response status and headers to the
error it throws (message unchanged). The reminder waits for Retry-After,
then x-ratelimit-reset when the quota is spent, and falls back to the
one-minute backoff otherwise. It also waits before moving on to the next
PR once retries run out.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs-ai reminder: skip writer docs PRs by branch, not title

The docs/pr-<n> head branch is set by the writer workflow and is what it
already uses as its own loop guard; the PR title can be edited by anyone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-26 12:48:37 +02:00
Eva SarafianouandCursor 27c501d217 Replace docs impact review with self-clearing gap detection (#38177)
* Replace docs impact review with self-clearing gap detection

The old workflow sparse-checked-out mattermost/docs and cited source/**.rst
paths that no longer exist, so it was judging the current PR against a docs
tree this repo replaced. It also applied Docs/Needed and never removed it,
which made the label a permanent record of a gap rather than a statement about
the PR as it stands.

docs-gap.yml reads both sides of the diff — the code and whatever docs the PR
already carries — so a later push that documents the change flips the verdict
to none and clears the label. The label follows the verdict, not the presence
of a docs diff, or clearing it would be an escape hatch anyone could take by
editing an unrelated page. Prior state travels in the sticky comment, so a
label a human applied survives a none verdict.

The audience personas come from the same frontmatter the review router reads
instead of being restated in workflow YAML, which is what keeps the two halves
of the pipeline from disagreeing about who reads what.

Both are added and removed in one commit: they share a trigger, so running
them together would double-comment and race the label.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Tune docs-gap prompt, CAP limits, and Action pins

Correct API docs publish scope, size wrap caps for ~10k/1k LoC and ~100 paths, and bump checkout/setup-node to v7.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Split docs-ai into review/, gap/, and shared lib/

Make which pipeline owns which scripts obvious; keep one package and shared helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Trim docs-gap comments to non-obvious rationale

Keep the why for label lifecycle, soft-fail, and secrets gating; drop restated narration.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix gap-report footer, label-remove restore, and cancelled report job

Address CodeRabbit: hide opt-out on none, restore sticky if removeLabel fails, shell-safe dry-run example, skip report on concurrency cancel.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Harden sticky author match and pin claude-code-action v1.0.235

Match stickies to github-actions[bot] only, use the job GITHUB_TOKEN
instead of Claude App OIDC on analyze, and bump the action pin.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 12:49:16 +03:00
Eva SarafianouandCursor 3a1f5f0da1 Add AI persona review pipeline for docs PRs (#38144)
* Add AI persona review pipeline for docs PRs

Six reader personas review changes under docs/main, docs/develop and
docs/api, and one sticky comment per PR carries their verdicts. Advisory
only: nothing blocks a merge, and the review is a no-op when
ANTHROPIC_API_KEY is unset, so forks and unconfigured checkouts are
unaffected.

The registry is the set of files in .github/prompts/personas/, each
carrying its metadata in frontmatter, so adding a persona means adding a
file. Rules that don't vary by audience live in conventions.md and
review-contract.md instead of being restated six times, and they form a
byte-identical prefix across personas so they hit the prompt cache.

Conventions were derived by measuring docs/ rather than ported from the
migration PoC, which corrected three wrong assumptions: title is the only
required frontmatter key, plan gating is <PlanAvailability slug>, and
internal links are absolute site paths.

No prose linter runs. The Vale config already in the repo comes from the
PoC and has never been run against this corpus; it produces ~8,375
findings, most of them false positives, so brand-voice judges heading case
and terminology in context instead. This change leaves those files
untouched and records the measurement in the docs-ai README, so whether
they should stay at all can be decided separately.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix version anchoring rules and drop the milestone from docs review

The milestone was a no-op. Assigning one is not a workflow trigger, and the
value comes from the event payload, so a milestone set late in the cycle —
which is when release management sets them — never reached a review at all.
Removed end to end: the workflow env var, the script flag, and both prompt
branches. Authoring keeps its milestone rule, since docs-needed.yml guarantees
one is set before the writer runs.

Version anchoring is now split by role rather than by who wrote the change. A
reviewer cannot tell whether a person or a generator produced a diff, so the
previous framing was undecidable at the point of use. Reviewers check that an
anchor exists, accept one the author states — developers ship docs with the
code and know their target release — and always flag the authoring placeholder,
which only a human can clear.

Reviewers also no longer defer findings. The old budget guidance had
brand-voice drop lesser categories to fit three slots, which surfaced them one
push at a time as earlier ones were fixed, indistinguishable from the standard
moving. Findings are pattern-collapsed instead, and a truncated list names its
remainder in the summary so an author can fix everything in one pass.

Drops dry-run.mjs and lib/diff.mjs, which nothing else consumed, and the README
link from the comment footer. Comments trimmed throughout.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Tighten docs AI prompts and harden the review comment

Scope brand-voice's consistency check to the diff: it cannot see pages
outside the change, so asking it to compare against neighbours invites
claims about content it never read.

Only adopt a bot-authored comment when updating the review. The marker
renders invisibly, so anyone able to comment could plant it and have the
next run overwrite their post.

Make the verdict example valid JSON, replace the frontmatter regex with
an explicit split, and cut the README back to the persona format and the
constraints a contributor can unknowingly break.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Validate persona docs_paths and code_signals at load

A docs_paths entry that no longer exists matches nothing, so the persona
silently stops being selected for the content it owns; an impact-scoped
persona with no code_signals silently gates on nothing. Both were only
caught by the test suite. Check them where the registry is built, so
editing a persona locally fails with the offending path named.

Code paths are deliberately not checked on disk: they are matched as
prefixes and move far more often than docs directories.

Also say in the README that the file body is the persona's system prompt.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Test the model-output and frontmatter edge cases

parseJson and withRetry had no coverage at all, and they sit either side
of every model call: one turns fenced or prose-wrapped output into a
verdict, the other decides whether a failure costs one API call or three.
The frontmatter rules were covered only for the personas we ship, so the
validation itself — id mismatch, unknown scope, a docs_paths entry that
does not exist — went unexercised.

Two seams were needed. parsePersona now takes the file contents instead
of reading them, because fixtures cannot live in the personas directory:
that directory is the registry, so a fixture in it would be a reviewer.
withRetry takes an injectable wait, so the retry path is tested without
3.5s of real backoff.

Each new test was checked by mutating the code it covers.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Validate the persona registry on master, and co-locate the unit tests

The registry resolves docs_paths against the working tree, so a docs
rename that lands between a PR's last run and its merge breaks master
with neither PR going red. Run validate on push as well; prepare now
gates on the event, and review and report follow it, so a push costs one
job and no model calls.

Move the three unit tests beside the modules they cover, matching how the
webapp places its tests. registry.test.mjs stays at the top level: it
checks the personas and prompts we ship rather than any one module.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Find the sticky review comment past the first page of a PR thread

report.mjs read one page of issue comments and stopped. That endpoint returns
oldest-first and takes no ordering parameter, so a sticky comment created once a
thread already held 100 comments fell outside the only page ever fetched, and
every later push posted a duplicate instead of editing it. The GitHub client
moves to lib/github.mjs, where the comment walk is a lazy generator that stops
at the first match: unchanged single request on a short thread, and no
duplicates on a long one.

Also drops docs/api from review scope. Its reference pages are generated from
the OpenAPI spec, so a finding there can only ever be fixed in api/v4/source/,
and the workflow, the personas and the README now say so. The workflow excludes
docs/main/agents/docs for the same reason.

complete() takes userPrompt rather than user, so the argument reads as the
prompt it is next to the system prompt.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Run docs persona review on pull requests only

The push trigger only ever ran `validate`; the sticky comment the rest of
the workflow exists to produce has nowhere to land outside a PR. A registry
break now surfaces on the next docs PR instead of on the merge that caused
it, which costs a little latency and saves a run on every merge to master.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Run docs AI review via workflow_dispatch as a single job

The pull_request matrix attached a check per persona plus validate /
prepare / report, which flooded the PR checks list before we had tuned
the personas. Manual dispatch with a PR number lets us exercise real
diffs without an audience; collapsing to one job keeps the later
pull_request restore to a single check.

Scripts and prompts come from the workflow ref, so a same-repo branch
cannot rewrite the pipeline that reviews it. Also bump @anthropic-ai/sdk
to 0.127.0 (was 0.40) and js-yaml to 4.3.2 for the merge-keys advisory,
and disable the SDK's own retries so they do not stack on withRetry.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Trim docs-review workflow comments to the non-obvious

Keep only why dispatch is manual/single-job, why PR metadata
avoids GITHUB_OUTPUT, the merge-ref fallback, fail-soft persona
waits, and why SDK retries are disabled.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-25 21:21:11 +03:00