Skip to content

[ci] Add credential-free redirect-validation premerge check - #64413

Merged
dstrodtman merged 2 commits into
ray-project:masterfrom
dstrodtman:doc-1299-redirect-ci-check
Aug 14, 2026
Merged

dstrodtman merged 2 commits into
ray-project:masterfrom
dstrodtman:doc-1299-redirect-ci-check

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

The YAML under doc/redirects/ is the source of truth for the docs.ray.io Read the Docs redirect configuration, managed with rtd-redirects. Today a PR that edits only redirect YAML runs no check at all, so a malformed or unreachable redirect can merge unnoticed.

Nothing routes redirect YAML anywhere. .yaml isn't covered by the leading prose-and-image skip rule, nor by the doc/*.py/doc/*.ipynb/doc/*/BUILD.bazel catch-all, so it falls through to the broad doc/ pass rule at the bottom of the doc section and emits no tag at all. Confirmed against the rule engine on master: doc/redirects/current.yaml emits set().

This adds a lightweight, credential-free premerge gate for doc/redirects/*.yaml that validates the redirects and prints the redirect-level diff. The change is purely additive: it gives redirect YAML a check where it previously had none, and no other path's selection changes.

What changed

  • .buildkite/test.rules.txt — declare a doc_redirects test tag and route doc/redirects/*.yaml to it. The rule sits ahead of every doc/ rule, which matters because the final doc/ pass rule is what currently swallows these files.

    The rule emits doc_redirects alone, deliberately not doc or doc_api. A redirect edit can't change the documented API surface, and the check needs neither a rendered documentation build nor a compiled Ray: it parses the YAML and diffs it against the base ref.

  • .buildkite/test.rules.txt — route .buildkite/doc.rayci.yml to doc_redirects as well, on its own rule rather than by extending the autodoc-machinery block, so a conf.py edit doesn't start running the redirect check. An edit to a step definition has to be able to select the step it edits, which is the same reason that file already emits doc_api. This also covers the anyscale-rtd-redirects version pin, which lives in the redirect step's commands, so a version bump re-runs the check.

  • .buildkite/test.rules.test.txt — three cases: doc/redirects/current.yaml: doc_redirects, doc/redirects/README.md: asserting the prose beside it stays unrouted, and .buildkite/doc.rayci.yml: doc doc_api doc_redirects. The last one revises an assertion that already existed on master, since that file's tag set genuinely changes here.

  • .buildkite/doc.rayci.yml — add a forge-based step (no doc image) that installs the pinned anyscale-rtd-redirects==0.2.0 from PyPI and runs:

    rtd-redirects validate doc/redirects/current.yaml
    rtd-redirects diff-file --file doc/redirects/current.yaml --base FETCH_HEAD --head HEAD --repo .
    

    The step diffs against FETCH_HEAD after fetching the PR's base branch, rather than against origin/<base>: a clone with a restricted refspec may never create a local remote-tracking ref, and doc/test_no_new_rst.py already solves the same problem the same way. The base branch resolves at runtime from $${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}, escaped so the shell expands it rather than Buildkite interpolating it at pipeline-upload time, matching the $${...} convention used across the other pipeline files.

    The step also fails closed if doc/redirects/ grows a YAML file the commands don't name. The tag selects on a glob, but multiple redirect files compose in the order given and a shell glob can't express that order, so the guard forces the compose-order decision to be made explicitly instead of letting a new file select the step and then go unvalidated.

Verification

Verified with Ray's rule parser (ci/pipeline/determine_tests_to_run.py), the same first-match-wins engine rayci uses:

  • check_rules() parses clean, and all 126 cases in test.rules.test.txt replay green. That file is enforced by the test-rules CI step, and rayci asserts exact set equality, so a passing case proves the path emits exactly those tags and nothing else.
  • A sweep of all 10,333 tracked files against master shows exactly two deltas — doc/redirects/current.yaml gaining doc_redirects, and .buildkite/doc.rayci.yml gaining it alongside its existing doc doc_api — and zero tag losses on any path. Every pre-existing assertion in test.rules.test.txt is preserved except the doc.rayci.yml one this PR deliberately revises.
  • Ran the step's commands locally in a clean venv with anyscale-rtd-redirects==0.2.0 against the current doc/redirects/current.yaml: validate reports 0 errors (49 chain warnings, informational), and diff-file --base FETCH_HEAD reports the redirect-level diff and exits 0 with no Read the Docs credentials.
  • Exercised the drift guard both ways: it passes with only current.yaml present and exits non-zero when a second doc/redirects/*.yaml appears.

Because .buildkite/doc.rayci.yml now emits doc_redirects, this PR selects the new step and runs it. Replaying this PR's own changed files through the rule engine gives a tag union of doc, doc_api, doc_redirects, and tools, so the step's commands are exercised in CI here rather than only on some later PR that happens to edit redirect YAML. It runs against an unchanged current.yaml, so diff-file reports an empty redirect diff and exits 0, which is exactly the smoke test that catches a typo in the step definition.

Update: rebased onto the doc-tag reorg

Rebased after #64775 and #64812 landed, which reorganized the doc tags: doc example tests moved to per-library <lib>_doc tags, and doc was split so the autodoc machinery emits doc doc_api while the rendering-only surface emits doc. This branch's four commits (one an upstream merge) are collapsed into one. Two conflicts in test.rules.txt (the tag declaration line, and the rule insertion point) and one in test.rules.test.txt (three expectations the reorg had since updated) were resolved in favor of master, then the doc_redirects rule and cases re-applied on top.

The rebase also invalidated this PR's original rationale, so the rule and step comments have been rewritten. The earlier framing was that doc_redirects keeps redirect YAML from pulling in docbuild, the API checks, and the per-team doc tests. That's no longer accurate on any of the three: the per-team tests are selected by <lib>_doc, the two API checks carry doc_api plus the library tags and no longer carry bare doc, and the only remaining step carrying bare doc is doc: build, which is skip-on-premerge. Since redirect YAML emits nothing at all on master, this rule was never preventing over-triggering. It's additive, and the comments now say so.

Update: the step now selects itself

Cursor Bugbot caught that the redirect step wasn't reachable from an edit to its own definition: .buildkite/doc.rayci.yml emitted doc doc_api but never doc_redirects, so changing the redirect step's commands wouldn't have run the redirect step. That contradicted the rule's own stated reason for emitting doc_api, and this PR demonstrated the gap: its previous revision noted that the new step didn't execute here.

Fixed by giving .buildkite/doc.rayci.yml its own rule emitting doc doc_api doc_redirects. It's a separate rule rather than an extra tag on the autodoc-machinery block, because that block also covers conf.py, api_autogen.py, and doc/source/_ext/, and a conf.py edit has no business running the redirect check. The first attempt at this appended the tag to the shared block and the full-repo sweep caught it immediately: seven machinery files picked up doc_redirects.

AI assistance (Claude Code) was used to draft the CI step, the rebase conflict resolution, and this description. Every changed line was reviewed by hand, and the verification above was run as described. This isn't duplicating existing work: no other open PR adds redirect validation to premerge, and the doc_redirects tag doesn't exist on master.

Update: uv, and a recursive fail-closed guard

Two review follow-ups.

Install with uv (Elliot's suggestion). ci/docker/forge.Dockerfile already installs uv to /usr/local/bin and uses it for the image's Python, so the step needs no extra setup. It's uv tool install rather than uv pip install --system for a PATH reason: the previous revision's premerge log shows pip install fell back to a user install, so the rtd-redirects entry point resolved from ~/.local/bin. uv tool install writes executables to that same directory, so PATH resolution is unchanged. uv pip install --system would target the uv-managed interpreter and put the entry point in that env's bin, which isn't on PATH.

The fail-closed guard now recurses. Cursor Bugbot caught that the guard's single-level shell glob didn't cover a nested redirect file, and it was right. The rule engine matches with fnmatch, whose * crosses /, so doc/redirects/nested/foo.yaml emits doc_redirects and selects this step, while ls doc/redirects/*.yaml never saw it and the guard passed. Replacing the glob with find closes the gap. Exercised three ways locally: passes with only current.yaml, exits non-zero for a nested file and for a sibling file.

A .yml file stays out of scope. The tag rule matches *.yaml only, so doc/redirects/current.yml emits no tags and never selects the step, putting it beyond the guard's reach. That matches the pre-PR baseline for every redirect file rather than regressing anything, and rtd-redirects uses .yaml.

Re-verified after the change: rules parse clean and all 126 cases in test.rules.test.txt replay green (the rule files are untouched by this revision).

Related issue number

N/A

Checks

  • I've signed off every commit (-s), because all commits are squashed into one when merged.
  • I've run scripts/format.sh to lint the changes in this PR. (Via pre-commit; the applicable hooks pass.)
  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a dedicated, credential-free premerge check (doc_redirects) for validating documentation redirects in doc/redirects/current.yaml. This lightweight check avoids running the full documentation build pipeline for redirect-only PRs. The feedback recommends avoiding hardcoding master as the base branch in the Buildkite configuration, suggesting the use of BUILDKITE_PULL_REQUEST_BASE_BRANCH with a fallback to master to correctly support PRs targeting release branches.

Comment thread .buildkite/doc.rayci.yml Resolved
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jul 14, 2026
@dstrodtman dstrodtman added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Jul 14, 2026
@dstrodtman
dstrodtman marked this pull request as ready for review July 29, 2026 18:23
@dstrodtman
dstrodtman requested a review from a team as a code owner July 29, 2026 18:23

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a lightweight, credential-free premerge check (doc_redirects) for documentation redirects (doc/redirects/*.yaml) to bypass the full documentation build for redirect-only PRs. The feedback suggests explicitly specifying the refspec in the git fetch command to prevent potential failures during diffing in CI environments with restricted refspecs.

Comment thread .buildkite/doc.rayci.yml Outdated
- pip install --no-cache-dir anyscale-rtd-redirects==0.2.0
# diff-file reads the base via `git show origin/<base>:<path>`, so resolve the
# PR's base branch (falling back to master for non-PR builds) and ensure it's present.
- git fetch -q origin "${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

In CI environments, the repository is sometimes cloned with a restricted refspec (such as single-branch or shallow clones). A simple git fetch command might not update or create the local remote-tracking branch, which can cause the subsequent diff-file command to fail with an unknown revision error. Specifying the refspec explicitly in the fetch command ensures that the remote-tracking branch is always created and updated correctly.

      - git fetch -q origin "+refs/heads/${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}:refs/remotes/origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right diagnosis, and it's precisely why the step doesn't reference origin/<base> at all. Rather than mapping an explicit refspec so the remote-tracking branch gets created, the step diffs against FETCH_HEAD:

- git fetch -q origin "$${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}"
- rtd-redirects diff-file --file doc/redirects/current.yaml --base FETCH_HEAD --head HEAD --repo .

git fetch always writes FETCH_HEAD, so this needs no refspec mapping and doesn't depend on a remote-tracking ref existing, which covers the single-branch and shallow-clone cases without having to reason about the clone's refspec. doc/test_no_new_rst.py already solves the same problem the same way, so this keeps the two consistent.

This works because rtd-redirects diff-file resolves the base with git show <ref>:<path>, which takes FETCH_HEAD like any other ref.

As on the other thread: the branch was rebased onto master after #64775 and #64812 landed and force-pushed, so this line anchor is outdated.

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation devprod labels Jul 29, 2026
@dstrodtman
dstrodtman force-pushed the doc-1299-redirect-ci-check branch from 9882983 to 3cd6e46 Compare August 5, 2026 20:49
Comment thread .buildkite/test.rules.txt Resolved
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Aug 6, 2026
@dstrodtman
dstrodtman force-pushed the doc-1299-redirect-ci-check branch from 3cd6e46 to 873f615 Compare August 6, 2026 19:42

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 873f615. Configure here.

Comment thread .buildkite/doc.rayci.yml Resolved
`doc/redirects/current.yaml` drives the Read the Docs redirect set, and
nothing validated it at PR time. Redirect YAML matches no rule in
test.rules.txt: `.yaml` isn't covered by the leading prose-and-image skip
or by the `doc/*.py`/`doc/*.ipynb` catch-all, so it falls through to the
broad `doc/` pass rule and triggers no documentation step at all. A
malformed or conflicting redirect only surfaced after merge.

Add a `doc: validate redirects` step that runs `rtd-redirects validate`
and `rtd-redirects diff-file` against the PR's base ref, and a
`doc_redirects` tag that routes `doc/redirects/*.yaml` to it. No path
loses a tag, and no other rule's behavior changes.

The redirect-YAML rule emits `doc_redirects` alone, not `doc` or
`doc_api`. A redirect edit can't change the documented API surface and
doesn't need a rendered build or a compiled Ray, so the step runs in
forge, installs the pinned `anyscale-rtd-redirects` PyPI package, and uses
no Read the Docs token, which keeps it safe on fork PRs.

`.buildkite/doc.rayci.yml` also emits `doc_redirects`, on its own rule
rather than in the autodoc-machinery block, so that a `conf.py` edit
doesn't run the redirect check. An edit to a step definition has to be
able to select the step it edits: without this, changing the redirect
step's commands would never run the redirect step on the PR making the
change. It also covers the `anyscale-rtd-redirects` version pin, which
lives in those commands, so a version bump re-runs the check.

Two guards on the parts that can drift:

- The commands name `current.yaml` explicitly rather than globbing,
  because multiple redirect files compose in the order given and a shell
  glob can't express that order. The step fails closed if another `.yaml`
  appears in `doc/redirects/`, so a new file can't select the step and
  then go unvalidated.
- `diff-file` resolves the base with `git show <ref>:<path>`, so the step
  fetches the PR's base branch and diffs against `FETCH_HEAD`. This is
  the pattern `doc/test_no_new_rst.py` already uses: a clone with a
  restricted refspec may never create a local `origin/<base>`.

Test cases cover the routed YAML, the unrouted README beside it, and
doc.rayci.yml's three tags. Verified with the rayci rule engine: rules
parse clean, all 126 replay cases pass, and a sweep of all 10,333 tracked
files shows exactly two deltas against master
(`doc/redirects/current.yaml` gaining `doc_redirects`, and
`.buildkite/doc.rayci.yml` gaining it alongside `doc doc_api`) with zero
tag losses on any path.

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1299-redirect-ci-check branch from 873f615 to da45fdd Compare August 12, 2026 13:28
Comment thread .buildkite/doc.rayci.yml Outdated
Comment on lines +126 to +128
- doc_redirects
commands:
- pip install --no-cache-dir anyscale-rtd-redirects==0.2.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: can you use uv instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should be available on the forge image already

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 586cd1b — uv tool install anyscale-rtd-redirects==0.2.0.

Confirmed it's on the image: ci/docker/forge.Dockerfile installs uv to /usr/local/bin and uses it for the image's Python, so this needs no extra setup.

Went with uv tool install over uv pip install --system on a PATH detail. The premerge log for the previous revision shows the old pip install fell back to a user install ("Defaulting to user installation because normal site-packages is not writeable"), so the rtd-redirects entry point resolved from ~/.local/bin. uv tool install writes its executables to that same directory, so PATH resolution is unchanged. uv pip install --system would target the uv-managed interpreter instead and put the entry point in that env's bin, which isn't on PATH.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verified in CI: the step ran on this revision (build 71912, :book: doc: validate redirects) and passed. uv resolved and installed in ~1s, reported Installed 1 executable: rtd-redirects with no PATH warning, and both validate and diff-file ran clean.

Two review follow-ups on the redirect-validation step.

Install the pinned package with `uv tool install` instead of `pip install`.
uv is already on the forge image (ci/docker/forge.Dockerfile installs it to
/usr/local/bin and uses it for the image's Python), and `uv tool install`
lands the `rtd-redirects` executable in the same ~/.local/bin that the pip
user install was already writing to, so PATH resolution is unchanged.

Make the fail-closed guard recurse. The `doc_redirects` tag rule matches with
fnmatch, whose `*` crosses `/`, so doc/redirects/nested/foo.yaml selects this
step; the old single-level `ls doc/redirects/*.yaml` glob never saw such a
file, so it passed and the nested file went unvalidated. `find` closes that
gap and still trips on a sibling file.

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman merged commit cd59f3a into ray-project:master Aug 14, 2026
6 checks passed
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ect#64413)

## Why are these changes needed?

The YAML under `doc/redirects/` is the source of truth for the
docs.ray.io Read the Docs redirect configuration, managed with
[rtd-redirects](https://github.com/anyscale/rtd-redirects). Today a PR
that edits only redirect YAML runs no check at all, so a malformed or
unreachable redirect can merge unnoticed.

Nothing routes redirect YAML anywhere. `.yaml` isn't covered by the
leading prose-and-image skip rule, nor by the
`doc/*.py`/`doc/*.ipynb`/`doc/*/BUILD.bazel` catch-all, so it falls
through to the broad `doc/` pass rule at the bottom of the doc section
and emits no tag at all. Confirmed against the rule engine on master:
`doc/redirects/current.yaml` emits `set()`.

This adds a lightweight, credential-free premerge gate for
`doc/redirects/*.yaml` that validates the redirects and prints the
redirect-level diff. The change is purely additive: it gives redirect
YAML a check where it previously had none, and no other path's selection
changes.

## What changed

- **`.buildkite/test.rules.txt`** — declare a `doc_redirects` test tag
and route `doc/redirects/*.yaml` to it. The rule sits ahead of every
`doc/` rule, which matters because the final `doc/` pass rule is what
currently swallows these files.

The rule emits `doc_redirects` alone, deliberately not `doc` or
`doc_api`. A redirect edit can't change the documented API surface, and
the check needs neither a rendered documentation build nor a compiled
Ray: it parses the YAML and diffs it against the base ref.
- **`.buildkite/test.rules.txt`** — route `.buildkite/doc.rayci.yml` to
`doc_redirects` as well, on its own rule rather than by extending the
autodoc-machinery block, so a `conf.py` edit doesn't start running the
redirect check. An edit to a step definition has to be able to select
the step it edits, which is the same reason that file already emits
`doc_api`. This also covers the `anyscale-rtd-redirects` version pin,
which lives in the redirect step's commands, so a version bump re-runs
the check.
- **`.buildkite/test.rules.test.txt`** — three cases:
`doc/redirects/current.yaml: doc_redirects`, `doc/redirects/README.md:`
asserting the prose beside it stays unrouted, and
`.buildkite/doc.rayci.yml: doc doc_api doc_redirects`. The last one
revises an assertion that already existed on master, since that file's
tag set genuinely changes here.
- **`.buildkite/doc.rayci.yml`** — add a `forge`-based step (no doc
image) that installs the pinned `anyscale-rtd-redirects==0.2.0` from
PyPI and runs:
  ```
  rtd-redirects validate doc/redirects/current.yaml
rtd-redirects diff-file --file doc/redirects/current.yaml --base
FETCH_HEAD --head HEAD --repo .
  ```
The step diffs against `FETCH_HEAD` after fetching the PR's base branch,
rather than against `origin/<base>`: a clone with a restricted refspec
may never create a local remote-tracking ref, and
`doc/test_no_new_rst.py` already solves the same problem the same way.
The base branch resolves at runtime from
`$${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}`, escaped so the shell
expands it rather than Buildkite interpolating it at pipeline-upload
time, matching the `$${...}` convention used across the other pipeline
files.

The step also fails closed if `doc/redirects/` grows a YAML file the
commands don't name. The tag selects on a glob, but multiple redirect
files compose in the order given and a shell glob can't express that
order, so the guard forces the compose-order decision to be made
explicitly instead of letting a new file select the step and then go
unvalidated.

## Verification

Verified with Ray's rule parser
(`ci/pipeline/determine_tests_to_run.py`), the same first-match-wins
engine rayci uses:

- `check_rules()` parses clean, and all 126 cases in
`test.rules.test.txt` replay green. That file is enforced by the
`test-rules` CI step, and rayci asserts exact set equality, so a passing
case proves the path emits exactly those tags and nothing else.
- A sweep of all 10,333 tracked files against master shows **exactly two
deltas** — `doc/redirects/current.yaml` gaining `doc_redirects`, and
`.buildkite/doc.rayci.yml` gaining it alongside its existing `doc
doc_api` — and **zero tag losses** on any path. Every pre-existing
assertion in `test.rules.test.txt` is preserved except the
`doc.rayci.yml` one this PR deliberately revises.
- Ran the step's commands locally in a clean venv with
`anyscale-rtd-redirects==0.2.0` against the current
`doc/redirects/current.yaml`: `validate` reports 0 errors (49 chain
warnings, informational), and `diff-file --base FETCH_HEAD` reports the
redirect-level diff and exits 0 with no Read the Docs credentials.
- Exercised the drift guard both ways: it passes with only
`current.yaml` present and exits non-zero when a second
`doc/redirects/*.yaml` appears.

Because `.buildkite/doc.rayci.yml` now emits `doc_redirects`, **this PR
selects the new step and runs it**. Replaying this PR's own changed
files through the rule engine gives a tag union of `doc`, `doc_api`,
`doc_redirects`, and `tools`, so the step's commands are exercised in CI
here rather than only on some later PR that happens to edit redirect
YAML. It runs against an unchanged `current.yaml`, so `diff-file`
reports an empty redirect diff and exits 0, which is exactly the smoke
test that catches a typo in the step definition.

## Update: rebased onto the doc-tag reorg

Rebased after ray-project#64775 and ray-project#64812 landed, which reorganized the doc tags:
doc example tests moved to per-library `<lib>_doc` tags, and `doc` was
split so the autodoc machinery emits `doc doc_api` while the
rendering-only surface emits `doc`. This branch's four commits (one an
upstream merge) are collapsed into one. Two conflicts in
`test.rules.txt` (the tag declaration line, and the rule insertion
point) and one in `test.rules.test.txt` (three expectations the reorg
had since updated) were resolved in favor of master, then the
`doc_redirects` rule and cases re-applied on top.

The rebase also invalidated this PR's original rationale, so the rule
and step comments have been rewritten. The earlier framing was that
`doc_redirects` keeps redirect YAML from pulling in docbuild, the API
checks, and the per-team doc tests. That's no longer accurate on any of
the three: the per-team tests are selected by `<lib>_doc`, the two API
checks carry `doc_api` plus the library tags and no longer carry bare
`doc`, and the only remaining step carrying bare `doc` is `doc: build`,
which is `skip-on-premerge`. Since redirect YAML emits nothing at all on
master, this rule was never preventing over-triggering. It's additive,
and the comments now say so.

## Update: the step now selects itself

Cursor Bugbot caught that the redirect step wasn't reachable from an
edit to its own definition: `.buildkite/doc.rayci.yml` emitted `doc
doc_api` but never `doc_redirects`, so changing the redirect step's
commands wouldn't have run the redirect step. That contradicted the
rule's own stated reason for emitting `doc_api`, and this PR
demonstrated the gap: its previous revision noted that the new step
didn't execute here.

Fixed by giving `.buildkite/doc.rayci.yml` its own rule emitting `doc
doc_api doc_redirects`. It's a separate rule rather than an extra tag on
the autodoc-machinery block, because that block also covers `conf.py`,
`api_autogen.py`, and `doc/source/_ext/`, and a `conf.py` edit has no
business running the redirect check. The first attempt at this appended
the tag to the shared block and the full-repo sweep caught it
immediately: seven machinery files picked up `doc_redirects`.

AI assistance (Claude Code) was used to draft the CI step, the rebase
conflict resolution, and this description. Every changed line was
reviewed by hand, and the verification above was run as described. This
isn't duplicating existing work: no other open PR adds redirect
validation to premerge, and the `doc_redirects` tag doesn't exist on
master.

## Update: uv, and a recursive fail-closed guard

Two review follow-ups.

**Install with `uv`** (Elliot's suggestion).
`ci/docker/forge.Dockerfile` already installs uv to `/usr/local/bin` and
uses it for the image's Python, so the step needs no extra setup. It's
`uv tool install` rather than `uv pip install --system` for a PATH
reason: the previous revision's premerge log shows `pip install` fell
back to a user install, so the `rtd-redirects` entry point resolved from
`~/.local/bin`. `uv tool install` writes executables to that same
directory, so PATH resolution is unchanged. `uv pip install --system`
would target the uv-managed interpreter and put the entry point in that
env's `bin`, which isn't on PATH.

**The fail-closed guard now recurses.** Cursor Bugbot caught that the
guard's single-level shell glob didn't cover a nested redirect file, and
it was right. The rule engine matches with `fnmatch`, whose `*` crosses
`/`, so `doc/redirects/nested/foo.yaml` emits `doc_redirects` and
selects this step, while `ls doc/redirects/*.yaml` never saw it and the
guard passed. Replacing the glob with `find` closes the gap. Exercised
three ways locally: passes with only `current.yaml`, exits non-zero for
a nested file and for a sibling file.

A `.yml` file stays out of scope. The tag rule matches `*.yaml` only, so
`doc/redirects/current.yml` emits no tags and never selects the step,
putting it beyond the guard's reach. That matches the pre-PR baseline
for every redirect file rather than regressing anything, and
`rtd-redirects` uses `.yaml`.

Re-verified after the change: rules parse clean and all 126 cases in
`test.rules.test.txt` replay green (the rule files are untouched by this
revision).

## Related issue number

N/A

## Checks

- [x] I've signed off every commit (`-s`), because all commits are
squashed into one when merged.
- [x] I've run `scripts/format.sh` to lint the changes in this PR. (Via
`pre-commit`; the applicable hooks pass.)
- [x] I've made sure the tests are passing.
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Signed-off-by: 400Ping <[email protected]>
dstrodtman added a commit that referenced this pull request Sep 9, 2026
…tial) (#65866)

## What this does

Adds the merge-time sync step that reconciles
`doc/redirects/current.yaml` into
the live `anyscale-ray` Read the Docs project. This is the automation
that
replaces the manual `rtd-redirects apply` a maintainer runs by hand
today (see
`doc/redirects/README.md`). It completes the redirect-as-code pipeline
whose
credential-free PR-time validation gate already landed in #64413.

**It lands disabled.** The dedicated bot credential it needs isn't
provisioned
yet, so the step carries the `disabled` tag and rayci skips it in both
premerge
and postmerge. This PR is deliberately staged, not ready to
merge-and-run — it's
here so the credential wiring can be reviewed and the dependency
tracked. Same
pattern the `doc: linkcheck` step used to land ahead of its Slack
webhook secret.

## How it's wired

- **Postmerge-only.** The `skip-on-premerge` tag keeps it off every PR
build, so
no PR event — fork or not — ever runs the token-bearing step. It runs
only on
  push to master.
- **Self-gated on the diff.** rayci evaluates file-based tag rules on
premerge
only; master builds are run-all. The step therefore exits early unless
the
merge actually touched `doc/redirects/`, so the token and the RtD API
are used
  only when a redirect changed.
- **Least-privilege secret.** The token is read inline from a dedicated
Secrets
Manager ARN read by no other step — not the shared
`ray-air-test-secrets`
bucket. Blast radius stays bounded to redirects on the one RtD project.

## What I need to enable it

A dedicated bot principal with admin on the `anyscale-ray` RtD project,
its API
token stored in a dedicated Secrets Manager ARN. Once that exists,
enabling is a
one-PR flip: remove the `disabled` tag, replace the
`RTD_TOKEN_SECRET_ARN`
placeholder with the real ARN, and update the "application is manual for
now"
line in `doc/redirects/README.md`.

## One caveat for review

The pinned tool version (0.2.0) has no `--no-delete` or `--accept-drift`
guard,
so the first automated `apply` reconciles hard: a live redirect absent
from
`current.yaml` is deleted. That's the intended one-write-path behavior,
but it's
why the manual-apply phase should finish before this is turned on.

## Test plan

- [x] YAML parses; new step present with tags `oss`, `skip-on-premerge`,
`disabled`.
- [x] Tag-rules dry-run confirms the edit emits only the doc pipeline
      (`doc, doc_api, doc_redirects, lint`), no code fan-out.
- [x] `disabled` tag verified to skip in both premerge and postmerge
rayci configs.
- [ ] Enablement (separate PR, after credential): real
premerge/postmerge run.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
NightWing1998 pushed a commit to NightWing1998/ray that referenced this pull request Sep 11, 2026
…tial) (ray-project#65866)

## What this does

Adds the merge-time sync step that reconciles
`doc/redirects/current.yaml` into
the live `anyscale-ray` Read the Docs project. This is the automation
that
replaces the manual `rtd-redirects apply` a maintainer runs by hand
today (see
`doc/redirects/README.md`). It completes the redirect-as-code pipeline
whose
credential-free PR-time validation gate already landed in ray-project#64413.

**It lands disabled.** The dedicated bot credential it needs isn't
provisioned
yet, so the step carries the `disabled` tag and rayci skips it in both
premerge
and postmerge. This PR is deliberately staged, not ready to
merge-and-run — it's
here so the credential wiring can be reviewed and the dependency
tracked. Same
pattern the `doc: linkcheck` step used to land ahead of its Slack
webhook secret.

## How it's wired

- **Postmerge-only.** The `skip-on-premerge` tag keeps it off every PR
build, so
no PR event — fork or not — ever runs the token-bearing step. It runs
only on
  push to master.
- **Self-gated on the diff.** rayci evaluates file-based tag rules on
premerge
only; master builds are run-all. The step therefore exits early unless
the
merge actually touched `doc/redirects/`, so the token and the RtD API
are used
  only when a redirect changed.
- **Least-privilege secret.** The token is read inline from a dedicated
Secrets
Manager ARN read by no other step — not the shared
`ray-air-test-secrets`
bucket. Blast radius stays bounded to redirects on the one RtD project.

## What I need to enable it

A dedicated bot principal with admin on the `anyscale-ray` RtD project,
its API
token stored in a dedicated Secrets Manager ARN. Once that exists,
enabling is a
one-PR flip: remove the `disabled` tag, replace the
`RTD_TOKEN_SECRET_ARN`
placeholder with the real ARN, and update the "application is manual for
now"
line in `doc/redirects/README.md`.

## One caveat for review

The pinned tool version (0.2.0) has no `--no-delete` or `--accept-drift`
guard,
so the first automated `apply` reconciles hard: a live redirect absent
from
`current.yaml` is deleted. That's the intended one-write-path behavior,
but it's
why the manual-apply phase should finish before this is turned on.

## Test plan

- [x] YAML parses; new step present with tags `oss`, `skip-on-premerge`,
`disabled`.
- [x] Tag-rules dry-run confirms the edit emits only the doc pipeline
      (`doc, doc_api, doc_redirects, lint`), no code fan-out.
- [x] `disabled` tag verified to skip in both premerge and postmerge
rayci configs.
- [ ] Enablement (separate PR, after credential): real
premerge/postmerge run.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ect#64413)

## Why are these changes needed?

The YAML under `doc/redirects/` is the source of truth for the
docs.ray.io Read the Docs redirect configuration, managed with
[rtd-redirects](https://github.com/anyscale/rtd-redirects). Today a PR
that edits only redirect YAML runs no check at all, so a malformed or
unreachable redirect can merge unnoticed.

Nothing routes redirect YAML anywhere. `.yaml` isn't covered by the
leading prose-and-image skip rule, nor by the
`doc/*.py`/`doc/*.ipynb`/`doc/*/BUILD.bazel` catch-all, so it falls
through to the broad `doc/` pass rule at the bottom of the doc section
and emits no tag at all. Confirmed against the rule engine on master:
`doc/redirects/current.yaml` emits `set()`.

This adds a lightweight, credential-free premerge gate for
`doc/redirects/*.yaml` that validates the redirects and prints the
redirect-level diff. The change is purely additive: it gives redirect
YAML a check where it previously had none, and no other path's selection
changes.

## What changed

- **`.buildkite/test.rules.txt`** — declare a `doc_redirects` test tag
and route `doc/redirects/*.yaml` to it. The rule sits ahead of every
`doc/` rule, which matters because the final `doc/` pass rule is what
currently swallows these files.

The rule emits `doc_redirects` alone, deliberately not `doc` or
`doc_api`. A redirect edit can't change the documented API surface, and
the check needs neither a rendered documentation build nor a compiled
Ray: it parses the YAML and diffs it against the base ref.
- **`.buildkite/test.rules.txt`** — route `.buildkite/doc.rayci.yml` to
`doc_redirects` as well, on its own rule rather than by extending the
autodoc-machinery block, so a `conf.py` edit doesn't start running the
redirect check. An edit to a step definition has to be able to select
the step it edits, which is the same reason that file already emits
`doc_api`. This also covers the `anyscale-rtd-redirects` version pin,
which lives in the redirect step's commands, so a version bump re-runs
the check.
- **`.buildkite/test.rules.test.txt`** — three cases:
`doc/redirects/current.yaml: doc_redirects`, `doc/redirects/README.md:`
asserting the prose beside it stays unrouted, and
`.buildkite/doc.rayci.yml: doc doc_api doc_redirects`. The last one
revises an assertion that already existed on master, since that file's
tag set genuinely changes here.
- **`.buildkite/doc.rayci.yml`** — add a `forge`-based step (no doc
image) that installs the pinned `anyscale-rtd-redirects==0.2.0` from
PyPI and runs:
  ```
  rtd-redirects validate doc/redirects/current.yaml
rtd-redirects diff-file --file doc/redirects/current.yaml --base
FETCH_HEAD --head HEAD --repo .
  ```
The step diffs against `FETCH_HEAD` after fetching the PR's base branch,
rather than against `origin/<base>`: a clone with a restricted refspec
may never create a local remote-tracking ref, and
`doc/test_no_new_rst.py` already solves the same problem the same way.
The base branch resolves at runtime from
`$${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}`, escaped so the shell
expands it rather than Buildkite interpolating it at pipeline-upload
time, matching the `$${...}` convention used across the other pipeline
files.

The step also fails closed if `doc/redirects/` grows a YAML file the
commands don't name. The tag selects on a glob, but multiple redirect
files compose in the order given and a shell glob can't express that
order, so the guard forces the compose-order decision to be made
explicitly instead of letting a new file select the step and then go
unvalidated.

## Verification

Verified with Ray's rule parser
(`ci/pipeline/determine_tests_to_run.py`), the same first-match-wins
engine rayci uses:

- `check_rules()` parses clean, and all 126 cases in
`test.rules.test.txt` replay green. That file is enforced by the
`test-rules` CI step, and rayci asserts exact set equality, so a passing
case proves the path emits exactly those tags and nothing else.
- A sweep of all 10,333 tracked files against master shows **exactly two
deltas** — `doc/redirects/current.yaml` gaining `doc_redirects`, and
`.buildkite/doc.rayci.yml` gaining it alongside its existing `doc
doc_api` — and **zero tag losses** on any path. Every pre-existing
assertion in `test.rules.test.txt` is preserved except the
`doc.rayci.yml` one this PR deliberately revises.
- Ran the step's commands locally in a clean venv with
`anyscale-rtd-redirects==0.2.0` against the current
`doc/redirects/current.yaml`: `validate` reports 0 errors (49 chain
warnings, informational), and `diff-file --base FETCH_HEAD` reports the
redirect-level diff and exits 0 with no Read the Docs credentials.
- Exercised the drift guard both ways: it passes with only
`current.yaml` present and exits non-zero when a second
`doc/redirects/*.yaml` appears.

Because `.buildkite/doc.rayci.yml` now emits `doc_redirects`, **this PR
selects the new step and runs it**. Replaying this PR's own changed
files through the rule engine gives a tag union of `doc`, `doc_api`,
`doc_redirects`, and `tools`, so the step's commands are exercised in CI
here rather than only on some later PR that happens to edit redirect
YAML. It runs against an unchanged `current.yaml`, so `diff-file`
reports an empty redirect diff and exits 0, which is exactly the smoke
test that catches a typo in the step definition.

## Update: rebased onto the doc-tag reorg

Rebased after ray-project#64775 and ray-project#64812 landed, which reorganized the doc tags:
doc example tests moved to per-library `<lib>_doc` tags, and `doc` was
split so the autodoc machinery emits `doc doc_api` while the
rendering-only surface emits `doc`. This branch's four commits (one an
upstream merge) are collapsed into one. Two conflicts in
`test.rules.txt` (the tag declaration line, and the rule insertion
point) and one in `test.rules.test.txt` (three expectations the reorg
had since updated) were resolved in favor of master, then the
`doc_redirects` rule and cases re-applied on top.

The rebase also invalidated this PR's original rationale, so the rule
and step comments have been rewritten. The earlier framing was that
`doc_redirects` keeps redirect YAML from pulling in docbuild, the API
checks, and the per-team doc tests. That's no longer accurate on any of
the three: the per-team tests are selected by `<lib>_doc`, the two API
checks carry `doc_api` plus the library tags and no longer carry bare
`doc`, and the only remaining step carrying bare `doc` is `doc: build`,
which is `skip-on-premerge`. Since redirect YAML emits nothing at all on
master, this rule was never preventing over-triggering. It's additive,
and the comments now say so.

## Update: the step now selects itself

Cursor Bugbot caught that the redirect step wasn't reachable from an
edit to its own definition: `.buildkite/doc.rayci.yml` emitted `doc
doc_api` but never `doc_redirects`, so changing the redirect step's
commands wouldn't have run the redirect step. That contradicted the
rule's own stated reason for emitting `doc_api`, and this PR
demonstrated the gap: its previous revision noted that the new step
didn't execute here.

Fixed by giving `.buildkite/doc.rayci.yml` its own rule emitting `doc
doc_api doc_redirects`. It's a separate rule rather than an extra tag on
the autodoc-machinery block, because that block also covers `conf.py`,
`api_autogen.py`, and `doc/source/_ext/`, and a `conf.py` edit has no
business running the redirect check. The first attempt at this appended
the tag to the shared block and the full-repo sweep caught it
immediately: seven machinery files picked up `doc_redirects`.

AI assistance (Claude Code) was used to draft the CI step, the rebase
conflict resolution, and this description. Every changed line was
reviewed by hand, and the verification above was run as described. This
isn't duplicating existing work: no other open PR adds redirect
validation to premerge, and the `doc_redirects` tag doesn't exist on
master.

## Update: uv, and a recursive fail-closed guard

Two review follow-ups.

**Install with `uv`** (Elliot's suggestion).
`ci/docker/forge.Dockerfile` already installs uv to `/usr/local/bin` and
uses it for the image's Python, so the step needs no extra setup. It's
`uv tool install` rather than `uv pip install --system` for a PATH
reason: the previous revision's premerge log shows `pip install` fell
back to a user install, so the `rtd-redirects` entry point resolved from
`~/.local/bin`. `uv tool install` writes executables to that same
directory, so PATH resolution is unchanged. `uv pip install --system`
would target the uv-managed interpreter and put the entry point in that
env's `bin`, which isn't on PATH.

**The fail-closed guard now recurses.** Cursor Bugbot caught that the
guard's single-level shell glob didn't cover a nested redirect file, and
it was right. The rule engine matches with `fnmatch`, whose `*` crosses
`/`, so `doc/redirects/nested/foo.yaml` emits `doc_redirects` and
selects this step, while `ls doc/redirects/*.yaml` never saw it and the
guard passed. Replacing the glob with `find` closes the gap. Exercised
three ways locally: passes with only `current.yaml`, exits non-zero for
a nested file and for a sibling file.

A `.yml` file stays out of scope. The tag rule matches `*.yaml` only, so
`doc/redirects/current.yml` emits no tags and never selects the step,
putting it beyond the guard's reach. That matches the pre-PR baseline
for every redirect file rather than regressing anything, and
`rtd-redirects` uses `.yaml`.

Re-verified after the change: rules parse clean and all 126 cases in
`test.rules.test.txt` replay green (the rule files are untouched by this
revision).

## Related issue number

N/A

## Checks

- [x] I've signed off every commit (`-s`), because all commits are
squashed into one when merged.
- [x] I've run `scripts/format.sh` to lint the changes in this PR. (Via
`pre-commit`; the applicable hooks pass.)
- [x] I've made sure the tests are passing.
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…tial) (ray-project#65866)

## What this does

Adds the merge-time sync step that reconciles
`doc/redirects/current.yaml` into
the live `anyscale-ray` Read the Docs project. This is the automation
that
replaces the manual `rtd-redirects apply` a maintainer runs by hand
today (see
`doc/redirects/README.md`). It completes the redirect-as-code pipeline
whose
credential-free PR-time validation gate already landed in ray-project#64413.

**It lands disabled.** The dedicated bot credential it needs isn't
provisioned
yet, so the step carries the `disabled` tag and rayci skips it in both
premerge
and postmerge. This PR is deliberately staged, not ready to
merge-and-run — it's
here so the credential wiring can be reviewed and the dependency
tracked. Same
pattern the `doc: linkcheck` step used to land ahead of its Slack
webhook secret.

## How it's wired

- **Postmerge-only.** The `skip-on-premerge` tag keeps it off every PR
build, so
no PR event — fork or not — ever runs the token-bearing step. It runs
only on
  push to master.
- **Self-gated on the diff.** rayci evaluates file-based tag rules on
premerge
only; master builds are run-all. The step therefore exits early unless
the
merge actually touched `doc/redirects/`, so the token and the RtD API
are used
  only when a redirect changed.
- **Least-privilege secret.** The token is read inline from a dedicated
Secrets
Manager ARN read by no other step — not the shared
`ray-air-test-secrets`
bucket. Blast radius stays bounded to redirects on the one RtD project.

## What I need to enable it

A dedicated bot principal with admin on the `anyscale-ray` RtD project,
its API
token stored in a dedicated Secrets Manager ARN. Once that exists,
enabling is a
one-PR flip: remove the `disabled` tag, replace the
`RTD_TOKEN_SECRET_ARN`
placeholder with the real ARN, and update the "application is manual for
now"
line in `doc/redirects/README.md`.

## One caveat for review

The pinned tool version (0.2.0) has no `--no-delete` or `--accept-drift`
guard,
so the first automated `apply` reconciles hard: a live redirect absent
from
`current.yaml` is deleted. That's the intended one-write-path behavior,
but it's
why the manual-apply phase should finish before this is turned on.

## Test plan

- [x] YAML parses; new step present with tags `oss`, `skip-on-premerge`,
`disabled`.
- [x] Tag-rules dry-run confirms the edit emits only the doc pipeline
      (`doc, doc_api, doc_redirects, lint`), no code fan-out.
- [x] `disabled` tag verified to skip in both premerge and postmerge
rayci configs.
- [ ] Enablement (separate PR, after credential): real
premerge/postmerge run.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devprod docs An issue or change related to documentation go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants