Skip to content

[doc] Add in-repo llms.txt generator, replacing sphinx-llms-txt - #64458

Merged
dstrodtman merged 21 commits into
masterfrom
doc-1130-llms-txt-extension
Aug 11, 2026
Merged

dstrodtman merged 21 commits into
masterfrom
doc-1130-llms-txt-extension

Conversation

@ronny-anyscale

@ronny-anyscale ronny-anyscale commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the third-party sphinx-llms-txt with a small in-repo Sphinx extension (doc/source/_ext/llms_txt.py, alongside callouts.py / queryparamrefs.py) that generates navigation-structured agent manifests instead of one flat list.

Three tiers, emitted into the HTML build output:

  • /llms.txt — index: H1 + summary, one ## Section per top-level toctree entry of the root doc. Each section lists its landing page and every in-scope page in the subtree beneath it as - [title](url): description, deduped so a page appears only under the first section that reaches it, so an agent can locate any page from the index without drilling into the corpus. A page the nav toctrees never reach (an example linked only from a gallery grid, say) folds into the section owning its top-level directory; only pages whose directory maps to no section land in a trailing ## Other pages. Sections in llms_txt_optional_sections move to a trailing ## Optional block.
  • /<section>/llms-full.txt — verbatim page source per section, behind a ## Contents TOC (which also surfaces deep pages absent from the index). A section whose source exceeds llms_txt_full_max_shard_tokens (default 200K, ~4 chars/token) is split recursively into per-subdirectory sub-shards, so each loadable unit fits an agent's context budget.
  • /llms-full.txt — a manifest linking every shard (sub-shards nested under their parent), each with a description and page count, so an agent routes without downloading.

Descriptions resolve from front-matter/docinfo description → an html_meta / .. meta:: node → a first-paragraph fallback.

Why not a single llms-full.txt

Ray's full corpus is ~1.14M tokens — too large to load whole on most models, and truncating it (what sphinx-llms-txt's size knobs do) just yields an arbitrary lossy prefix. Peer projects all ship a single flat file and none cap; sharding by section keeps every unit independently loadable.

Note for existing llms-full.txt consumers

This changes what /llms-full.txt serves at a stable URL. Today it's ~5.9 MB of concatenated page text; after this it's a small manifest linking the per-section shards. Anything pointed at that URL expecting full text should follow the manifest to the shard it needs instead.

Changes

  • New doc/source/_ext/llms_txt.py + hermetic test doc/source/_ext/test_llms_txt.py.
  • conf.py: swap sphinx_llms_txt → llms_txt; add llms_txt_title, llms_txt_optional_sections, llms_txt_full_max_shard_tokens (keeps the existing llms_txt_summary / llms_txt_exclude).
  • Remove sphinx-llms-txt==0.7.1 from requirements-doc.txt and the docs lock (python/deplocks/docs/docbuild_depset_py3.11.lock; clean leaf removal — raydepsets --check consistent).
  • New premerge step doc: test llms.txt extension in .buildkite/doc.rayci.yml (runs in the docbuild-py3.11 env, since the test needs sphinx + myst).

Forward-compatibility

Written for the in-flight Sphinx 8→9 upgrade: findall (not traverse), root_doc (not master_doc), defensive getattr env access, docutils.nodes.meta, and all work in build-finished (parallel-safe).

Testing

  • doc/source/_ext/test_llms_txt.py — hermetic in-process Sphinx build covering all three description sources, exclusion, the ## Optional section, sub-shard splitting, and the nested manifest. Passes on the pinned stack (Sphinx 8.2.3 / MyST 5.1.0 / docutils 0.21.2).
  • The full -W docs build validates end-to-end in CI here.

Relationship to #64330

Independent of #64330 (which adds the per-page <meta name="description"> descriptions) — zero file overlap, mergeable in either order. Where a page has no curated description yet, the generator uses its first paragraph, so output is sensible regardless.

🤖 Generated with Claude Code

…1130)

Add `doc/source/_ext/llms_txt.py`, a Sphinx extension that emits
navigation-structured agent manifests into the docs build output, and remove
the third-party `sphinx-llms-txt` dependency it replaces.

It produces three tiers:
- `llms.txt` — an index with one `## Section` per top-level toctree entry, each
  listing the landing page and its direct children as
  `- [title](url): description` (descriptions from front-matter/`html_meta`, an
  `.. meta::` directive, or a first-paragraph fallback). Sections named in
  `llms_txt_optional_sections` move to a trailing `## Optional` block.
- `<section>/llms-full.txt` — verbatim page source per section behind a
  `## Contents` TOC. A section over `llms_txt_full_max_shard_tokens`
  (default 200K) is split recursively into per-subdirectory sub-shards so each
  loadable unit stays within an agent's context budget.
- `llms-full.txt` — a manifest linking every shard (sub-shards nested), each
  with a description and page count.

Work runs in `build-finished` (parallel-safe) and sticks to APIs that survive
the Sphinx 8->9 jump (`findall`, `root_doc`, `docutils.nodes.meta`).

Wires the extension into `conf.py`, removes `sphinx-llms-txt==0.7.1` from
`requirements-doc.txt` and the docs lock, and adds a `doc: test llms.txt
extension` premerge step running the hermetic `doc/test_llms_txt.py`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
@ronny-anyscale
ronny-anyscale requested a review from a team as a code owner June 30, 2026 21:30

@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 replaces the third-party sphinx-llms-txt dependency with a custom in-repo Sphinx extension (llms_txt.py) to generate structured llms.txt and sharded llms-full.txt files for AI agents, complete with a new test suite and Buildkite CI integration. The review feedback suggests improving the extension's robustness by handling non-string metadata in _clean to prevent build crashes, using fnmatch.fnmatchcase to ensure consistent cross-platform path exclusions, and emitting a warning if html_baseurl is unconfigured to prevent relative links that violate the llms.txt specification.

Comment thread doc/source/_ext/llms_txt.py Resolved
Comment thread doc/source/_ext/llms_txt.py Resolved
Comment thread doc/source/_ext/llms_txt.py Resolved
ronny-anyscale and others added 2 commits June 30, 2026 15:47
Drop Jupyter notebooks from llms.txt / llms-full.txt in the extension itself,
by testing the page's source suffix (`.ipynb`) at build time, instead of
enumerating `*.ipynb` docnames into `llms_txt_exclude` at conf-load time.

The conf-load enumeration could only see checked-in notebooks; notebooks
fetched into the build by sphinx-collections (which run after conf.py loads)
were never enumerated and slipped through as raw notebook JSON in the corpus —
and the new per-section sharding would surface them as a `_collections`
shard. Checking `env.doc2path(docname)` at `build-finished` catches both
checked-in and fetched notebooks, and removes the conf.py enumeration hack.

Adds a unit test for the suffix check; verified end-to-end that a notebook
present in a build is dropped from both the index and the full-text shards.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
Add an `llms_txt_build` switch (default True); when False, the extension skips
all generation in `build-finished`. conf.py sets it from RtD's
`READTHEDOCS_VERSION_TYPE`, so the agent manifests are built on published
versions (master, release tags) and local builds but skipped on PR previews —
the same `external` signal `.readthedocs.yaml` already keys its incremental-vs-
full build off of.

The corpus is consumed from docs.ray.io, not by PR reviewers, so generating it
on previews is wasted work — more so now that the per-section sharding reads
every in-scope source file.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Jul 1, 2026
From the automated PR review on #64458:

- `_clean`: coerce non-string front-matter `description` values (a YAML scalar
  can parse to a number/bool, or a list) instead of raising AttributeError and
  crashing the build.
- `_is_excluded`: use `fnmatch.fnmatchcase` for deterministic, case-sensitive
  docname matching on every platform (`fnmatch` case-normalizes per-OS, but
  Sphinx docnames are case-sensitive).
- Warn when `html_baseurl` is unset, since links would then be relative while
  the llms.txt spec expects absolute URLs.

Adds a unit test for the `_clean` coercion.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
@ronny-anyscale
ronny-anyscale requested a review from a team as a code owner July 6, 2026 14:37
Temporarily set `llms_txt_build = True` unconditionally so llms.txt and the
llms-full.txt shards render on this PR's Read the Docs preview for review.

REVERT before merge to the DOC-1048 gate:
    llms_txt_build = os.getenv("READTHEDOCS_VERSION_TYPE") != "external"

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
Comment thread .buildkite/doc.rayci.yml
- python doc/test_llms_txt.py
depends_on: docbuild
job_env: docbuild-py3.11
tags:

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.

Let's sync on when this test should be running and what could potentially break it.

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.

To put concrete detail on the "when should this run" question: this step keys on doc, but #64775 narrows doc to mean doc-build/validation infra (the -W build, Vale, requirements) rather than "something under doc/ changed." That reshuffle changes when this test runs, in both directions:

  • Stops firing on its own inputs. After [ci] Reserve the doc tag for doc validation; route doc example tests per library #64775, doc/source/_ext/llms_txt.py, doc/source/conf.py, and doc/test_llms_txt.py fall through to the catch-all doc/*.py -> core_doc rule, so they no longer emit doc. A change to the extension this test covers wouldn't run the test.
  • Over-fires today. On master, doc is emitted by every executable doc asset (doc/**/*.py, **/*.ipynb) across all libraries, so this unit test runs on unrelated example-code edits.

The end state I'm after: a doc-tagged step runs when the build machinery changes, not when content changes — and this test fits that cleanly since it validates a build extension. The missing piece is routing: the extension source and conf aren't mapped to doc after the reorg. I'll add doc/source/conf.py and doc/source/_ext/ to the doc infra rule in #64775 (they should trigger the full build anyway), which makes this step fire exactly on _ext/conf/test changes and nothing else. With that in place, tags: [oss, doc] here is right as-is — just merge-order coordination so we don't both rewrite that rule block.

ronny-anyscale and others added 3 commits July 6, 2026 09:16
Read the llms.txt blockquote summary from doc/source/llms_txt_summary.txt
instead of hardcoding the paragraph in conf.py, so it can be edited as plain
prose without touching Python. `.txt` isn't a Sphinx source suffix, so the file
isn't built as a page; conf.py collapses its whitespace to a single line.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
Build the generated links from a per-build base URL (new `llms_txt_base_url`
config) instead of the SEO-pinned `html_baseurl` (/en/latest/). conf.py sets it
from RtD's `READTHEDOCS_CANONICAL_URL`, which carries the correct host and
current version slug (including PR-preview hosts); falls back to `html_baseurl`
for local builds.

Previously every generated link — index page links, manifest shard links, and
per-shard `Source:` lines — pointed at docs.ray.io/en/latest/ on every build,
so master/release copies cross-linked to latest and PR previews linked to prod
instead of themselves (the preview manifest's shard links 404'd). Now each
version's output is self-consistent; the canonical latest/root file is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
@ronny-anyscale ronny-anyscale added the go add ONLY when ready to merge, run all tests label Jul 13, 2026
ronny-anyscale and others added 4 commits July 14, 2026 11:43
Make the index self-sufficient. Each section now lists its entire in-scope
toctree subtree (deduped), not just its direct children, so an agent can find
any page from the index itself without drilling into the corpus. Add a pointer
to llms-full.txt under the summary, and sweep any in-scope page not reachable
via the nav toctrees into a trailing "## Other pages" section so the index stays
complete.

On the real docs this takes the index from ~119 to ~500 entries (~32K tokens),
which still fits any modern context window.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
Add `ray-core/compiled-graph/doc/*` to `llms_txt_exclude`. These are 48
per-method autodoc stub pages — the same low-signal boilerplate the other
`*/api/doc/*` excludes target — that were slipping into the corpus (surfaced by
comparing the RtD build against docs.ray.io/llms.txt). Only the `/doc/` stubs
are dropped; the compiled-graph narrative pages stay.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
…tions

Two changes that together empty the "## Other pages" catch-all (74 -> ~0 on
the real doc set), so every listed page sits under its library.

Aggressively drop noise from the agent corpus (DOC-908): deprecated pages
(Train V1 API, deprecated Train user guides), include-only fragments
(train/common/*, ray-contribute/involvement), helper/utility code files and
raw literalinclude scripts rendered as pages (slurm-*, *_utils), and thin
example stubs (tune/examples/includes/*, a heading + a code block). Surfacing
a superseded API to an agent is worse than omitting it.

Fold pages the nav toctrees never reach into the section that owns their
top-level directory. Ray drives its example galleries with grid cards and
query-param links (from examples.yml), not toctree, so Serve tutorials and
Train/Tune examples are in-scope yet unreached; directory folding lists them
under their library. _collections/<lib>/... build-fetched pages key on <lib>.
Only pages whose directory maps to no section remain in "## Other pages".

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>

@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

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b389035. Configure here.

Comment thread doc/source/_ext/llms_txt.py Resolved
ronny-anyscale and others added 2 commits July 16, 2026 14:58
Reverts the temporary `llms_txt_build = True` that forced generation on this
PR's RtD preview for review. Back to the gated line: generate on published
(master, release tags) and local builds; skip RtD external/PR previews, where
the agent corpus isn't review-critical and the full-source read is wasted
work on an incremental build.

Verified on the #64458 RtD preview before flipping: the folded index shows
"Other pages" gone (was 74) and _collections/<lib> examples correctly under
their library sections.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
…xt shard

Bugbot flagged an index/full-text mismatch: the index folds
`_collections/<lib>/…` build-fetched example pages into their library's nav
section (via `_match_dir`), but the `llms-full.txt` shards grouped by
`_top_dir`, so those pages landed in a separate `_collections/…` shard. An
agent following the index into a section's `llms-full.txt` wouldn't get the
fetched examples' verbatim text.

Add `_shard_relpath()` (strips the `_collections/` prefix) and use it for both
the full-text group key (now `_match_dir`) and the shard-tree subdirectory
split, so a Serve tutorial at `_collections/serve/tutorials/…` nests into the
Serve shard tree. The real docname still reads source and builds URLs — only
grouping/placement uses the logical path. No `_collections` shard is emitted.

Strict no-op for non-collection pages (`_shard_relpath(d) == d`). Test gains
assertions that the fetched page lands in the library shard and no stray
`_collections` shard or manifest entry is written.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
dstrodtman added a commit to dstrodtman/ray that referenced this pull request Jul 29, 2026
ray-project#64458 adds doc/test_llms_txt.py and doc/source/llms_txt_summary.txt but no
test.rules.txt change, so on merge the test would land on the doc/*.py
catch-all and emit core_doc. That runs Ray Core's doctests and example
execution for a test whose own docstring describes it as hermetic: it builds a
tiny Sphinx project in a temp dir, in-process, with no network and no Ray
import, and needs only sphinx and myst-parser. It also would not run the
:book: doc: test llms.txt extension step that actually executes it, since that
step is tagged doc.

The summary file is worse off: as a bare .txt under doc/source/ it matches no
rule and falls through to the trailing doc/ skip, so editing the text the
generator injects into llms.txt would verify nothing at all.

Routes both to doc. Rules for absent paths are inert, so this is safe to land
first and means ray-project#64458 merges correctly scoped with no follow-up and no
ordering dependency in either direction.

Note for anyone tracing the doc tag's premerge behavior: ray-project#64458's new step
carries no skip-on-premerge, unlike doc: build. Once it lands, doc is a live
premerge selector again rather than a post-merge-only one.

Replayed all 92 test.rules.test.txt cases through
ci/pipeline/determine_tests_to_run.py: check_rules() passes, 92/92 match, and
the full doc/ sweep invariants still hold.

AI assistance was used for this change.

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman

Copy link
Copy Markdown
Contributor

Heads-up: CI routing for the two new files, handled in #64775

Flagging a cross-PR interaction and the design call I made about it, so it's visible rather than a surprise.

This PR adds doc/test_llms_txt.py and doc/source/llms_txt_summary.txt but no .buildkite/test.rules.txt change, so as it stands neither file is routed anywhere sensible:

File Routes to today Consequence
doc/test_llms_txt.py core_doc (via the doc/*.py catch-all) Runs Ray Core's doctests and //doc/... example execution, and does not run :book: doc: test llms.txt extension, which is the step that actually executes it
doc/source/llms_txt_summary.txt nothing — a bare .txt under doc/source/ matches no rule and hits the trailing doc/ skip Editing the text the generator injects into llms.txt verifies nothing at all

The first one is the odd fit. Your test's own docstring is unambiguous that it's hermetic ("builds a tiny Sphinx project in a temp dir (in-process, no network, no Ray import)... needs sphinx + myst-parser but not the full Ray docs toolchain"), so pulling in Ray Core library execution is backwards, and it misses the one step that runs it.

What I did

Rather than ask you to carry a rules change, I pre-routed both files to doc in #64775 (commit 99c3af2), which is the PR reserving the doc tag for doc validation and moving the per-library example tests onto dedicated <lib>_doc tags. Rules for paths that don't exist yet are inert, so:

One design note worth your input

Your step is tagged [oss, doc] with no skip-on-premerge, unlike doc: build. That's the right call and I'm not suggesting otherwise, but it's worth naming the effect: it makes doc a live premerge selector again. After #64775 and #64777, doc would otherwise have selected only the skip-on-premerge doc: build, i.e. nothing on premerge. Your cheap instance_type: small hermetic test is arguably what the tag should have meant all along, so this is a good outcome. It just means the reserved-doc-tag story now has a real premerge consumer, and anyone reasoning about premerge cost should know that.

Alternative, if you prefer

Relocating the test under doc/source/_ext/ would be covered automatically by the existing doc/source/_ext/ directory rule and would need no per-file line, which is tidier long-term. It wouldn't cover llms_txt_summary.txt, so that one needs a rule regardless. Happy either way; the pre-routing works as-is.

@ronny-anyscale

Copy link
Copy Markdown
Contributor Author

Thanks for pre-routing it — and for writing up the interaction rather than letting it surprise me later.

I took your alternative: doc/test_llms_txt.py → doc/source/_ext/test_llms_txt.py in f79a2e4. Your reasoning is right that it's the tidier long-term shape, and it lines up with where you're taking the doc tag — the test and the extension it covers now live in one directory, so one rule routes both and there's nothing per-file to keep in sync as the extension grows.

What that means for #64775

  • Drop the doc/test_llms_txt.py line from 99c3af2. The path no longer exists, so it's inert either way, but it's dead weight — the existing doc/source/_ext/ directory rule covers the test now.
  • Keep the doc/source/llms_txt_summary.txt line. You're right that it needs a rule regardless; a bare .txt under doc/source/ still hits the trailing doc/ skip, and that file is the text the generator injects verbatim into llms.txt, so editing it genuinely should run the build.
  • Merge-order coordination is moot now. This PR touches no rules at all, so there's no rule block for us to both rewrite in either direction.

Your end state is the one I want too: doc fires on build machinery, not content. Adding doc/source/conf.py and doc/source/_ext/ to the infra rule is the piece that makes this step fire on its own inputs, and with _ext/ in there the test file comes along for free.

Also updated the Buildkite command to the new path. The step is otherwise unchanged — still instance_type: small, still [oss, doc] with no skip-on-premerge, so the live-premerge-selector effect you named holds as described.

One caveat worth naming in return

doc/source/ is in the global exclude in .pre-commit-config.yaml, so moving the test under it drops it out of lint coverage — no ruff, trailing-whitespace, or end-of-file-fixer. It had those at doc/.

That's the same gap llms_txt.py and its neighbours (callouts.py, queryparamrefs.py, api_sidebar.py) already sit in, so the move makes the extension consistent rather than newly anomalous — but it is a real loss and I'd rather it be on the record than discovered later. The fix would be narrowing the exclude to doc/source/(?!_ext/), which would also start linting those four existing files for the first time and could surface pre-existing failures. That's out of scope here; happy to carry it as a follow-up if you think it's worth having, or to leave _ext/ unlinted deliberately.

For what it's worth the moved test is ruff check / ruff format --check clean today, and passes from its new home locally on Sphinx 7.3.7 / MyST 2.0.0 — older than the pinned stack, but it's hermetic so version skew doesn't reach it. CI here runs it on the pinned 8.2.3 / 5.1.0 in docbuild-py3.11.

Relocate doc/test_llms_txt.py to doc/source/_ext/test_llms_txt.py so it sits
beside the extension it covers and is routed by a directory rule rather than a
per-file line in .buildkite/test.rules.txt. The rules file matches with fnmatch,
whose `*` crosses `/`, so `doc/*.py` already routes everything under doc/ to the
`doc` tag today; the move keeps that correct while making the test fall under
the `doc/source/_ext/` rule once #64775 narrows `doc` to
doc-build infra and sends `doc/*.py` to the per-library `<lib>_doc` tags.

Adjust _EXT_DIR to the file's own directory and update the Buildkite command to
the new path. No Bazel target picks the file up: doc/BUILD.bazel's `source/**`
globs match .md/.rst only, and its .py globs name specific doc_code/ dirs.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
Build 71026 failed in six wanda image builds, all with the same Bazel loading
error: every SourceForge mirror for xz-5.2.7.tar.gz was unreachable, so
@@org_lzma_lzma// couldn't be fetched and @@boost//:iostreams failed analysis.
The download only happened because the build took a docker cache miss;
neighbouring builds in the same window passed on a warm cache.

The failure blocked docbuild-py3.11, which left 118 jobs in waiting_failed --
including "doc: test llms.txt extension", which never ran. Empty commit to get
a clean run; no source change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Ronny Roland <[email protected]>
Picks up #64906 ("[ci] fix org_lzma_lzma download failures by using SourceForge
redirector"), which is what premerge needed. The branch's merge base was
2026-07-14, 183 commits behind, so it still pinned four specific SourceForge
mirrors for xz-5.2.7.tar.gz. All four are offline, so every wanda image build
that took a docker cache miss failed in Bazel's loading phase with
`no such package '@@org_lzma_lzma//'`, taking @@boost//:iostreams with it.

That blocked docbuild-py3.11 and left 118 jobs in waiting_failed, including
"doc: test llms.txt extension". Builds 71026 and 71029 failed identically --
the retry hit the same cache key because an empty commit changes no build
inputs. Master now uses the SourceForge redirector plus tukaani.org.

Merge is conflict-free; doc/source/conf.py auto-merged. The extension test
still passes from its new doc/source/_ext/ location.

Signed-off-by: Ronny Roland <[email protected]>
dstrodtman added a commit that referenced this pull request Aug 5, 2026
…per library (#64775)

## Reviewer summary

**What this does.** The per-team `X: doc tests` steps are library
example and doctest suites that live under `doc/`. They exercise library
code, not documentation quality. Today every executable doc asset emits
the blanket `doc` tag and all six teams' steps are tagged `doc`, so a
one-library doc change starts every team's step. This gives each step a
dedicated `<lib>_doc` tag, routes `doc/source/<lib>/**` to the owning
library's tag, renames the steps to `X: docs example tests`, and leaves
`doc` for documentation validation (the build and the Vale/config
infra). The library tag stays on each step, so a library **code** change
runs its doc example tests exactly as before.

**What's verified.**

| Claim | Evidence |
|---|---|
| Each path emits exactly the intended tag, and no other | `test-rules`
green on this PR. That's the pinned `rayci` binary replaying all 103
`test.rules.test.txt` assertions (up from 57 on master) with **exact set
equality**, so each case also proves the blanket `doc` tag does *not*
come along. |
| The emitted tags resolve to the intended steps, and only those |
Generated the real pipeline locally with the pinned `rayci v0.46.0`
release binary for a one-file Serve doc-example change, before and after
this branch. Output below. |
| The renamed steps still run and pass | All five plus the GPU and dask
siblings green on this PR, selected via the library tags this change
preserves. |
| Every executable target under `doc/` routes to a step that can
actually select it | Swept all 948 (file, target) claims against the
per-team `team:` / `--only-tags` / `--except-tags` filters. One
deliberate exception (`doc/test_myst_doc.py`, below) and two
pre-existing gaps that this change doesn't create. |
| The rename doesn't reset step identity | rayci derives step IDs
positionally (`fmt.Sprintf("g%d_s%d", i, j)`, `converter.go`), not from
the label. The generated pipelines confirm it: `g16_s12`, `g16_s21`,
`g6_s22`, `g13_s26` are identical before and after. |

**What I need from a reviewer.**

1. **One question I can't answer from inside the repo.**
`ci/build/get_build_info.py` sets `config.env` to `"Buildkite " +
BUILDKITE_LABEL`, and `ci/build/upload_build_info.sh` uploads it on
postmerge pipelines on `master` only. Does anything downstream of that
`metadata.json` treat `config.env` as an identity or grouping key? If
it's descriptive, renaming five steps is free. If something groups on
it, those five steps' postmerge history splits at the merge commit.
Flaky-test selection and target selection both key on `team` (unchanged
here) and test identity is the bazel target name (`f"{system}:{name}"`
in `release/ray_release/test.py`), so I believe `config.env` is the only
place the label escapes.
1. **Confirm the API-check behavior change below is acceptable.**
1. **Confirm the catch-all owner.** Executable doc assets in directories
with no per-team step route to the core step: roughly 25 files, being 18
`doc/source/templates/*/start.ipynb` plus a handful under
`doc/source/cluster/doc_code/`, `doc/source/ray-contribute/doc_code/`,
and `doc/source/_templates/`. The templates majority may be retired or
externally managed, in which case a skip rule is the better answer than
core ownership.

**Known behavior change worth your eyes.** Because
`doc/source/<lib>/doc_code/` and `examples/` now emit `<lib>_doc`
instead of `doc`, the two API-surface checks (`doc: check API
annotations`, `doc: check API doc consistency`) stop running on library
doc-example changes. They carry the blanket `doc` tag among their
library tags, so today a `doc_code` edit incidentally triggers a
premerge `make -C doc/ html`. I think that's correct: those checks guard
the documented public API surface, which a doc example can't change, and
the example itself is still executed by the owning library's step while
the render is gated by Read the Docs. But it is a premerge signal that
disappears, so it should be a decision rather than a side effect. Raised
on #64812, which routes the API **reference** pages to a dedicated
`doc_api` tag for the related case.

**Out of scope, tracked separately.** `.buildkite/others.rayci.yml:13`
declares a sixth step labeled `doc tests`, running `//python/ray/...
//doc/... none --only-tags doctest` and tagged `python`, a tag no rule
in `test.rules.txt` emits. Generating the full-fan-out pipeline shows it
does get emitted (`doc tests [g14_s1]`), so it is live. After this
rename it becomes the only step in the repo still called "doc tests."
This PR doesn't touch `others.rayci.yml` and the fix is independent.

---

## What this changes

1. **Dedicated per-library tag.** Each step gets a `<lib>_doc` tag
(`core_doc`, `data_doc`, `ml_doc`, `rllib_doc`, `serve_doc`) and drops
the blanket `doc` tag. The library tag stays.
1. **Path routing.** `test.rules.txt` routes `doc/source/<lib>/**` to
that library's tag, so a doc change runs only the owning library's
example tests. LLM doc assets already route to `llm` and keep doing so.
1. **`doc` reserved for validation.** It now stays only on the
documentation build and the Vale/config infra.
1. **Rename** to `X: docs example tests`, since a failure in these steps
means library code or an example broke, not that the docs are wrong.
1. **Build-file rule fix.** `test.rules.txt` matched `doc/BUILD` and
`doc/*/BUILD`, but the files are `BUILD.bazel`, so editing a file that
*defines* the doc test targets ran no doc tests premerge. It now matches
the `.bazel` files and routes them to the same per-library steps. The
root `doc/BUILD.bazel` defines every library's targets, so it routes to
all of them.

### Scoping exceptions, and why each exists

Several paths sit under a library doc directory but can't be
meaningfully tested by that library's example step, so they're routed
explicitly rather than by directory:

- **Static images skip entirely.** Image extensions sit on the leading
skip rule, ahead of the per-library rules, so a `.png` or `.svg` edit
triggers nothing. 310 tracked image files. `.yaml` and `.sh` stay
routed, since unlike an image they can change what a test does.
- **Sphinx build machinery routes to `doc`.** `conf.py` imports
`custom_directives`, `api_autogen`, `api_mock_imports`, and
`template_collections`; none was listed in the validation-infra rule, so
all fell to the `doc/*.py` catch-all and emitted `core_doc`, running Ray
Core's doctests for a docs-build-machinery edit. Those four plus
`preprocess_github_markdown` and the doc-root build helpers now route to
`doc`. They're enumerated one per line on purpose: `*` is fnmatch here
and crosses `/`, so a `doc/source/*.py` pattern would also swallow every
example script under `doc/source/<lib>/doc_code/`. There's a comment on
the rule saying so.
- **Gallery configs route to `doc`.**
`doc/source/{data,serve,train}/examples.yml` are parsed by
`custom_directives.py` (`EXAMPLE_GALLERY_CONFIGS`) to generate the
gallery pages. They hold no executable code and can't change what any
example does. Narrowed to a three-path exception rather than a blanket
`.yml` skip, because a sibling `.yml` under a library doc directory can
be a config an example consumes.
- **`doc/.claude/` triggers nothing.** Agent files never participate in
the Sphinx build and define no test targets, but
`doc/.claude/skills/sphinx-fix/sphinx_fix.py` matched the `doc/*.py`
catch-all. The Read the Docs build guard already excludes this exact
path for the same reason, so the two guards now agree. Pre-existing
rather than a regression from this PR: on master the file emits the
blanket `doc` tag, which reaches all five per-team steps.
- **Four `team:ml` notebooks under `ray-core/` route to `ml_doc`.**
`plot_hyperparameter`, `batch_prediction`, `plot_parameter_server`, and
`plot_pong_example` live under `doc/source/ray-core/examples/` but their
targets are tagged `team:ml`, and the team argument to
`//ci/ray_ci:test_in_docker` filters targets by `team:<team>`
(`_get_all_test_query`, `ci/ray_ci/tester.py`). Routing them to
`core_doc` would run a step that tests everything under `ray-core/`
except the file that changed. Re-tagging the four `team:core` in
`doc/BUILD.bazel` is the alternative fix and would let the rule lines go
away.
- **`highly_parallel.ipynb` routes to `doc`.** Its `py_test` carries a
`highly_parallel` tag that the ml docs example step excludes, and the
notebook glob in `doc/source/ray-core/examples/BUILD.bazel` excludes it
too, as a release test needing a live multi-node cluster. The remaining
ml `//doc/...` steps select `gpu` / `train_v2_gpu` and the target has
neither, so no premerge step executes it. Routing to `doc` means the
build renders it (`nb_execution_mode` defaults to `off`, so
render-and-lint only), which is the only validation premerge offers
here.
- **`doc/external/` routes to `ml_doc`.** Its `test_external_hashes`
target is tagged `team:ml`; it had fallen through the `doc/*.py`
catch-all to `core_doc`, where the core step's `team:core` query never
sees it.
- **The `llms.txt` files route to `doc`.** #64458 adds
`doc/test_llms_txt.py` and `doc/source/llms_txt_summary.txt` with no
`test.rules.txt` change. Left alone the test would land on the
`doc/*.py` catch-all and emit `core_doc`, running Ray Core's doctests
for a test its own docstring describes as hermetic, while never running
the step that executes it. Rules for absent paths are inert, so there's
no ordering dependency: this PR doesn't touch `doc.rayci.yml`, #64458
doesn't touch `test.rules.txt`, and whichever lands first the other
merges correctly scoped.
- **Declined:** fanning `doc/test_myst_doc.py` out to all five
`<lib>_doc` tags. It backs 19 targets across every team, but it's shared
infrastructure, so a break surfaces in core as readily as anywhere. One
library's worth of execution is a sufficient smoke signal and the
post-merge build covers the rest. The rule carries a comment recording
that trade and when to revisit it.

### Effect on a doc-only PR (no `docs-go`)

| Change | Before | After |
|---|---|---|
| A Serve doc example | every team's `doc tests` step | `serve: docs
example tests` and its GPU sibling |
| A Data doc example | every team's `doc tests` step | `data: docs
example tests`, plus the dask and GPU siblings |
| An image under a library doc dir | that library's example step |
nothing |
| A Sphinx build module (`custom_directives.py` etc.) | `core: docs
example tests` | `doc: build` only (post-merge) |
| A gallery config (`examples.yml`) | that library's example step |
`doc: build` only (post-merge) |
| Editing `doc/BUILD.bazel` | nothing (rule was dead) | the doc example
steps it defines |
| The two `doc: check API*` checks | ran, via the blanket `doc` tag |
don't run (see reviewer summary) |

The GPU and dask siblings carry `<lib>_doc` too, and tag matching is a
non-empty intersection, so they're selected alongside the main step.
That's unchanged behavior: they carried the blanket `doc` tag before, so
a doc change already started them. No new GPU cost.

## Verification

**Rule conformance, under the authoritative evaluator.** `test-rules` is
green on this PR. It replays all 103 `test.rules.test.txt` assertions
through the pinned `rayci` binary, and `runTestRules` compares the full
computed tag set per path, so every case is also a negative assertion
that no other tag fires.

**Tag-to-step resolution, generated locally.** The tag set isn't the
step set: rayci filters steps by tag, then `markDeps` pulls in
everything reachable through `depends_on` regardless of that step's own
tags. To confirm the composition rather than infer it, I ran the pinned
`rayci v0.46.0` release binary against a one-file Serve doc-example
change, on master and on this branch:

```
before (base=master)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always doc lint
  doc-related steps emitted:
    core: doc tests [g6_s22]             ml: doc tests [g13_s26]
    data: doc tests [g7_s21]             rllib: doc tests [g15_s8]
    data: dask doc tests [g7_s22]        serve: doc tests [g16_s12]
    data: doc gpu tests [g7_s23]         serve: doc gpu tests [g16_s21]
    doc: check API annotations [g9_s3]   doc: check API doc consistency [g9_s4]

after (this branch)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always lint serve_doc
  doc-related steps emitted:
    serve: docs example tests [g16_s12]
    serve: docs example gpu tests [g16_s21]
```

Six teams' example steps collapse to the owning team's two, and the step
IDs are unchanged across the rename.

**Routing versus coverage.** Correct routing isn't sufficient: the step
that starts still has to select the target. `ci/ray_ci/tester.py`
filters by `attr(tags, 'team:<team>')`, then intersects `--only-tags`
and subtracts `--except-tags`, so a change can route perfectly, start
the right-looking step, and be invisible to every command in it. I swept
all 948 (file, target) claims under `doc/` against the per-team filters.
After the exceptions above, the only deliberate team mismatch left is
`doc/test_myst_doc.py`. Two pre-existing gaps fell out, neither created
by this change:

- **GPU-tagged ml and core doc examples have no owning step** — six
`team:ml` notebooks tagged `gpu`, five `team:core` `doc_code` modules
tagged `multi_gpu`, and one `post_wheel_build` module. `data` and
`serve` each have a GPU doc-example step; ml and core never got one, so
the only steps that would run these are gated on `train_gpu` and
`cgraphs_direct_transport`, which no doc path emits. No `doc`-tagged
step ran them before the split either. This needs a REEf and
library-team decision rather than a rules change.
- **Prose doctests aren't triggered by prose edits.** The
`doc/BUILD.bazel` `doctest` targets over `doc/source/**/*.{md,rst}` are
reachable only from the `others.rayci.yml` step gated on `python`, while
prose paths hit the leading skip rule. Roughly 700 files. I consider
this correct as-is: given current coverage the Read the Docs render
build is the gate a prose change needs.

**Also swept** all 1,628 tracked `doc/` files against the previous rules
to confirm exactly which paths changed routing and that nothing else
moved.

## Change log

Consolidated above; kept here so the review history stays legible.

- `6a1310d3b5` — the split: per-library tags, path routing, rename,
`BUILD.bazel` rule fix.
- `c6302c8a21`, `b1d03629cf` — first bot-review pass: static images
skip; Sphinx build modules route to `doc`.
- `99c3af2c28` — pre-route the `llms.txt` extension test and summary
ahead of #64458.
- `3795c6161b` — skip `doc/.claude/`; route the `team:ml` `ray-core`
notebooks to `ml_doc`.
- `e88e8a4b52` — remove a stray `TEMP(do-not-merge)` marker that reached
master with #65040. Inert, and independent of this PR's thesis; happy to
split it out.
- `f8347baf54` — second bot-review pass: gallery configs to `doc`;
correct `highly_parallel.ipynb` to `doc`.
- `6a050a0511` — route `doc/external/` to `ml_doc` so the hash guard
still runs.

## AI assistance

This change was drafted with AI assistance (Claude Code) and reviewed by
me.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman dstrodtman changed the title [doc] Add in-repo llms.txt generator, replacing sphinx-llms-txt (DOC-1130) [doc] Add in-repo llms.txt generator, replacing sphinx-llms-txt Aug 10, 2026
`_write_shard` reads each page's source with `read_text(encoding="utf-8")`
but only catches `OSError`. `UnicodeDecodeError` subclasses `ValueError`,
so a source the decoder rejects would escape the handler and propagate out
of the `build-finished` callback, failing the whole docs build with a
traceback instead of skipping the page with a warning.

Narrow in practice, since Sphinx reads sources itself with `source_encoding`
(`utf-8-sig` by default) and would fail earlier on a genuinely undecodable
file. It's still the wrong failure mode for a defensive handler that already
degrades gracefully on unreadable files.

Signed-off-by: Douglas Strodtman <[email protected]>
dstrodtman added a commit that referenced this pull request Aug 10, 2026
…65115)

## Summary

Completes the page-description work
[#64330](#64330) started, so that
**every page listed in `llms.txt` carries a curated description**.

#64330 (merged) described the 94 pages that made up the index when it
listed only each section's landing page plus its direct toctree
children. The generator in
[#64458](#64458) makes the index
complete — every in-scope page under its section — so the index now
carries ~630 entries, and the ~400 that #64330 didn't cover fall back to
a truncated first paragraph.

That fallback is often actively bad for an agent routing on it. Of the
397 undescribed pages:

| Fallback problem | Pages | Example |
|---|---:|---|
| No paragraph at all | 22 | `cluster/kubernetes/troubleshooting` |
| Pointer prose | 34 | `cluster/cli` → "This section contains commands
for managing Ray clusters." |
| Restates the title | 117 | every `ray-core/patterns/*` anti-pattern
page |
| Under 70 chars | 170 | `data/inspecting-data` → "Inspect Datasets to
better understand your data." |

## Changes

- **368 pages get a curated description**, following the convention
#64330 established: `myst: html_meta: description:` front matter for
`.md` (164 files), and a `.. meta::` directive for `.rst` (204 files).
The `.rst` block is placed after any leading docinfo field list
(`:orphan:` and friends) but **before** any `.. _label:` target, so the
label still resolves to the section title.
- **31 pages are excluded instead** (`conf.py`). These are thin
API-reference hub pages — a title plus an autosummary table, under 40
words of real prose — whose per-symbol targets are already excluded by
the existing `*/api/doc/*` patterns. Also `data/api/_autogen` (no title
at all) and two `*_regression_example` literalinclude stubs with zero
prose. A description on any of these could only restate its title.

Style follows the same house rule as #64330: 130–150 characters,
front-loading what distinguishes the page, no "Ray X is a…" restatement
of the link title. Mean length 122 chars, none over 160.

Substantial API-reference pages were **kept and described**, not
excluded — `tune/api/schedulers` (965 words of prose), `tune/api/env`,
`tune/api/trainable`, `serve/api/index`, `data/api/expressions` are
exactly what a coding agent wants.

**Result: 479 in-scope pages described, 31 excluded, 0 relying on
first-paragraph fallback.**

## Relationship to other PRs

Independent of **#64458** (the generator). Descriptions are page front
matter and work with the current third-party `sphinx-llms-txt` on master
as well as the in-repo generator. The one file both touch is
`doc/source/conf.py`: this PR appends a `llms_txt_exclude += [...]`
block below the existing list rather than editing the list literal,
which is what #64458 rewrites, so the two shouldn't collide. Either can
merge first.

Not a duplicate: `gh pr list --state open` finds no other PR adding page
descriptions or `html_meta` blocks. #64330, the only prior art, is
merged.

## Rebased on master

Merged master to clear a conflict. Two pages shifted:

- `cluster/kubernetes/user-guides/kuberay-history-server.md` no longer
appears in this diff. #65139 described that page independently while
this branch was open, and its description is the better one: this
branch's scoped the page to GKE and Google Cloud Storage, where master's
covers RayCluster, RayJob, and RayService, which is the page's actual
scope. Resolved in favor of master.
- `ray-observability/user-guides/jax-tpu-profiling.md` is newly
described. It landed on master after this branch was cut and was the one
in-scope page still falling back to a truncated first paragraph.

Net file count is 368 newly described pages plus `conf.py`, plus one
re-key:
`ray-core/scheduling/labels.md` carried a bare top-level `description:`
in its front matter, the only such file in the tree. Sphinx emits no
meta description from that key, so despite looking described the page
fed neither the HTML meta tag nor `llms.txt`. The text is unchanged;
only the key moves under `myst.html_meta`. That page was already counted
as described, so the totals above don't move.

## Testing

Local verification (no Ray build required — these are doc source edits):

```
$ python3 doc/test_no_new_rst.py                       # exit 0 (no new .rst files; all 204 are edits)
$ vale doc/source/data doc/source/ray-overview/examples
  174 alerts, 0 error-level, 0 on the added lines
  identical to the master baseline (174 alerts) — this change adds no Vale alerts
$ python3 -c "import ast; ast.parse(open('doc/source/conf.py').read())"   # conf.py parses
```

Plus scripted checks over all 370 changed files:

- All 164 `.md` front-matter blocks parse as YAML and expose
`myst.html_meta.description`.
- All 204 `.rst` files: `.. meta::` precedes any `.. _label:`, and any
docinfo field list still precedes the `.. meta::` block.
- Re-running the in-scope inventory: 510 pages, 479 described, 31
excluded, **0 gaps**.
- The 31 entries added to `llms_txt_exclude` match the computed exclude
set exactly.

The `-W` docs build is the real end-to-end gate and runs in CI here.

## AI assistance

Drafted with Claude Code: the descriptions were generated from each
page's title, headings, and lead prose, and applied by script. Per
`AGENTS.md`, this needs a human pass over the content before it's ready
for review — **opening as a draft for that reason**. The mechanical
placement is verified by the checks above; what needs human eyes is
whether each description is accurate and useful for its page.

---------

Signed-off-by: Ronny Roland <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
…per library (ray-project#64775)

## Reviewer summary

**What this does.** The per-team `X: doc tests` steps are library
example and doctest suites that live under `doc/`. They exercise library
code, not documentation quality. Today every executable doc asset emits
the blanket `doc` tag and all six teams' steps are tagged `doc`, so a
one-library doc change starts every team's step. This gives each step a
dedicated `<lib>_doc` tag, routes `doc/source/<lib>/**` to the owning
library's tag, renames the steps to `X: docs example tests`, and leaves
`doc` for documentation validation (the build and the Vale/config
infra). The library tag stays on each step, so a library **code** change
runs its doc example tests exactly as before.

**What's verified.**

| Claim | Evidence |
|---|---|
| Each path emits exactly the intended tag, and no other | `test-rules`
green on this PR. That's the pinned `rayci` binary replaying all 103
`test.rules.test.txt` assertions (up from 57 on master) with **exact set
equality**, so each case also proves the blanket `doc` tag does *not*
come along. |
| The emitted tags resolve to the intended steps, and only those |
Generated the real pipeline locally with the pinned `rayci v0.46.0`
release binary for a one-file Serve doc-example change, before and after
this branch. Output below. |
| The renamed steps still run and pass | All five plus the GPU and dask
siblings green on this PR, selected via the library tags this change
preserves. |
| Every executable target under `doc/` routes to a step that can
actually select it | Swept all 948 (file, target) claims against the
per-team `team:` / `--only-tags` / `--except-tags` filters. One
deliberate exception (`doc/test_myst_doc.py`, below) and two
pre-existing gaps that this change doesn't create. |
| The rename doesn't reset step identity | rayci derives step IDs
positionally (`fmt.Sprintf("g%d_s%d", i, j)`, `converter.go`), not from
the label. The generated pipelines confirm it: `g16_s12`, `g16_s21`,
`g6_s22`, `g13_s26` are identical before and after. |

**What I need from a reviewer.**

1. **One question I can't answer from inside the repo.**
`ci/build/get_build_info.py` sets `config.env` to `"Buildkite " +
BUILDKITE_LABEL`, and `ci/build/upload_build_info.sh` uploads it on
postmerge pipelines on `master` only. Does anything downstream of that
`metadata.json` treat `config.env` as an identity or grouping key? If
it's descriptive, renaming five steps is free. If something groups on
it, those five steps' postmerge history splits at the merge commit.
Flaky-test selection and target selection both key on `team` (unchanged
here) and test identity is the bazel target name (`f"{system}:{name}"`
in `release/ray_release/test.py`), so I believe `config.env` is the only
place the label escapes.
1. **Confirm the API-check behavior change below is acceptable.**
1. **Confirm the catch-all owner.** Executable doc assets in directories
with no per-team step route to the core step: roughly 25 files, being 18
`doc/source/templates/*/start.ipynb` plus a handful under
`doc/source/cluster/doc_code/`, `doc/source/ray-contribute/doc_code/`,
and `doc/source/_templates/`. The templates majority may be retired or
externally managed, in which case a skip rule is the better answer than
core ownership.

**Known behavior change worth your eyes.** Because
`doc/source/<lib>/doc_code/` and `examples/` now emit `<lib>_doc`
instead of `doc`, the two API-surface checks (`doc: check API
annotations`, `doc: check API doc consistency`) stop running on library
doc-example changes. They carry the blanket `doc` tag among their
library tags, so today a `doc_code` edit incidentally triggers a
premerge `make -C doc/ html`. I think that's correct: those checks guard
the documented public API surface, which a doc example can't change, and
the example itself is still executed by the owning library's step while
the render is gated by Read the Docs. But it is a premerge signal that
disappears, so it should be a decision rather than a side effect. Raised
on ray-project#64812, which routes the API **reference** pages to a dedicated
`doc_api` tag for the related case.

**Out of scope, tracked separately.** `.buildkite/others.rayci.yml:13`
declares a sixth step labeled `doc tests`, running `//python/ray/...
//doc/... none --only-tags doctest` and tagged `python`, a tag no rule
in `test.rules.txt` emits. Generating the full-fan-out pipeline shows it
does get emitted (`doc tests [g14_s1]`), so it is live. After this
rename it becomes the only step in the repo still called "doc tests."
This PR doesn't touch `others.rayci.yml` and the fix is independent.

---

## What this changes

1. **Dedicated per-library tag.** Each step gets a `<lib>_doc` tag
(`core_doc`, `data_doc`, `ml_doc`, `rllib_doc`, `serve_doc`) and drops
the blanket `doc` tag. The library tag stays.
1. **Path routing.** `test.rules.txt` routes `doc/source/<lib>/**` to
that library's tag, so a doc change runs only the owning library's
example tests. LLM doc assets already route to `llm` and keep doing so.
1. **`doc` reserved for validation.** It now stays only on the
documentation build and the Vale/config infra.
1. **Rename** to `X: docs example tests`, since a failure in these steps
means library code or an example broke, not that the docs are wrong.
1. **Build-file rule fix.** `test.rules.txt` matched `doc/BUILD` and
`doc/*/BUILD`, but the files are `BUILD.bazel`, so editing a file that
*defines* the doc test targets ran no doc tests premerge. It now matches
the `.bazel` files and routes them to the same per-library steps. The
root `doc/BUILD.bazel` defines every library's targets, so it routes to
all of them.

### Scoping exceptions, and why each exists

Several paths sit under a library doc directory but can't be
meaningfully tested by that library's example step, so they're routed
explicitly rather than by directory:

- **Static images skip entirely.** Image extensions sit on the leading
skip rule, ahead of the per-library rules, so a `.png` or `.svg` edit
triggers nothing. 310 tracked image files. `.yaml` and `.sh` stay
routed, since unlike an image they can change what a test does.
- **Sphinx build machinery routes to `doc`.** `conf.py` imports
`custom_directives`, `api_autogen`, `api_mock_imports`, and
`template_collections`; none was listed in the validation-infra rule, so
all fell to the `doc/*.py` catch-all and emitted `core_doc`, running Ray
Core's doctests for a docs-build-machinery edit. Those four plus
`preprocess_github_markdown` and the doc-root build helpers now route to
`doc`. They're enumerated one per line on purpose: `*` is fnmatch here
and crosses `/`, so a `doc/source/*.py` pattern would also swallow every
example script under `doc/source/<lib>/doc_code/`. There's a comment on
the rule saying so.
- **Gallery configs route to `doc`.**
`doc/source/{data,serve,train}/examples.yml` are parsed by
`custom_directives.py` (`EXAMPLE_GALLERY_CONFIGS`) to generate the
gallery pages. They hold no executable code and can't change what any
example does. Narrowed to a three-path exception rather than a blanket
`.yml` skip, because a sibling `.yml` under a library doc directory can
be a config an example consumes.
- **`doc/.claude/` triggers nothing.** Agent files never participate in
the Sphinx build and define no test targets, but
`doc/.claude/skills/sphinx-fix/sphinx_fix.py` matched the `doc/*.py`
catch-all. The Read the Docs build guard already excludes this exact
path for the same reason, so the two guards now agree. Pre-existing
rather than a regression from this PR: on master the file emits the
blanket `doc` tag, which reaches all five per-team steps.
- **Four `team:ml` notebooks under `ray-core/` route to `ml_doc`.**
`plot_hyperparameter`, `batch_prediction`, `plot_parameter_server`, and
`plot_pong_example` live under `doc/source/ray-core/examples/` but their
targets are tagged `team:ml`, and the team argument to
`//ci/ray_ci:test_in_docker` filters targets by `team:<team>`
(`_get_all_test_query`, `ci/ray_ci/tester.py`). Routing them to
`core_doc` would run a step that tests everything under `ray-core/`
except the file that changed. Re-tagging the four `team:core` in
`doc/BUILD.bazel` is the alternative fix and would let the rule lines go
away.
- **`highly_parallel.ipynb` routes to `doc`.** Its `py_test` carries a
`highly_parallel` tag that the ml docs example step excludes, and the
notebook glob in `doc/source/ray-core/examples/BUILD.bazel` excludes it
too, as a release test needing a live multi-node cluster. The remaining
ml `//doc/...` steps select `gpu` / `train_v2_gpu` and the target has
neither, so no premerge step executes it. Routing to `doc` means the
build renders it (`nb_execution_mode` defaults to `off`, so
render-and-lint only), which is the only validation premerge offers
here.
- **`doc/external/` routes to `ml_doc`.** Its `test_external_hashes`
target is tagged `team:ml`; it had fallen through the `doc/*.py`
catch-all to `core_doc`, where the core step's `team:core` query never
sees it.
- **The `llms.txt` files route to `doc`.** ray-project#64458 adds
`doc/test_llms_txt.py` and `doc/source/llms_txt_summary.txt` with no
`test.rules.txt` change. Left alone the test would land on the
`doc/*.py` catch-all and emit `core_doc`, running Ray Core's doctests
for a test its own docstring describes as hermetic, while never running
the step that executes it. Rules for absent paths are inert, so there's
no ordering dependency: this PR doesn't touch `doc.rayci.yml`, ray-project#64458
doesn't touch `test.rules.txt`, and whichever lands first the other
merges correctly scoped.
- **Declined:** fanning `doc/test_myst_doc.py` out to all five
`<lib>_doc` tags. It backs 19 targets across every team, but it's shared
infrastructure, so a break surfaces in core as readily as anywhere. One
library's worth of execution is a sufficient smoke signal and the
post-merge build covers the rest. The rule carries a comment recording
that trade and when to revisit it.

### Effect on a doc-only PR (no `docs-go`)

| Change | Before | After |
|---|---|---|
| A Serve doc example | every team's `doc tests` step | `serve: docs
example tests` and its GPU sibling |
| A Data doc example | every team's `doc tests` step | `data: docs
example tests`, plus the dask and GPU siblings |
| An image under a library doc dir | that library's example step |
nothing |
| A Sphinx build module (`custom_directives.py` etc.) | `core: docs
example tests` | `doc: build` only (post-merge) |
| A gallery config (`examples.yml`) | that library's example step |
`doc: build` only (post-merge) |
| Editing `doc/BUILD.bazel` | nothing (rule was dead) | the doc example
steps it defines |
| The two `doc: check API*` checks | ran, via the blanket `doc` tag |
don't run (see reviewer summary) |

The GPU and dask siblings carry `<lib>_doc` too, and tag matching is a
non-empty intersection, so they're selected alongside the main step.
That's unchanged behavior: they carried the blanket `doc` tag before, so
a doc change already started them. No new GPU cost.

## Verification

**Rule conformance, under the authoritative evaluator.** `test-rules` is
green on this PR. It replays all 103 `test.rules.test.txt` assertions
through the pinned `rayci` binary, and `runTestRules` compares the full
computed tag set per path, so every case is also a negative assertion
that no other tag fires.

**Tag-to-step resolution, generated locally.** The tag set isn't the
step set: rayci filters steps by tag, then `markDeps` pulls in
everything reachable through `depends_on` regardless of that step's own
tags. To confirm the composition rather than infer it, I ran the pinned
`rayci v0.46.0` release binary against a one-file Serve doc-example
change, on master and on this branch:

```
before (base=master)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always doc lint
  doc-related steps emitted:
    core: doc tests [g6_s22]             ml: doc tests [g13_s26]
    data: doc tests [g7_s21]             rllib: doc tests [g15_s8]
    data: dask doc tests [g7_s22]        serve: doc tests [g16_s12]
    data: doc gpu tests [g7_s23]         serve: doc gpu tests [g16_s21]
    doc: check API annotations [g9_s3]   doc: check API doc consistency [g9_s4]

after (this branch)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always lint serve_doc
  doc-related steps emitted:
    serve: docs example tests [g16_s12]
    serve: docs example gpu tests [g16_s21]
```

Six teams' example steps collapse to the owning team's two, and the step
IDs are unchanged across the rename.

**Routing versus coverage.** Correct routing isn't sufficient: the step
that starts still has to select the target. `ci/ray_ci/tester.py`
filters by `attr(tags, 'team:<team>')`, then intersects `--only-tags`
and subtracts `--except-tags`, so a change can route perfectly, start
the right-looking step, and be invisible to every command in it. I swept
all 948 (file, target) claims under `doc/` against the per-team filters.
After the exceptions above, the only deliberate team mismatch left is
`doc/test_myst_doc.py`. Two pre-existing gaps fell out, neither created
by this change:

- **GPU-tagged ml and core doc examples have no owning step** — six
`team:ml` notebooks tagged `gpu`, five `team:core` `doc_code` modules
tagged `multi_gpu`, and one `post_wheel_build` module. `data` and
`serve` each have a GPU doc-example step; ml and core never got one, so
the only steps that would run these are gated on `train_gpu` and
`cgraphs_direct_transport`, which no doc path emits. No `doc`-tagged
step ran them before the split either. This needs a REEf and
library-team decision rather than a rules change.
- **Prose doctests aren't triggered by prose edits.** The
`doc/BUILD.bazel` `doctest` targets over `doc/source/**/*.{md,rst}` are
reachable only from the `others.rayci.yml` step gated on `python`, while
prose paths hit the leading skip rule. Roughly 700 files. I consider
this correct as-is: given current coverage the Read the Docs render
build is the gate a prose change needs.

**Also swept** all 1,628 tracked `doc/` files against the previous rules
to confirm exactly which paths changed routing and that nothing else
moved.

## Change log

Consolidated above; kept here so the review history stays legible.

- `6a1310d3b5` — the split: per-library tags, path routing, rename,
`BUILD.bazel` rule fix.
- `c6302c8a21`, `b1d03629cf` — first bot-review pass: static images
skip; Sphinx build modules route to `doc`.
- `99c3af2c28` — pre-route the `llms.txt` extension test and summary
ahead of ray-project#64458.
- `3795c6161b` — skip `doc/.claude/`; route the `team:ml` `ray-core`
notebooks to `ml_doc`.
- `e88e8a4b52` — remove a stray `TEMP(do-not-merge)` marker that reached
master with ray-project#65040. Inert, and independent of this PR's thesis; happy to
split it out.
- `f8347baf54` — second bot-review pass: gallery configs to `doc`;
correct `highly_parallel.ipynb` to `doc`.
- `6a050a0511` — route `doc/external/` to `ml_doc` so the hash guard
still runs.

## AI assistance

This change was drafted with AI assistance (Claude Code) and reviewed by
me.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Artimislyy pushed a commit to Artimislyy/ray that referenced this pull request Aug 11, 2026
…ay-project#65115)

## Summary

Completes the page-description work
[ray-project#64330](ray-project#64330) started, so that
**every page listed in `llms.txt` carries a curated description**.

ray-project#64330 (merged) described the 94 pages that made up the index when it
listed only each section's landing page plus its direct toctree
children. The generator in
[ray-project#64458](ray-project#64458) makes the index
complete — every in-scope page under its section — so the index now
carries ~630 entries, and the ~400 that ray-project#64330 didn't cover fall back to
a truncated first paragraph.

That fallback is often actively bad for an agent routing on it. Of the
397 undescribed pages:

| Fallback problem | Pages | Example |
|---|---:|---|
| No paragraph at all | 22 | `cluster/kubernetes/troubleshooting` |
| Pointer prose | 34 | `cluster/cli` → "This section contains commands
for managing Ray clusters." |
| Restates the title | 117 | every `ray-core/patterns/*` anti-pattern
page |
| Under 70 chars | 170 | `data/inspecting-data` → "Inspect Datasets to
better understand your data." |

## Changes

- **368 pages get a curated description**, following the convention
ray-project#64330 established: `myst: html_meta: description:` front matter for
`.md` (164 files), and a `.. meta::` directive for `.rst` (204 files).
The `.rst` block is placed after any leading docinfo field list
(`:orphan:` and friends) but **before** any `.. _label:` target, so the
label still resolves to the section title.
- **31 pages are excluded instead** (`conf.py`). These are thin
API-reference hub pages — a title plus an autosummary table, under 40
words of real prose — whose per-symbol targets are already excluded by
the existing `*/api/doc/*` patterns. Also `data/api/_autogen` (no title
at all) and two `*_regression_example` literalinclude stubs with zero
prose. A description on any of these could only restate its title.

Style follows the same house rule as ray-project#64330: 130–150 characters,
front-loading what distinguishes the page, no "Ray X is a…" restatement
of the link title. Mean length 122 chars, none over 160.

Substantial API-reference pages were **kept and described**, not
excluded — `tune/api/schedulers` (965 words of prose), `tune/api/env`,
`tune/api/trainable`, `serve/api/index`, `data/api/expressions` are
exactly what a coding agent wants.

**Result: 479 in-scope pages described, 31 excluded, 0 relying on
first-paragraph fallback.**

## Relationship to other PRs

Independent of **ray-project#64458** (the generator). Descriptions are page front
matter and work with the current third-party `sphinx-llms-txt` on master
as well as the in-repo generator. The one file both touch is
`doc/source/conf.py`: this PR appends a `llms_txt_exclude += [...]`
block below the existing list rather than editing the list literal,
which is what ray-project#64458 rewrites, so the two shouldn't collide. Either can
merge first.

Not a duplicate: `gh pr list --state open` finds no other PR adding page
descriptions or `html_meta` blocks. ray-project#64330, the only prior art, is
merged.

## Rebased on master

Merged master to clear a conflict. Two pages shifted:

- `cluster/kubernetes/user-guides/kuberay-history-server.md` no longer
appears in this diff. ray-project#65139 described that page independently while
this branch was open, and its description is the better one: this
branch's scoped the page to GKE and Google Cloud Storage, where master's
covers RayCluster, RayJob, and RayService, which is the page's actual
scope. Resolved in favor of master.
- `ray-observability/user-guides/jax-tpu-profiling.md` is newly
described. It landed on master after this branch was cut and was the one
in-scope page still falling back to a truncated first paragraph.

Net file count is 368 newly described pages plus `conf.py`, plus one
re-key:
`ray-core/scheduling/labels.md` carried a bare top-level `description:`
in its front matter, the only such file in the tree. Sphinx emits no
meta description from that key, so despite looking described the page
fed neither the HTML meta tag nor `llms.txt`. The text is unchanged;
only the key moves under `myst.html_meta`. That page was already counted
as described, so the totals above don't move.

## Testing

Local verification (no Ray build required — these are doc source edits):

```
$ python3 doc/test_no_new_rst.py                       # exit 0 (no new .rst files; all 204 are edits)
$ vale doc/source/data doc/source/ray-overview/examples
  174 alerts, 0 error-level, 0 on the added lines
  identical to the master baseline (174 alerts) — this change adds no Vale alerts
$ python3 -c "import ast; ast.parse(open('doc/source/conf.py').read())"   # conf.py parses
```

Plus scripted checks over all 370 changed files:

- All 164 `.md` front-matter blocks parse as YAML and expose
`myst.html_meta.description`.
- All 204 `.rst` files: `.. meta::` precedes any `.. _label:`, and any
docinfo field list still precedes the `.. meta::` block.
- Re-running the in-scope inventory: 510 pages, 479 described, 31
excluded, **0 gaps**.
- The 31 entries added to `llms_txt_exclude` match the computed exclude
set exactly.

The `-W` docs build is the real end-to-end gate and runs in CI here.

## AI assistance

Drafted with Claude Code: the descriptions were generated from each
page's title, headings, and lead prose, and applied by script. Per
`AGENTS.md`, this needs a human pass over the content before it's ready
for review — **opening as a draft for that reason**. The mechanical
placement is verified by the checks above; what needs human eyes is
whether each description is accurate and useful for its page.

---------

Signed-off-by: Ronny Roland <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]>

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

stamp to unblock

@dstrodtman
dstrodtman enabled auto-merge (squash) August 11, 2026 15:13
@dstrodtman
dstrodtman merged commit 5368554 into master Aug 11, 2026
7 checks passed
@dstrodtman
dstrodtman deleted the doc-1130-llms-txt-extension branch August 11, 2026 16:38
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…per library (ray-project#64775)

## Reviewer summary

**What this does.** The per-team `X: doc tests` steps are library
example and doctest suites that live under `doc/`. They exercise library
code, not documentation quality. Today every executable doc asset emits
the blanket `doc` tag and all six teams' steps are tagged `doc`, so a
one-library doc change starts every team's step. This gives each step a
dedicated `<lib>_doc` tag, routes `doc/source/<lib>/**` to the owning
library's tag, renames the steps to `X: docs example tests`, and leaves
`doc` for documentation validation (the build and the Vale/config
infra). The library tag stays on each step, so a library **code** change
runs its doc example tests exactly as before.

**What's verified.**

| Claim | Evidence |
|---|---|
| Each path emits exactly the intended tag, and no other | `test-rules`
green on this PR. That's the pinned `rayci` binary replaying all 103
`test.rules.test.txt` assertions (up from 57 on master) with **exact set
equality**, so each case also proves the blanket `doc` tag does *not*
come along. |
| The emitted tags resolve to the intended steps, and only those |
Generated the real pipeline locally with the pinned `rayci v0.46.0`
release binary for a one-file Serve doc-example change, before and after
this branch. Output below. |
| The renamed steps still run and pass | All five plus the GPU and dask
siblings green on this PR, selected via the library tags this change
preserves. |
| Every executable target under `doc/` routes to a step that can
actually select it | Swept all 948 (file, target) claims against the
per-team `team:` / `--only-tags` / `--except-tags` filters. One
deliberate exception (`doc/test_myst_doc.py`, below) and two
pre-existing gaps that this change doesn't create. |
| The rename doesn't reset step identity | rayci derives step IDs
positionally (`fmt.Sprintf("g%d_s%d", i, j)`, `converter.go`), not from
the label. The generated pipelines confirm it: `g16_s12`, `g16_s21`,
`g6_s22`, `g13_s26` are identical before and after. |

**What I need from a reviewer.**

1. **One question I can't answer from inside the repo.**
`ci/build/get_build_info.py` sets `config.env` to `"Buildkite " +
BUILDKITE_LABEL`, and `ci/build/upload_build_info.sh` uploads it on
postmerge pipelines on `master` only. Does anything downstream of that
`metadata.json` treat `config.env` as an identity or grouping key? If
it's descriptive, renaming five steps is free. If something groups on
it, those five steps' postmerge history splits at the merge commit.
Flaky-test selection and target selection both key on `team` (unchanged
here) and test identity is the bazel target name (`f"{system}:{name}"`
in `release/ray_release/test.py`), so I believe `config.env` is the only
place the label escapes.
1. **Confirm the API-check behavior change below is acceptable.**
1. **Confirm the catch-all owner.** Executable doc assets in directories
with no per-team step route to the core step: roughly 25 files, being 18
`doc/source/templates/*/start.ipynb` plus a handful under
`doc/source/cluster/doc_code/`, `doc/source/ray-contribute/doc_code/`,
and `doc/source/_templates/`. The templates majority may be retired or
externally managed, in which case a skip rule is the better answer than
core ownership.

**Known behavior change worth your eyes.** Because
`doc/source/<lib>/doc_code/` and `examples/` now emit `<lib>_doc`
instead of `doc`, the two API-surface checks (`doc: check API
annotations`, `doc: check API doc consistency`) stop running on library
doc-example changes. They carry the blanket `doc` tag among their
library tags, so today a `doc_code` edit incidentally triggers a
premerge `make -C doc/ html`. I think that's correct: those checks guard
the documented public API surface, which a doc example can't change, and
the example itself is still executed by the owning library's step while
the render is gated by Read the Docs. But it is a premerge signal that
disappears, so it should be a decision rather than a side effect. Raised
on ray-project#64812, which routes the API **reference** pages to a dedicated
`doc_api` tag for the related case.

**Out of scope, tracked separately.** `.buildkite/others.rayci.yml:13`
declares a sixth step labeled `doc tests`, running `//python/ray/...
//doc/... none --only-tags doctest` and tagged `python`, a tag no rule
in `test.rules.txt` emits. Generating the full-fan-out pipeline shows it
does get emitted (`doc tests [g14_s1]`), so it is live. After this
rename it becomes the only step in the repo still called "doc tests."
This PR doesn't touch `others.rayci.yml` and the fix is independent.

---

## What this changes

1. **Dedicated per-library tag.** Each step gets a `<lib>_doc` tag
(`core_doc`, `data_doc`, `ml_doc`, `rllib_doc`, `serve_doc`) and drops
the blanket `doc` tag. The library tag stays.
1. **Path routing.** `test.rules.txt` routes `doc/source/<lib>/**` to
that library's tag, so a doc change runs only the owning library's
example tests. LLM doc assets already route to `llm` and keep doing so.
1. **`doc` reserved for validation.** It now stays only on the
documentation build and the Vale/config infra.
1. **Rename** to `X: docs example tests`, since a failure in these steps
means library code or an example broke, not that the docs are wrong.
1. **Build-file rule fix.** `test.rules.txt` matched `doc/BUILD` and
`doc/*/BUILD`, but the files are `BUILD.bazel`, so editing a file that
*defines* the doc test targets ran no doc tests premerge. It now matches
the `.bazel` files and routes them to the same per-library steps. The
root `doc/BUILD.bazel` defines every library's targets, so it routes to
all of them.

### Scoping exceptions, and why each exists

Several paths sit under a library doc directory but can't be
meaningfully tested by that library's example step, so they're routed
explicitly rather than by directory:

- **Static images skip entirely.** Image extensions sit on the leading
skip rule, ahead of the per-library rules, so a `.png` or `.svg` edit
triggers nothing. 310 tracked image files. `.yaml` and `.sh` stay
routed, since unlike an image they can change what a test does.
- **Sphinx build machinery routes to `doc`.** `conf.py` imports
`custom_directives`, `api_autogen`, `api_mock_imports`, and
`template_collections`; none was listed in the validation-infra rule, so
all fell to the `doc/*.py` catch-all and emitted `core_doc`, running Ray
Core's doctests for a docs-build-machinery edit. Those four plus
`preprocess_github_markdown` and the doc-root build helpers now route to
`doc`. They're enumerated one per line on purpose: `*` is fnmatch here
and crosses `/`, so a `doc/source/*.py` pattern would also swallow every
example script under `doc/source/<lib>/doc_code/`. There's a comment on
the rule saying so.
- **Gallery configs route to `doc`.**
`doc/source/{data,serve,train}/examples.yml` are parsed by
`custom_directives.py` (`EXAMPLE_GALLERY_CONFIGS`) to generate the
gallery pages. They hold no executable code and can't change what any
example does. Narrowed to a three-path exception rather than a blanket
`.yml` skip, because a sibling `.yml` under a library doc directory can
be a config an example consumes.
- **`doc/.claude/` triggers nothing.** Agent files never participate in
the Sphinx build and define no test targets, but
`doc/.claude/skills/sphinx-fix/sphinx_fix.py` matched the `doc/*.py`
catch-all. The Read the Docs build guard already excludes this exact
path for the same reason, so the two guards now agree. Pre-existing
rather than a regression from this PR: on master the file emits the
blanket `doc` tag, which reaches all five per-team steps.
- **Four `team:ml` notebooks under `ray-core/` route to `ml_doc`.**
`plot_hyperparameter`, `batch_prediction`, `plot_parameter_server`, and
`plot_pong_example` live under `doc/source/ray-core/examples/` but their
targets are tagged `team:ml`, and the team argument to
`//ci/ray_ci:test_in_docker` filters targets by `team:<team>`
(`_get_all_test_query`, `ci/ray_ci/tester.py`). Routing them to
`core_doc` would run a step that tests everything under `ray-core/`
except the file that changed. Re-tagging the four `team:core` in
`doc/BUILD.bazel` is the alternative fix and would let the rule lines go
away.
- **`highly_parallel.ipynb` routes to `doc`.** Its `py_test` carries a
`highly_parallel` tag that the ml docs example step excludes, and the
notebook glob in `doc/source/ray-core/examples/BUILD.bazel` excludes it
too, as a release test needing a live multi-node cluster. The remaining
ml `//doc/...` steps select `gpu` / `train_v2_gpu` and the target has
neither, so no premerge step executes it. Routing to `doc` means the
build renders it (`nb_execution_mode` defaults to `off`, so
render-and-lint only), which is the only validation premerge offers
here.
- **`doc/external/` routes to `ml_doc`.** Its `test_external_hashes`
target is tagged `team:ml`; it had fallen through the `doc/*.py`
catch-all to `core_doc`, where the core step's `team:core` query never
sees it.
- **The `llms.txt` files route to `doc`.** ray-project#64458 adds
`doc/test_llms_txt.py` and `doc/source/llms_txt_summary.txt` with no
`test.rules.txt` change. Left alone the test would land on the
`doc/*.py` catch-all and emit `core_doc`, running Ray Core's doctests
for a test its own docstring describes as hermetic, while never running
the step that executes it. Rules for absent paths are inert, so there's
no ordering dependency: this PR doesn't touch `doc.rayci.yml`, ray-project#64458
doesn't touch `test.rules.txt`, and whichever lands first the other
merges correctly scoped.
- **Declined:** fanning `doc/test_myst_doc.py` out to all five
`<lib>_doc` tags. It backs 19 targets across every team, but it's shared
infrastructure, so a break surfaces in core as readily as anywhere. One
library's worth of execution is a sufficient smoke signal and the
post-merge build covers the rest. The rule carries a comment recording
that trade and when to revisit it.

### Effect on a doc-only PR (no `docs-go`)

| Change | Before | After |
|---|---|---|
| A Serve doc example | every team's `doc tests` step | `serve: docs
example tests` and its GPU sibling |
| A Data doc example | every team's `doc tests` step | `data: docs
example tests`, plus the dask and GPU siblings |
| An image under a library doc dir | that library's example step |
nothing |
| A Sphinx build module (`custom_directives.py` etc.) | `core: docs
example tests` | `doc: build` only (post-merge) |
| A gallery config (`examples.yml`) | that library's example step |
`doc: build` only (post-merge) |
| Editing `doc/BUILD.bazel` | nothing (rule was dead) | the doc example
steps it defines |
| The two `doc: check API*` checks | ran, via the blanket `doc` tag |
don't run (see reviewer summary) |

The GPU and dask siblings carry `<lib>_doc` too, and tag matching is a
non-empty intersection, so they're selected alongside the main step.
That's unchanged behavior: they carried the blanket `doc` tag before, so
a doc change already started them. No new GPU cost.

## Verification

**Rule conformance, under the authoritative evaluator.** `test-rules` is
green on this PR. It replays all 103 `test.rules.test.txt` assertions
through the pinned `rayci` binary, and `runTestRules` compares the full
computed tag set per path, so every case is also a negative assertion
that no other tag fires.

**Tag-to-step resolution, generated locally.** The tag set isn't the
step set: rayci filters steps by tag, then `markDeps` pulls in
everything reachable through `depends_on` regardless of that step's own
tags. To confirm the composition rather than infer it, I ran the pinned
`rayci v0.46.0` release binary against a one-file Serve doc-example
change, on master and on this branch:

```
before (base=master)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always doc lint
  doc-related steps emitted:
    core: doc tests [g6_s22]             ml: doc tests [g13_s26]
    data: doc tests [g7_s21]             rllib: doc tests [g15_s8]
    data: dask doc tests [g7_s22]        serve: doc tests [g16_s12]
    data: doc gpu tests [g7_s23]         serve: doc gpu tests [g16_s21]
    doc: check API annotations [g9_s3]   doc: check API doc consistency [g9_s4]

after (this branch)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always lint serve_doc
  doc-related steps emitted:
    serve: docs example tests [g16_s12]
    serve: docs example gpu tests [g16_s21]
```

Six teams' example steps collapse to the owning team's two, and the step
IDs are unchanged across the rename.

**Routing versus coverage.** Correct routing isn't sufficient: the step
that starts still has to select the target. `ci/ray_ci/tester.py`
filters by `attr(tags, 'team:<team>')`, then intersects `--only-tags`
and subtracts `--except-tags`, so a change can route perfectly, start
the right-looking step, and be invisible to every command in it. I swept
all 948 (file, target) claims under `doc/` against the per-team filters.
After the exceptions above, the only deliberate team mismatch left is
`doc/test_myst_doc.py`. Two pre-existing gaps fell out, neither created
by this change:

- **GPU-tagged ml and core doc examples have no owning step** — six
`team:ml` notebooks tagged `gpu`, five `team:core` `doc_code` modules
tagged `multi_gpu`, and one `post_wheel_build` module. `data` and
`serve` each have a GPU doc-example step; ml and core never got one, so
the only steps that would run these are gated on `train_gpu` and
`cgraphs_direct_transport`, which no doc path emits. No `doc`-tagged
step ran them before the split either. This needs a REEf and
library-team decision rather than a rules change.
- **Prose doctests aren't triggered by prose edits.** The
`doc/BUILD.bazel` `doctest` targets over `doc/source/**/*.{md,rst}` are
reachable only from the `others.rayci.yml` step gated on `python`, while
prose paths hit the leading skip rule. Roughly 700 files. I consider
this correct as-is: given current coverage the Read the Docs render
build is the gate a prose change needs.

**Also swept** all 1,628 tracked `doc/` files against the previous rules
to confirm exactly which paths changed routing and that nothing else
moved.

## Change log

Consolidated above; kept here so the review history stays legible.

- `6a1310d3b5` — the split: per-library tags, path routing, rename,
`BUILD.bazel` rule fix.
- `c6302c8a21`, `b1d03629cf` — first bot-review pass: static images
skip; Sphinx build modules route to `doc`.
- `99c3af2c28` — pre-route the `llms.txt` extension test and summary
ahead of ray-project#64458.
- `3795c6161b` — skip `doc/.claude/`; route the `team:ml` `ray-core`
notebooks to `ml_doc`.
- `e88e8a4b52` — remove a stray `TEMP(do-not-merge)` marker that reached
master with ray-project#65040. Inert, and independent of this PR's thesis; happy to
split it out.
- `f8347baf54` — second bot-review pass: gallery configs to `doc`;
correct `highly_parallel.ipynb` to `doc`.
- `6a050a0511` — route `doc/external/` to `ml_doc` so the hash guard
still runs.

## AI assistance

This change was drafted with AI assistance (Claude Code) and reviewed by
me.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ay-project#65115)

## Summary

Completes the page-description work
[ray-project#64330](ray-project#64330) started, so that
**every page listed in `llms.txt` carries a curated description**.

ray-project#64330 (merged) described the 94 pages that made up the index when it
listed only each section's landing page plus its direct toctree
children. The generator in
[ray-project#64458](ray-project#64458) makes the index
complete — every in-scope page under its section — so the index now
carries ~630 entries, and the ~400 that ray-project#64330 didn't cover fall back to
a truncated first paragraph.

That fallback is often actively bad for an agent routing on it. Of the
397 undescribed pages:

| Fallback problem | Pages | Example |
|---|---:|---|
| No paragraph at all | 22 | `cluster/kubernetes/troubleshooting` |
| Pointer prose | 34 | `cluster/cli` → "This section contains commands
for managing Ray clusters." |
| Restates the title | 117 | every `ray-core/patterns/*` anti-pattern
page |
| Under 70 chars | 170 | `data/inspecting-data` → "Inspect Datasets to
better understand your data." |

## Changes

- **368 pages get a curated description**, following the convention
ray-project#64330 established: `myst: html_meta: description:` front matter for
`.md` (164 files), and a `.. meta::` directive for `.rst` (204 files).
The `.rst` block is placed after any leading docinfo field list
(`:orphan:` and friends) but **before** any `.. _label:` target, so the
label still resolves to the section title.
- **31 pages are excluded instead** (`conf.py`). These are thin
API-reference hub pages — a title plus an autosummary table, under 40
words of real prose — whose per-symbol targets are already excluded by
the existing `*/api/doc/*` patterns. Also `data/api/_autogen` (no title
at all) and two `*_regression_example` literalinclude stubs with zero
prose. A description on any of these could only restate its title.

Style follows the same house rule as ray-project#64330: 130–150 characters,
front-loading what distinguishes the page, no "Ray X is a…" restatement
of the link title. Mean length 122 chars, none over 160.

Substantial API-reference pages were **kept and described**, not
excluded — `tune/api/schedulers` (965 words of prose), `tune/api/env`,
`tune/api/trainable`, `serve/api/index`, `data/api/expressions` are
exactly what a coding agent wants.

**Result: 479 in-scope pages described, 31 excluded, 0 relying on
first-paragraph fallback.**

## Relationship to other PRs

Independent of **ray-project#64458** (the generator). Descriptions are page front
matter and work with the current third-party `sphinx-llms-txt` on master
as well as the in-repo generator. The one file both touch is
`doc/source/conf.py`: this PR appends a `llms_txt_exclude += [...]`
block below the existing list rather than editing the list literal,
which is what ray-project#64458 rewrites, so the two shouldn't collide. Either can
merge first.

Not a duplicate: `gh pr list --state open` finds no other PR adding page
descriptions or `html_meta` blocks. ray-project#64330, the only prior art, is
merged.

## Rebased on master

Merged master to clear a conflict. Two pages shifted:

- `cluster/kubernetes/user-guides/kuberay-history-server.md` no longer
appears in this diff. ray-project#65139 described that page independently while
this branch was open, and its description is the better one: this
branch's scoped the page to GKE and Google Cloud Storage, where master's
covers RayCluster, RayJob, and RayService, which is the page's actual
scope. Resolved in favor of master.
- `ray-observability/user-guides/jax-tpu-profiling.md` is newly
described. It landed on master after this branch was cut and was the one
in-scope page still falling back to a truncated first paragraph.

Net file count is 368 newly described pages plus `conf.py`, plus one
re-key:
`ray-core/scheduling/labels.md` carried a bare top-level `description:`
in its front matter, the only such file in the tree. Sphinx emits no
meta description from that key, so despite looking described the page
fed neither the HTML meta tag nor `llms.txt`. The text is unchanged;
only the key moves under `myst.html_meta`. That page was already counted
as described, so the totals above don't move.

## Testing

Local verification (no Ray build required — these are doc source edits):

```
$ python3 doc/test_no_new_rst.py                       # exit 0 (no new .rst files; all 204 are edits)
$ vale doc/source/data doc/source/ray-overview/examples
  174 alerts, 0 error-level, 0 on the added lines
  identical to the master baseline (174 alerts) — this change adds no Vale alerts
$ python3 -c "import ast; ast.parse(open('doc/source/conf.py').read())"   # conf.py parses
```

Plus scripted checks over all 370 changed files:

- All 164 `.md` front-matter blocks parse as YAML and expose
`myst.html_meta.description`.
- All 204 `.rst` files: `.. meta::` precedes any `.. _label:`, and any
docinfo field list still precedes the `.. meta::` block.
- Re-running the in-scope inventory: 510 pages, 479 described, 31
excluded, **0 gaps**.
- The 31 entries added to `llms_txt_exclude` match the computed exclude
set exactly.

The `-W` docs build is the real end-to-end gate and runs in CI here.

## AI assistance

Drafted with Claude Code: the descriptions were generated from each
page's title, headings, and lead prose, and applied by script. Per
`AGENTS.md`, this needs a human pass over the content before it's ready
for review — **opening as a draft for that reason**. The mechanical
placement is verified by the checks above; what needs human eyes is
whether each description is accurate and useful for its page.

---------

Signed-off-by: Ronny Roland <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]>
Signed-off-by: 400Ping <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…project#64458)

## Summary

Replaces the third-party
[`sphinx-llms-txt`](https://github.com/jdillard/sphinx-llms-txt) with a
small in-repo Sphinx extension (`doc/source/_ext/llms_txt.py`, alongside
`callouts.py` / `queryparamrefs.py`) that generates
**navigation-structured** agent manifests instead of one flat list.

Three tiers, emitted into the HTML build output:

- **`/llms.txt`** — index: H1 + summary, one `## Section` per top-level
`toctree` entry of the root doc. Each section lists its landing page and
every in-scope page in the subtree beneath it as `- [title](url):
description`, deduped so a page appears only under the first section
that reaches it, so an agent can locate any page from the index without
drilling into the corpus. A page the nav toctrees never reach (an
example linked only from a gallery grid, say) folds into the section
owning its top-level directory; only pages whose directory maps to no
section land in a trailing `## Other pages`. Sections in
`llms_txt_optional_sections` move to a trailing `## Optional` block.
- **`/<section>/llms-full.txt`** — verbatim page source per section,
behind a `## Contents` TOC (which also surfaces deep pages absent from
the index). A section whose source exceeds
`llms_txt_full_max_shard_tokens` (default **200K**, ~4 chars/token) is
split recursively into per-subdirectory sub-shards, so each loadable
unit fits an agent's context budget.
- **`/llms-full.txt`** — a manifest linking every shard (sub-shards
nested under their parent), each with a description and page count, so
an agent routes without downloading.

Descriptions resolve from front-matter/docinfo `description` → an
`html_meta` / `.. meta::` node → a first-paragraph fallback.

## Why not a single `llms-full.txt`

Ray's full corpus is ~1.14M tokens — too large to load whole on most
models, and truncating it (what `sphinx-llms-txt`'s size knobs do) just
yields an arbitrary lossy prefix. Peer projects all ship a single flat
file and none cap; sharding by section keeps every unit independently
loadable.

### Note for existing `llms-full.txt` consumers

This changes what `/llms-full.txt` serves at a stable URL. Today it's
~5.9 MB of concatenated page text; after this it's a small manifest
linking the per-section shards. Anything pointed at that URL expecting
full text should follow the manifest to the shard it needs instead.

## Changes

- New `doc/source/_ext/llms_txt.py` + hermetic test
`doc/source/_ext/test_llms_txt.py`.
- `conf.py`: swap `sphinx_llms_txt` → `llms_txt`; add `llms_txt_title`,
`llms_txt_optional_sections`, `llms_txt_full_max_shard_tokens` (keeps
the existing `llms_txt_summary` / `llms_txt_exclude`).
- Remove `sphinx-llms-txt==0.7.1` from `requirements-doc.txt` and the
docs lock (`python/deplocks/docs/docbuild_depset_py3.11.lock`; clean
leaf removal — `raydepsets --check` consistent).
- New premerge step `doc: test llms.txt extension` in
`.buildkite/doc.rayci.yml` (runs in the `docbuild-py3.11` env, since the
test needs sphinx + myst).

## Forward-compatibility

Written for the in-flight Sphinx 8→9 upgrade: `findall` (not
`traverse`), `root_doc` (not `master_doc`), defensive `getattr` env
access, `docutils.nodes.meta`, and all work in `build-finished`
(parallel-safe).

## Testing

- `doc/source/_ext/test_llms_txt.py` — hermetic in-process Sphinx build
covering all three description sources, exclusion, the `## Optional`
section, sub-shard splitting, and the nested manifest. Passes on the
pinned stack (Sphinx 8.2.3 / MyST 5.1.0 / docutils 0.21.2).
- The full `-W` docs build validates end-to-end in CI here.

## Relationship to ray-project#64330

Independent of [ray-project#64330](ray-project#64330)
(which adds the per-page `<meta name="description">` descriptions) —
zero file overlap, mergeable in either order. Where a page has no
curated description yet, the generator uses its first paragraph, so
output is sensible regardless.

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

---------

Signed-off-by: Ronny Roland <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]>
Signed-off-by: 400Ping <[email protected]>
dstrodtman pushed a commit that referenced this pull request Aug 28, 2026
## Summary

Follow-up to #64458. Adds one line to `llms.txt` telling agents that the
page links also serve Markdown.

Read the Docs serves a Markdown rendering of any page **from that page's
own `.html` URL**, under an `Accept: text/markdown` request. There is no
separate `.md` file to link to — `page.md`, `page.html.md`,
`/md/<page>.md`, and `?format=md` all 404, and no `Link: rel=alternate`
header advertises one.

So the `.html` links `llms.txt` already emits *are* the Markdown links.
Nothing in the file says so, and an agent has no way to discover it.

```
# Ray

> Ray is an open-source unified compute framework for scaling AI and Python workloads…

Full page text, grouped by section, is in [llms-full.txt](https://docs.ray.io/en/master/llms-full.txt).

Request the links that follow with the HTTP header `Accept: text/markdown` to retrieve a Markdown rendering of the page.

## Overview
…
```

## The header has to be explicit

Measured against `docs.ray.io/en/master/data/data.html`:

| `Accept:` sent | returns |
|---|---|
| `*/*` — the default for curl, `requests`, `httpx` | `text/html` |
| `text/html,application/xhtml+xml,*/*;q=0.8` — browser default |
`text/html` |
| `text/plain` | `text/html` |
| `text/markdown` | **`text/markdown`** |
| `text/markdown, */*` | **`text/markdown`** |
| `text/markdown;q=1.0, text/html;q=0.9` | **`text/markdown`** |

A wildcard isn't enough; the type has to be named. A client gets
Markdown only by asking deliberately, so the pointer has a real
audience.

## Config-gated

New `llms_txt_markdown_hint`, **default `False`**. Content negotiation
is a property of the host, not of the generator — a build served from
somewhere that doesn't negotiate Markdown would otherwise advertise a
representation that doesn't exist. `conf.py` sets it `True` for Ray.

## Wording note

It says "a Markdown rendering of **the page**", deliberately not "the
source". What comes back is the built page converted to Markdown — front
matter, then site chrome (`Skip to main content`, theme switcher,
version picker), then the content. That is not what
`_sources/<page>.<ext>.txt` returns, and `_sources` genuinely exists, so
calling it "the source" would point agents at the wrong artifact.

## Why not link `_sources/<page>.<ext>.txt` instead

Considered and rejected:

- **It leaks the source format to the consumer.** master is **363 `.rst`
to 232 `.md`**, so most pages would hand back reStructuredText, not
Markdown — noisier for an agent than the HTML→Markdown conversion.
- **The URL isn't derivable from the page URL** — it depends on each
page's source suffix (`index.md.txt` vs `installation.rst.txt`).
- **It isn't human-clickable.**
- **It would churn.** As pages migrate to MyST, each link would change
from `.rst.txt` to `.md.txt`. Negotiation happens on the rendered HTML,
so it's identical for both source formats and survives the migration.
- **It's redundant** — the verbatim source is already in the
`llms-full.txt` shards.

## Testing

```
$ python doc/source/_ext/test_llms_txt.py
PASS: llms_txt extension produced a correct index, Optional section, llms-full shards,
excludes notebooks by source type, gates the Markdown pointer, and honors the llms_txt_build gate.

$ ruff check doc/source/_ext/llms_txt.py doc/source/_ext/test_llms_txt.py
All checks passed!
```

New `test_markdown_hint` covers both directions: the pointer appears in
the header (asserted to sit before the first `##` section) when the
config is on, and is absent when it's off. The header table above was
produced by probing the live `docs.ray.io`.

All three changed files route to `@ doc doc_api` under the current
`.buildkite/test.rules.txt`, so `doc: test llms.txt extension` runs on
this PR.

Not a duplicate: `gh pr list --state open` finds no other open PR
touching `llms.txt` or Markdown content negotiation.

## AI assistance

Drafted with Claude Code. The behavioural claims here (which `Accept`
values return what, which `.md` URL forms 404, the negotiated output
including page chrome) were each verified against the live site rather
than assumed.

Signed-off-by: Ronny Roland <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…per library (ray-project#64775)

## Reviewer summary

**What this does.** The per-team `X: doc tests` steps are library
example and doctest suites that live under `doc/`. They exercise library
code, not documentation quality. Today every executable doc asset emits
the blanket `doc` tag and all six teams' steps are tagged `doc`, so a
one-library doc change starts every team's step. This gives each step a
dedicated `<lib>_doc` tag, routes `doc/source/<lib>/**` to the owning
library's tag, renames the steps to `X: docs example tests`, and leaves
`doc` for documentation validation (the build and the Vale/config
infra). The library tag stays on each step, so a library **code** change
runs its doc example tests exactly as before.

**What's verified.**

| Claim | Evidence |
|---|---|
| Each path emits exactly the intended tag, and no other | `test-rules`
green on this PR. That's the pinned `rayci` binary replaying all 103
`test.rules.test.txt` assertions (up from 57 on master) with **exact set
equality**, so each case also proves the blanket `doc` tag does *not*
come along. |
| The emitted tags resolve to the intended steps, and only those |
Generated the real pipeline locally with the pinned `rayci v0.46.0`
release binary for a one-file Serve doc-example change, before and after
this branch. Output below. |
| The renamed steps still run and pass | All five plus the GPU and dask
siblings green on this PR, selected via the library tags this change
preserves. |
| Every executable target under `doc/` routes to a step that can
actually select it | Swept all 948 (file, target) claims against the
per-team `team:` / `--only-tags` / `--except-tags` filters. One
deliberate exception (`doc/test_myst_doc.py`, below) and two
pre-existing gaps that this change doesn't create. |
| The rename doesn't reset step identity | rayci derives step IDs
positionally (`fmt.Sprintf("g%d_s%d", i, j)`, `converter.go`), not from
the label. The generated pipelines confirm it: `g16_s12`, `g16_s21`,
`g6_s22`, `g13_s26` are identical before and after. |

**What I need from a reviewer.**

1. **One question I can't answer from inside the repo.**
`ci/build/get_build_info.py` sets `config.env` to `"Buildkite " +
BUILDKITE_LABEL`, and `ci/build/upload_build_info.sh` uploads it on
postmerge pipelines on `master` only. Does anything downstream of that
`metadata.json` treat `config.env` as an identity or grouping key? If
it's descriptive, renaming five steps is free. If something groups on
it, those five steps' postmerge history splits at the merge commit.
Flaky-test selection and target selection both key on `team` (unchanged
here) and test identity is the bazel target name (`f"{system}:{name}"`
in `release/ray_release/test.py`), so I believe `config.env` is the only
place the label escapes.
1. **Confirm the API-check behavior change below is acceptable.**
1. **Confirm the catch-all owner.** Executable doc assets in directories
with no per-team step route to the core step: roughly 25 files, being 18
`doc/source/templates/*/start.ipynb` plus a handful under
`doc/source/cluster/doc_code/`, `doc/source/ray-contribute/doc_code/`,
and `doc/source/_templates/`. The templates majority may be retired or
externally managed, in which case a skip rule is the better answer than
core ownership.

**Known behavior change worth your eyes.** Because
`doc/source/<lib>/doc_code/` and `examples/` now emit `<lib>_doc`
instead of `doc`, the two API-surface checks (`doc: check API
annotations`, `doc: check API doc consistency`) stop running on library
doc-example changes. They carry the blanket `doc` tag among their
library tags, so today a `doc_code` edit incidentally triggers a
premerge `make -C doc/ html`. I think that's correct: those checks guard
the documented public API surface, which a doc example can't change, and
the example itself is still executed by the owning library's step while
the render is gated by Read the Docs. But it is a premerge signal that
disappears, so it should be a decision rather than a side effect. Raised
on ray-project#64812, which routes the API **reference** pages to a dedicated
`doc_api` tag for the related case.

**Out of scope, tracked separately.** `.buildkite/others.rayci.yml:13`
declares a sixth step labeled `doc tests`, running `//python/ray/...
//doc/... none --only-tags doctest` and tagged `python`, a tag no rule
in `test.rules.txt` emits. Generating the full-fan-out pipeline shows it
does get emitted (`doc tests [g14_s1]`), so it is live. After this
rename it becomes the only step in the repo still called "doc tests."
This PR doesn't touch `others.rayci.yml` and the fix is independent.

---

## What this changes

1. **Dedicated per-library tag.** Each step gets a `<lib>_doc` tag
(`core_doc`, `data_doc`, `ml_doc`, `rllib_doc`, `serve_doc`) and drops
the blanket `doc` tag. The library tag stays.
1. **Path routing.** `test.rules.txt` routes `doc/source/<lib>/**` to
that library's tag, so a doc change runs only the owning library's
example tests. LLM doc assets already route to `llm` and keep doing so.
1. **`doc` reserved for validation.** It now stays only on the
documentation build and the Vale/config infra.
1. **Rename** to `X: docs example tests`, since a failure in these steps
means library code or an example broke, not that the docs are wrong.
1. **Build-file rule fix.** `test.rules.txt` matched `doc/BUILD` and
`doc/*/BUILD`, but the files are `BUILD.bazel`, so editing a file that
*defines* the doc test targets ran no doc tests premerge. It now matches
the `.bazel` files and routes them to the same per-library steps. The
root `doc/BUILD.bazel` defines every library's targets, so it routes to
all of them.

### Scoping exceptions, and why each exists

Several paths sit under a library doc directory but can't be
meaningfully tested by that library's example step, so they're routed
explicitly rather than by directory:

- **Static images skip entirely.** Image extensions sit on the leading
skip rule, ahead of the per-library rules, so a `.png` or `.svg` edit
triggers nothing. 310 tracked image files. `.yaml` and `.sh` stay
routed, since unlike an image they can change what a test does.
- **Sphinx build machinery routes to `doc`.** `conf.py` imports
`custom_directives`, `api_autogen`, `api_mock_imports`, and
`template_collections`; none was listed in the validation-infra rule, so
all fell to the `doc/*.py` catch-all and emitted `core_doc`, running Ray
Core's doctests for a docs-build-machinery edit. Those four plus
`preprocess_github_markdown` and the doc-root build helpers now route to
`doc`. They're enumerated one per line on purpose: `*` is fnmatch here
and crosses `/`, so a `doc/source/*.py` pattern would also swallow every
example script under `doc/source/<lib>/doc_code/`. There's a comment on
the rule saying so.
- **Gallery configs route to `doc`.**
`doc/source/{data,serve,train}/examples.yml` are parsed by
`custom_directives.py` (`EXAMPLE_GALLERY_CONFIGS`) to generate the
gallery pages. They hold no executable code and can't change what any
example does. Narrowed to a three-path exception rather than a blanket
`.yml` skip, because a sibling `.yml` under a library doc directory can
be a config an example consumes.
- **`doc/.claude/` triggers nothing.** Agent files never participate in
the Sphinx build and define no test targets, but
`doc/.claude/skills/sphinx-fix/sphinx_fix.py` matched the `doc/*.py`
catch-all. The Read the Docs build guard already excludes this exact
path for the same reason, so the two guards now agree. Pre-existing
rather than a regression from this PR: on master the file emits the
blanket `doc` tag, which reaches all five per-team steps.
- **Four `team:ml` notebooks under `ray-core/` route to `ml_doc`.**
`plot_hyperparameter`, `batch_prediction`, `plot_parameter_server`, and
`plot_pong_example` live under `doc/source/ray-core/examples/` but their
targets are tagged `team:ml`, and the team argument to
`//ci/ray_ci:test_in_docker` filters targets by `team:<team>`
(`_get_all_test_query`, `ci/ray_ci/tester.py`). Routing them to
`core_doc` would run a step that tests everything under `ray-core/`
except the file that changed. Re-tagging the four `team:core` in
`doc/BUILD.bazel` is the alternative fix and would let the rule lines go
away.
- **`highly_parallel.ipynb` routes to `doc`.** Its `py_test` carries a
`highly_parallel` tag that the ml docs example step excludes, and the
notebook glob in `doc/source/ray-core/examples/BUILD.bazel` excludes it
too, as a release test needing a live multi-node cluster. The remaining
ml `//doc/...` steps select `gpu` / `train_v2_gpu` and the target has
neither, so no premerge step executes it. Routing to `doc` means the
build renders it (`nb_execution_mode` defaults to `off`, so
render-and-lint only), which is the only validation premerge offers
here.
- **`doc/external/` routes to `ml_doc`.** Its `test_external_hashes`
target is tagged `team:ml`; it had fallen through the `doc/*.py`
catch-all to `core_doc`, where the core step's `team:core` query never
sees it.
- **The `llms.txt` files route to `doc`.** ray-project#64458 adds
`doc/test_llms_txt.py` and `doc/source/llms_txt_summary.txt` with no
`test.rules.txt` change. Left alone the test would land on the
`doc/*.py` catch-all and emit `core_doc`, running Ray Core's doctests
for a test its own docstring describes as hermetic, while never running
the step that executes it. Rules for absent paths are inert, so there's
no ordering dependency: this PR doesn't touch `doc.rayci.yml`, ray-project#64458
doesn't touch `test.rules.txt`, and whichever lands first the other
merges correctly scoped.
- **Declined:** fanning `doc/test_myst_doc.py` out to all five
`<lib>_doc` tags. It backs 19 targets across every team, but it's shared
infrastructure, so a break surfaces in core as readily as anywhere. One
library's worth of execution is a sufficient smoke signal and the
post-merge build covers the rest. The rule carries a comment recording
that trade and when to revisit it.

### Effect on a doc-only PR (no `docs-go`)

| Change | Before | After |
|---|---|---|
| A Serve doc example | every team's `doc tests` step | `serve: docs
example tests` and its GPU sibling |
| A Data doc example | every team's `doc tests` step | `data: docs
example tests`, plus the dask and GPU siblings |
| An image under a library doc dir | that library's example step |
nothing |
| A Sphinx build module (`custom_directives.py` etc.) | `core: docs
example tests` | `doc: build` only (post-merge) |
| A gallery config (`examples.yml`) | that library's example step |
`doc: build` only (post-merge) |
| Editing `doc/BUILD.bazel` | nothing (rule was dead) | the doc example
steps it defines |
| The two `doc: check API*` checks | ran, via the blanket `doc` tag |
don't run (see reviewer summary) |

The GPU and dask siblings carry `<lib>_doc` too, and tag matching is a
non-empty intersection, so they're selected alongside the main step.
That's unchanged behavior: they carried the blanket `doc` tag before, so
a doc change already started them. No new GPU cost.

## Verification

**Rule conformance, under the authoritative evaluator.** `test-rules` is
green on this PR. It replays all 103 `test.rules.test.txt` assertions
through the pinned `rayci` binary, and `runTestRules` compares the full
computed tag set per path, so every case is also a negative assertion
that no other tag fires.

**Tag-to-step resolution, generated locally.** The tag set isn't the
step set: rayci filters steps by tag, then `markDeps` pulls in
everything reachable through `depends_on` regardless of that step's own
tags. To confirm the composition rather than infer it, I ran the pinned
`rayci v0.46.0` release binary against a one-file Serve doc-example
change, on master and on this branch:

```
before (base=master)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always doc lint
  doc-related steps emitted:
    core: doc tests [g6_s22]             ml: doc tests [g13_s26]
    data: doc tests [g7_s21]             rllib: doc tests [g15_s8]
    data: dask doc tests [g7_s22]        serve: doc tests [g16_s12]
    data: doc gpu tests [g7_s23]         serve: doc gpu tests [g16_s21]
    doc: check API annotations [g9_s3]   doc: check API doc consistency [g9_s4]

after (this branch)
  changed files: [doc/source/serve/doc_code/app_builder.py]
  selected tags: always lint serve_doc
  doc-related steps emitted:
    serve: docs example tests [g16_s12]
    serve: docs example gpu tests [g16_s21]
```

Six teams' example steps collapse to the owning team's two, and the step
IDs are unchanged across the rename.

**Routing versus coverage.** Correct routing isn't sufficient: the step
that starts still has to select the target. `ci/ray_ci/tester.py`
filters by `attr(tags, 'team:<team>')`, then intersects `--only-tags`
and subtracts `--except-tags`, so a change can route perfectly, start
the right-looking step, and be invisible to every command in it. I swept
all 948 (file, target) claims under `doc/` against the per-team filters.
After the exceptions above, the only deliberate team mismatch left is
`doc/test_myst_doc.py`. Two pre-existing gaps fell out, neither created
by this change:

- **GPU-tagged ml and core doc examples have no owning step** — six
`team:ml` notebooks tagged `gpu`, five `team:core` `doc_code` modules
tagged `multi_gpu`, and one `post_wheel_build` module. `data` and
`serve` each have a GPU doc-example step; ml and core never got one, so
the only steps that would run these are gated on `train_gpu` and
`cgraphs_direct_transport`, which no doc path emits. No `doc`-tagged
step ran them before the split either. This needs a REEf and
library-team decision rather than a rules change.
- **Prose doctests aren't triggered by prose edits.** The
`doc/BUILD.bazel` `doctest` targets over `doc/source/**/*.{md,rst}` are
reachable only from the `others.rayci.yml` step gated on `python`, while
prose paths hit the leading skip rule. Roughly 700 files. I consider
this correct as-is: given current coverage the Read the Docs render
build is the gate a prose change needs.

**Also swept** all 1,628 tracked `doc/` files against the previous rules
to confirm exactly which paths changed routing and that nothing else
moved.

## Change log

Consolidated above; kept here so the review history stays legible.

- `6a1310d3b5` — the split: per-library tags, path routing, rename,
`BUILD.bazel` rule fix.
- `c6302c8a21`, `b1d03629cf` — first bot-review pass: static images
skip; Sphinx build modules route to `doc`.
- `99c3af2c28` — pre-route the `llms.txt` extension test and summary
ahead of ray-project#64458.
- `3795c6161b` — skip `doc/.claude/`; route the `team:ml` `ray-core`
notebooks to `ml_doc`.
- `e88e8a4b52` — remove a stray `TEMP(do-not-merge)` marker that reached
master with ray-project#65040. Inert, and independent of this PR's thesis; happy to
split it out.
- `f8347baf54` — second bot-review pass: gallery configs to `doc`;
correct `highly_parallel.ipynb` to `doc`.
- `6a050a0511` — route `doc/external/` to `ml_doc` so the hash guard
still runs.

## AI assistance

This change was drafted with AI assistance (Claude Code) and reviewed by
me.

---------

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

## Summary

Completes the page-description work
[ray-project#64330](ray-project#64330) started, so that
**every page listed in `llms.txt` carries a curated description**.

ray-project#64330 (merged) described the 94 pages that made up the index when it
listed only each section's landing page plus its direct toctree
children. The generator in
[ray-project#64458](ray-project#64458) makes the index
complete — every in-scope page under its section — so the index now
carries ~630 entries, and the ~400 that ray-project#64330 didn't cover fall back to
a truncated first paragraph.

That fallback is often actively bad for an agent routing on it. Of the
397 undescribed pages:

| Fallback problem | Pages | Example |
|---|---:|---|
| No paragraph at all | 22 | `cluster/kubernetes/troubleshooting` |
| Pointer prose | 34 | `cluster/cli` → "This section contains commands
for managing Ray clusters." |
| Restates the title | 117 | every `ray-core/patterns/*` anti-pattern
page |
| Under 70 chars | 170 | `data/inspecting-data` → "Inspect Datasets to
better understand your data." |

## Changes

- **368 pages get a curated description**, following the convention
ray-project#64330 established: `myst: html_meta: description:` front matter for
`.md` (164 files), and a `.. meta::` directive for `.rst` (204 files).
The `.rst` block is placed after any leading docinfo field list
(`:orphan:` and friends) but **before** any `.. _label:` target, so the
label still resolves to the section title.
- **31 pages are excluded instead** (`conf.py`). These are thin
API-reference hub pages — a title plus an autosummary table, under 40
words of real prose — whose per-symbol targets are already excluded by
the existing `*/api/doc/*` patterns. Also `data/api/_autogen` (no title
at all) and two `*_regression_example` literalinclude stubs with zero
prose. A description on any of these could only restate its title.

Style follows the same house rule as ray-project#64330: 130–150 characters,
front-loading what distinguishes the page, no "Ray X is a…" restatement
of the link title. Mean length 122 chars, none over 160.

Substantial API-reference pages were **kept and described**, not
excluded — `tune/api/schedulers` (965 words of prose), `tune/api/env`,
`tune/api/trainable`, `serve/api/index`, `data/api/expressions` are
exactly what a coding agent wants.

**Result: 479 in-scope pages described, 31 excluded, 0 relying on
first-paragraph fallback.**

## Relationship to other PRs

Independent of **ray-project#64458** (the generator). Descriptions are page front
matter and work with the current third-party `sphinx-llms-txt` on master
as well as the in-repo generator. The one file both touch is
`doc/source/conf.py`: this PR appends a `llms_txt_exclude += [...]`
block below the existing list rather than editing the list literal,
which is what ray-project#64458 rewrites, so the two shouldn't collide. Either can
merge first.

Not a duplicate: `gh pr list --state open` finds no other PR adding page
descriptions or `html_meta` blocks. ray-project#64330, the only prior art, is
merged.

## Rebased on master

Merged master to clear a conflict. Two pages shifted:

- `cluster/kubernetes/user-guides/kuberay-history-server.md` no longer
appears in this diff. ray-project#65139 described that page independently while
this branch was open, and its description is the better one: this
branch's scoped the page to GKE and Google Cloud Storage, where master's
covers RayCluster, RayJob, and RayService, which is the page's actual
scope. Resolved in favor of master.
- `ray-observability/user-guides/jax-tpu-profiling.md` is newly
described. It landed on master after this branch was cut and was the one
in-scope page still falling back to a truncated first paragraph.

Net file count is 368 newly described pages plus `conf.py`, plus one
re-key:
`ray-core/scheduling/labels.md` carried a bare top-level `description:`
in its front matter, the only such file in the tree. Sphinx emits no
meta description from that key, so despite looking described the page
fed neither the HTML meta tag nor `llms.txt`. The text is unchanged;
only the key moves under `myst.html_meta`. That page was already counted
as described, so the totals above don't move.

## Testing

Local verification (no Ray build required — these are doc source edits):

```
$ python3 doc/test_no_new_rst.py                       # exit 0 (no new .rst files; all 204 are edits)
$ vale doc/source/data doc/source/ray-overview/examples
  174 alerts, 0 error-level, 0 on the added lines
  identical to the master baseline (174 alerts) — this change adds no Vale alerts
$ python3 -c "import ast; ast.parse(open('doc/source/conf.py').read())"   # conf.py parses
```

Plus scripted checks over all 370 changed files:

- All 164 `.md` front-matter blocks parse as YAML and expose
`myst.html_meta.description`.
- All 204 `.rst` files: `.. meta::` precedes any `.. _label:`, and any
docinfo field list still precedes the `.. meta::` block.
- Re-running the in-scope inventory: 510 pages, 479 described, 31
excluded, **0 gaps**.
- The 31 entries added to `llms_txt_exclude` match the computed exclude
set exactly.

The `-W` docs build is the real end-to-end gate and runs in CI here.

## AI assistance

Drafted with Claude Code: the descriptions were generated from each
page's title, headings, and lead prose, and applied by script. Per
`AGENTS.md`, this needs a human pass over the content before it's ready
for review — **opening as a draft for that reason**. The mechanical
placement is verified by the checks above; what needs human eyes is
whether each description is accurate and useful for its page.

---------

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

## Summary

Replaces the third-party
[`sphinx-llms-txt`](https://github.com/jdillard/sphinx-llms-txt) with a
small in-repo Sphinx extension (`doc/source/_ext/llms_txt.py`, alongside
`callouts.py` / `queryparamrefs.py`) that generates
**navigation-structured** agent manifests instead of one flat list.

Three tiers, emitted into the HTML build output:

- **`/llms.txt`** — index: H1 + summary, one `## Section` per top-level
`toctree` entry of the root doc. Each section lists its landing page and
every in-scope page in the subtree beneath it as `- [title](url):
description`, deduped so a page appears only under the first section
that reaches it, so an agent can locate any page from the index without
drilling into the corpus. A page the nav toctrees never reach (an
example linked only from a gallery grid, say) folds into the section
owning its top-level directory; only pages whose directory maps to no
section land in a trailing `## Other pages`. Sections in
`llms_txt_optional_sections` move to a trailing `## Optional` block.
- **`/<section>/llms-full.txt`** — verbatim page source per section,
behind a `## Contents` TOC (which also surfaces deep pages absent from
the index). A section whose source exceeds
`llms_txt_full_max_shard_tokens` (default **200K**, ~4 chars/token) is
split recursively into per-subdirectory sub-shards, so each loadable
unit fits an agent's context budget.
- **`/llms-full.txt`** — a manifest linking every shard (sub-shards
nested under their parent), each with a description and page count, so
an agent routes without downloading.

Descriptions resolve from front-matter/docinfo `description` → an
`html_meta` / `.. meta::` node → a first-paragraph fallback.

## Why not a single `llms-full.txt`

Ray's full corpus is ~1.14M tokens — too large to load whole on most
models, and truncating it (what `sphinx-llms-txt`'s size knobs do) just
yields an arbitrary lossy prefix. Peer projects all ship a single flat
file and none cap; sharding by section keeps every unit independently
loadable.

### Note for existing `llms-full.txt` consumers

This changes what `/llms-full.txt` serves at a stable URL. Today it's
~5.9 MB of concatenated page text; after this it's a small manifest
linking the per-section shards. Anything pointed at that URL expecting
full text should follow the manifest to the shard it needs instead.

## Changes

- New `doc/source/_ext/llms_txt.py` + hermetic test
`doc/source/_ext/test_llms_txt.py`.
- `conf.py`: swap `sphinx_llms_txt` → `llms_txt`; add `llms_txt_title`,
`llms_txt_optional_sections`, `llms_txt_full_max_shard_tokens` (keeps
the existing `llms_txt_summary` / `llms_txt_exclude`).
- Remove `sphinx-llms-txt==0.7.1` from `requirements-doc.txt` and the
docs lock (`python/deplocks/docs/docbuild_depset_py3.11.lock`; clean
leaf removal — `raydepsets --check` consistent).
- New premerge step `doc: test llms.txt extension` in
`.buildkite/doc.rayci.yml` (runs in the `docbuild-py3.11` env, since the
test needs sphinx + myst).

## Forward-compatibility

Written for the in-flight Sphinx 8→9 upgrade: `findall` (not
`traverse`), `root_doc` (not `master_doc`), defensive `getattr` env
access, `docutils.nodes.meta`, and all work in `build-finished`
(parallel-safe).

## Testing

- `doc/source/_ext/test_llms_txt.py` — hermetic in-process Sphinx build
covering all three description sources, exclusion, the `## Optional`
section, sub-shard splitting, and the nested manifest. Passes on the
pinned stack (Sphinx 8.2.3 / MyST 5.1.0 / docutils 0.21.2).
- The full `-W` docs build validates end-to-end in CI here.

## Relationship to ray-project#64330

Independent of [ray-project#64330](ray-project#64330)
(which adds the per-page `<meta name="description">` descriptions) —
zero file overlap, mergeable in either order. Where a page has no
curated description yet, the generator uses its first paragraph, so
output is sensible regardless.

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

---------

Signed-off-by: Ronny Roland <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Douglas Strodtman <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…roject#65461)

## Summary

Follow-up to ray-project#64458. Adds one line to `llms.txt` telling agents that the
page links also serve Markdown.

Read the Docs serves a Markdown rendering of any page **from that page's
own `.html` URL**, under an `Accept: text/markdown` request. There is no
separate `.md` file to link to — `page.md`, `page.html.md`,
`/md/<page>.md`, and `?format=md` all 404, and no `Link: rel=alternate`
header advertises one.

So the `.html` links `llms.txt` already emits *are* the Markdown links.
Nothing in the file says so, and an agent has no way to discover it.

```
# Ray

> Ray is an open-source unified compute framework for scaling AI and Python workloads…

Full page text, grouped by section, is in [llms-full.txt](https://docs.ray.io/en/master/llms-full.txt).

Request the links that follow with the HTTP header `Accept: text/markdown` to retrieve a Markdown rendering of the page.

## Overview
…
```

## The header has to be explicit

Measured against `docs.ray.io/en/master/data/data.html`:

| `Accept:` sent | returns |
|---|---|
| `*/*` — the default for curl, `requests`, `httpx` | `text/html` |
| `text/html,application/xhtml+xml,*/*;q=0.8` — browser default |
`text/html` |
| `text/plain` | `text/html` |
| `text/markdown` | **`text/markdown`** |
| `text/markdown, */*` | **`text/markdown`** |
| `text/markdown;q=1.0, text/html;q=0.9` | **`text/markdown`** |

A wildcard isn't enough; the type has to be named. A client gets
Markdown only by asking deliberately, so the pointer has a real
audience.

## Config-gated

New `llms_txt_markdown_hint`, **default `False`**. Content negotiation
is a property of the host, not of the generator — a build served from
somewhere that doesn't negotiate Markdown would otherwise advertise a
representation that doesn't exist. `conf.py` sets it `True` for Ray.

## Wording note

It says "a Markdown rendering of **the page**", deliberately not "the
source". What comes back is the built page converted to Markdown — front
matter, then site chrome (`Skip to main content`, theme switcher,
version picker), then the content. That is not what
`_sources/<page>.<ext>.txt` returns, and `_sources` genuinely exists, so
calling it "the source" would point agents at the wrong artifact.

## Why not link `_sources/<page>.<ext>.txt` instead

Considered and rejected:

- **It leaks the source format to the consumer.** master is **363 `.rst`
to 232 `.md`**, so most pages would hand back reStructuredText, not
Markdown — noisier for an agent than the HTML→Markdown conversion.
- **The URL isn't derivable from the page URL** — it depends on each
page's source suffix (`index.md.txt` vs `installation.rst.txt`).
- **It isn't human-clickable.**
- **It would churn.** As pages migrate to MyST, each link would change
from `.rst.txt` to `.md.txt`. Negotiation happens on the rendered HTML,
so it's identical for both source formats and survives the migration.
- **It's redundant** — the verbatim source is already in the
`llms-full.txt` shards.

## Testing

```
$ python doc/source/_ext/test_llms_txt.py
PASS: llms_txt extension produced a correct index, Optional section, llms-full shards,
excludes notebooks by source type, gates the Markdown pointer, and honors the llms_txt_build gate.

$ ruff check doc/source/_ext/llms_txt.py doc/source/_ext/test_llms_txt.py
All checks passed!
```

New `test_markdown_hint` covers both directions: the pointer appears in
the header (asserted to sit before the first `##` section) when the
config is on, and is absent when it's off. The header table above was
produced by probing the live `docs.ray.io`.

All three changed files route to `@ doc doc_api` under the current
`.buildkite/test.rules.txt`, so `doc: test llms.txt extension` runs on
this PR.

Not a duplicate: `gh pr list --state open` finds no other open PR
touching `llms.txt` or Markdown content negotiation.

## AI assistance

Drafted with Claude Code. The behavioural claims here (which `Accept`
values return what, which `.md` URL forms 404, the negotiated output
including page chrome) were each verified against the live site rather
than assumed.

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

Labels

core Issues that should be addressed in Ray Core docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants