Repository navigation
[ci/doc] Treat __all__ membership as public in the API-doc resolve check - #65340
Conversation
The API-doc consistency check classifies a documented name as non-public when its canonical name resolves under a private module, keying on the `._internal.` segment. Several public Ray Data APIs are re-exported into `ray.data.__all__` while their implementation lives in `_internal`, so the heuristic flags names that are legitimately public and correctly documented. Those names were suppressed with a per-team `doc_only_whitelist` -- a list that had to grow by one entry every time a team re-exported another API. Read the export instead. A name the documented module declares in its `__all__` is public regardless of where the implementation lives, so `API._is_public_reexport` exempts it from the private-name rule and the list goes away. The exemption is deliberately narrow, so genuinely private symbols stay flagged: - Only a public module's `__all__` counts. A name documented through a private path keeps its verdict; a private module's `__all__` is not a public contract. - An underscore leaf stays private on either side of the re-export. - Module-attribute reachability alone changes nothing. Absent an explicit `__all__` entry the verdict is unchanged. This retires all seven `doc_only_whitelist` entries on the data team config (six `ray.data` re-exports plus the `ray.data.llm` Processor). RLlib's `doc_only_whitelist` is a different case -- instance attributes assigned in `setup()` that never resolve -- and is untouched. Adds a private mock subpackage as the fixture and unit coverage for the re-export case, the private-path spelling of the same object, and the negative control: a class importable from the same public module but absent from its `__all__`. Signed-off-by: Douglas Strodtman <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to automatically recognize public re-exports of private implementations, avoiding false positives in the API discrepancy check. Specifically, it adds the _is_public_reexport helper to verify if a documented name is listed in its parent module's __all__ attribute, and updates the resolve check to exempt these cases, allowing the removal of the hardcoded doc_only_whitelist. Feedback was provided on ci/ray_ci/doc/api.py regarding potential runtime exceptions during dynamic module imports and __all__ validation. It is recommended to catch a broader range of exceptions and explicitly verify that __all__ is a valid collection (list, tuple, or set) before checking membership.
Review feedback. `__all__` is conventionally a list or tuple of names, but nothing enforces that, and the membership test read whatever the attribute held. A bare string would match a substring and silently exempt a symbol nobody exported; `None` would raise. Neither is a declaration worth reading, so require a list, tuple, or set. Both the list and the tuple spelling are accepted: 45 modules under python/ray declare `__all__` as a tuple, so a list-only guard would have broken the very re-exports this check is meant to recognize. Signed-off-by: Douglas Strodtman <[email protected]>
Empty commit. The prior build was a UI rebuild, which replays the triggering webhook's label snapshot, so it still saw a 'docs-go' label that had already been removed and ran the scope guard that label gates. A rebuild can't observe the removal and the pipeline skips label-change builds for an already-built commit, so a new commit is the only way to get a build that reads current labels. Signed-off-by: Douglas Strodtman <[email protected]>
|
Recording a known limitation of this change for whoever reads it next. Not a request to change anything here — the scope below is deliberate, and I'd rather this land as reviewed than grow. What this trades away. Retiring the whitelist in favor of a rule is the right move: the exemption is now earned by an explicit That's a deliberate trade, not an oversight, and it's worth stating plainly so nobody later mistakes the absence of a list for the absence of the pattern. Where it's tracked. The follow-up is to have the check emit the set of names That follow-up is deliberately not bundled here, for two reasons. It should be designed once across the checks that need it rather than bespoke for this rule, since One scope clarification for anyone arriving here from the Serve request-router discussion: this change is scoped to the resolve check, as the description says, so it doesn't affect the |
…documentation content in the docs-go scope guard (#65342) ## Why this change is needed `ci/lint/validate_docs_go_scope.sh` fails any pull request carrying the `docs-go` label if a changed file lives outside `doc/`. Two kinds of documentation work live outside `doc/` and are therefore locked out of the label today: - **Ray's Vale configuration** (`.vale.ini`, `.vale/`) sits at the repository root, so a PR that adds or edits a prose-lint rule can never carry the label even though it is documentation content by any reasonable reading. Concretely: #65239 adds KubeRay style rules and edits `doc/source/ray-contribute/writing-style.md`. Its [premerge build](https://buildkite.com/ray-project/premerge/builds/71732) has exactly one failing job, `lint: validate docs-go scope`. Every other check passes. - **The API-consistency checker's own source** (`ci/ray_ci/doc/`) is the tooling behind the `doc: check API doc consistency` step. Same shape: #65340 changes only that directory, and the label's guard is the sole red job on its [premerge build](https://buildkite.com/ray-project/premerge/builds/71727). In both cases the author's options today are to drop the label and wait on per-library example suites the PR cannot possibly affect, or to split a coherent change across two PRs. ## What changed Widen the guard's in-scope set from "under `doc/`" to "under `doc/`, the Vale prose-lint configuration (`.vale.ini`, `.vale/`), or the API-consistency checker (`ci/ray_ci/doc/`)". Both fail-closed paths (no merge-base, empty diff) are unchanged, and the `BUILD`-file exclusion now applies uniformly across the whole in-scope set rather than just `doc/`. Also updates the two places that state the predicate in prose, so they don't drift from the script: the `docs-go` section of `doc/source/ray-contribute/ci.md`, and `doc/.claude/CLAUDE.md`. ## Why this is safe The guard exists so `docs-go` can skip the 12 per-library docs example and llm test steps only on a PR that could not break them. The two additions clear that bar on different grounds, which is worth stating separately rather than blurring into one rule. **The Vale configuration** clears it on content: - **It defines no bazel target.** The separate `BUILD`-file exclusion is the mechanism that protects test targets, and it stays intact. - **It holds no executable Ray code**, so no doctest or example can change behavior because of it. - **The check that consumes it already runs unconditionally.** `lint: documentation_style` sits in the `lint-small-prose` matrix in `.buildkite/lint.rayci.yml` carrying `always`, which `always.rules.txt` emits for every changed file. Vale therefore runs on every pull request whether or not the label is present. - **No premerge step is traded away.** `test.rules.txt` already routes `.vale.ini` and `.vale/` to `doc` alone, in the rendering-and-validation-only block. That tag reaches `doc: build`, which carries `skip-on-premerge`. **The checker source** is executable CI code, so the reasoning above does not apply to it. It clears the bar on tag routing: - **`test.rules.txt` routes `ci/ray_ci/doc/` to `doc_api tools` and nothing else**, ahead of the broad `ci/ray_ci/` rule, and first match wins. - **Every step the label skips carries a library tag instead** — `core_python`, `data`, `llm`, `train`, `tune`, `rllib_directly`, `serve`, and the `*_doc` tags. A change confined to this directory never emits a tag that selects one of them. Since the label's `if:` can only suppress an already-emitted step, there is nothing for it to take away. - **Measured on the same commit, with and without the label.** #65340 was built twice: [71727](https://buildkite.com/ray-project/premerge/builds/71727) carried `["go", "docs-go"]` and [71736](https://buildkite.com/ray-project/premerge/builds/71736) carried `["go"]`. Both emitted the same 33 jobs, and diffing the two job-name sets yields no difference in either direction. The label's only effect on such a PR is whether this guard itself is emitted: it ran and failed in the first build, and was `broken` (never emitted) in the second. That is the claim above, observed rather than derived. - **The checks that do cover the directory are ungated.** The `doc_api` API checks and the `tools` job running this directory's six `ci_unit` py_test targets both run with the label present. Build 71727 is the direct evidence: it carried `docs-go` and ran `doc: check API annotations`, `doc: check API doc consistency`, and all six `//ci/ray_ci/doc:*` targets, all green. - **`BUILD` files stay excluded**, so a change to this directory's test targets still fails the guard. #65340 is exactly that case: it adds a `py_test` src, so it would still not qualify for the label after this change. That is the intended outcome. Each list is deliberately narrow. For Vale it covers the prose rules, not the CI wiring that runs them: `ci/lint/check-documentation-style.sh` and the Vale hook in `.pre-commit-config.yaml` stay out of scope, because a change to either one alters what actually runs. For the checker it covers `ci/ray_ci/doc/` only, not the shared `ci/ray_ci/` tooling that every bazel test step runs through. ## Two corrections on the same surface - **The script's header comment claimed the label skips the API consistency checks.** It doesn't. `doc.rayci.yml` leaves them deliberately ungated, precisely because an API reference page edit is the content-only change they must cover, and build 71727 confirms both ran under the label. `ci.md` already described this correctly, so only the script was wrong. - **The failure message advised an action that cannot work.** It said "Remove the 'docs-go' label so the appropriate tests run," but removing the label cannot produce a corrected build on the same commit. A Buildkite rebuild replays the label set from the build it was rebuilt from, and the pipeline sets `skip_pull_request_builds_for_existing_commits`, so the `unlabeled` event on an already-built commit produces no build at all. Verified on #65340: `docs-go` was removed at 19:59:30Z, build 71727 was created at 20:00:03Z as a UI rebuild, and its payload still carried `["go", "docs-go"]`. The message and both prose surfaces now say to remove the label *and push a new commit*. ## Checks - [x] I've signed off every commit (`git commit --signoff`). - [x] I've made sure the tests are passing. - Testing Strategy - [x] Manual tests `shellcheck` is clean. The guard was exercised end to end against a controlled base in a scratch repository, 15 cases — the 7 from the Vale-only version, unchanged, plus 8 for the new path: | Changed files | Expected | Result | | --- | --- | --- | | `.vale.ini` + `.vale/styles/**` + a `doc/` page (the #65239 shape) | pass | pass | | `.vale/styles/**` alone | pass | pass | | a `doc/` page alone (behavior before this change) | pass | pass | | `.vale/styles/**` + a file under `python/ray/` | fail | fail, names the Python file | | `.vale/BUILD.bazel` | fail | fail, names it as a `BUILD` file | | `ci/lint/check-documentation-style.sh` | fail | fail | | `.pre-commit-config.yaml` | fail | fail | | `ci/ray_ci/doc/api.py` alone | pass | pass | | `ci/ray_ci/doc/api.py` + a `doc/` page | pass | pass | | `ci/ray_ci/doc/mock/_internal/__init__.py` | pass | pass | | `ci/ray_ci/doc/BUILD.bazel` (the #65340 shape) | fail | fail, names it as a `BUILD` file | | `ci/ray_ci/doc/api.py` + a file under `python/ray/` | fail | fail, names the Python file | | `ci/ray_ci/tester.py` (shared tooling, not the checker) | fail | fail | | `ci/ray_ci/docker/**` (sibling path) | fail | fail | | `doc/BUILD.bazel` | fail | fail, unchanged behavior | Note that this PR itself edits `ci/lint/`, so it deliberately does not carry the `docs-go` label. The label's effect on #65239 is the real confirmation, and I'll rebase that PR onto this once it lands. ## Related #64775 reserved the `doc` tag for documentation validation. The `docs-go` label and this guard arrived with the content-only escape hatch that followed. #65340 is the checker-source change that motivated the second path. --------- Signed-off-by: Douglas Strodtman <[email protected]>
## Why `python/ray/serve/request_router.py` re-exports the public request-router extension surface, but declares it implicitly through `# noqa: F401` imports rather than explicitly through `__all__`. This declares it. The seven names are each decorated `@PublicAPI(stability="alpha")` at their definition site and documented in the Serve API reference at `doc/source/serve/api/index.md` under their `serve.request_router.*` path. `doc/source/serve/advanced-guides/custom-request-router.md` and its `doc_code/custom_request_router.py` teach users to import from this module. So the change records an existing contract rather than creating a new one. It also makes the surface visible to the API-doc consistency check. `API._is_public_reexport()`, added in #65340, treats a name in a public module's `__all__` as public regardless of where its implementation lives, but it requires an *explicit* `__all__` entry, which this module didn't have. ## Coordination This is a small mechanical change, so per `AGENTS.md` it's worth saying it was coordinated rather than volunteered. It follows from a ruling Richard Liaw gave on Ray's API location policy: a private definition re-exported through a public module's `__all__` is compliant, and the test that matters is whether users have to import a private package. Declaring the surface here is the fix that ruling implies. Happy to close this if the Serve team would rather handle the module differently. ## `ReplicaResult` is deliberately excluded It's the one name in the file left out of `__all__`, because unlike the other seven it carries no API annotation (`class ReplicaResult(ABC)`, no decorator) and has no reference-page entry. Including it would newly assert a public contract instead of recording one. Its import keeps an F401 suppression since the re-export is still in use. **This is the one judgment call in the PR and it's yours to make.** If Serve considers `ReplicaResult` part of the public extension surface, say so and I'll add it. `PowerOfTwoChoicesRequestRouter` is out of scope: it's absent from both this module's re-exports and the autosummary, so it needs a separate decision. ## Removing the per-import suppressions The seven declared names lose their `# noqa: F401` comments. A name listed in `__all__` counts as used, so pyflakes and ruff no longer flag it. `ReplicaResult` keeps its suppression. ## Testing Verified statically: - `ruff check python/ray/serve/request_router.py` — passes. - `black --check` and `ruff format --check` — already formatted. - Full `pre-commit run` on the changed file — all applicable hooks pass (ruff, black, pydoclint, docstyle, import order, semgrep). - Confirmed the declared `__all__` is exactly the set of seven names in the `serve.request_router.*` autosummary block, with no extras and nothing missing. **Not verified locally: `api_policy_check`.** It needs a Ray build, and master's Python source doesn't import against a released binary, so I'm relying on CI for that check rather than claiming a local run. The expected effect is on the resolve check only. I'm specifically *not* claiming this clears the `tracked_doc_debt` entries for these symbols: those fail the must-be-documented check, which #65340 explicitly left untouched. If CI shows any of them can drop, I'll follow up separately rather than bundling it here. ## Duplicate check No open PR touches `python/ray/serve/request_router.py`. #65410 (`[serve] Enforce type checking on the scheduling/routing modules`) touches `_private/request_router/request_router.py` but not this module, so no conflict. ## AI assistance AI-assisted, per `AGENTS.md`: the analysis and the patch were drafted with Claude Code, and I reviewed every changed line. Signed-off-by: Douglas Strodtman <[email protected]>
…eck (ray-project#65340) ## Why this change is needed The API-doc consistency check (`ci/ray_ci/doc/`) classifies a documented API as non-public when its canonical name resolves under a private module, keying on the `._internal.` segment in `API._is_private_name()`. Several public Ray Data APIs are re-exported into `ray.data.__all__` while their implementation lives in `_internal`, so the heuristic flags names that are legitimately public and correctly documented. Those false positives were suppressed with a per-team `doc_only_whitelist` — a hand-maintained list that had to grow by one entry every time a team re-exported another API from a private module. ## What this change does Reads the export instead of guessing from the path. A name that the documented module declares in its `__all__` is public regardless of where its implementation lives, so the new `API._is_public_reexport()` exempts it from the private-name rule and the list goes away. The exemption is deliberately narrow, so genuinely private symbols stay flagged: - **Only a public module's `__all__` counts.** A name documented through a private path (`ray.data._internal.foo.Bar`) keeps its verdict — a private module's `__all__` is not a public contract. - **An underscore leaf stays private** on either side of the re-export. `__all__` membership can never promote a `_foo` name. - **Module-attribute reachability alone changes nothing.** Absent an explicit `__all__` entry, the verdict is unchanged. Scope is limited to the resolve check's non-public classification (`split_resolvable_and_broken_doc_apis`). The "every `@PublicAPI` must be documented" check and the duplicate-documentation check are untouched, as is `API.is_public()` on the code side. ## Whitelist entries retired All seven `doc_only_whitelist` entries on the data team config: | Retired entry | Public name it's documented under | |---|---| | `ray.data._internal.compute.ActorPoolStrategy` | `ray.data.ActorPoolStrategy` | | `ray.data._internal.compute.TaskPoolStrategy` | `ray.data.TaskPoolStrategy` | | `ray.data._internal.execution.interfaces.execution_options.ExecutionOptions` | `ray.data.ExecutionOptions` | | `ray.data._internal.execution.interfaces.execution_options.ExecutionResources` | `ray.data.ExecutionResources` | | `ray.data._internal.logical.operators.n_ary_operator.MixStoppingCondition` | `ray.data.MixStoppingCondition` | | `ray.data._internal.random_config.RandomSeedConfig` | `ray.data.RandomSeedConfig` | | `ray.llm._internal.batch.processor.base.Processor` | `ray.data.llm.Processor` | Each is present in `ray.data.__all__` or `ray.data.llm.__all__`, and each is documented through its public `currentmodule` in `doc/source/data/api/`. None carries a `@Deprecated` annotation, so none relied on the whitelist for anything beyond the private-path suppression this change replaces. RLlib's `doc_only_whitelist` is a different case — instance attributes assigned in `setup()` that the import walk can't resolve — and is untouched. ## Related PRs - ray-project#64423 added the `doc_only_whitelist` workaround. - ray-project#64786 split the whitelists into permanent exemptions and tracked debt. ## Checks - [x] I've signed off every commit (`git commit --signoff`). - [x] I've made sure the tests are passing. - Testing Strategy - [x] Unit tests `ci/ray_ci/doc/test_api.py` gains coverage for the re-export case, for the same object documented through its private canonical path, and for the negative control — a class importable from the same public module but absent from its `__all__`, which must still be flagged. A private mock subpackage (`ci/ray_ci/doc/mock/_internal/`) provides the fixture so the test exercises the real `._internal.` code path rather than a spoofed `__module__`. Verified locally: the four `ci/ray_ci/doc` unit-test files pass (44 tests), and `pre-commit` is clean on the changed files. The end-to-end `api_policy_check` step needs a bazel-built Ray in the docbuild image, so the whitelist retirement is verified statically here (`__all__` membership and annotations read from source, per the table above) and premerge's `doc_api_policy_check` is the decisive check. --------- Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: 400Ping <[email protected]>
…documentation content in the docs-go scope guard (ray-project#65342) ## Why this change is needed `ci/lint/validate_docs_go_scope.sh` fails any pull request carrying the `docs-go` label if a changed file lives outside `doc/`. Two kinds of documentation work live outside `doc/` and are therefore locked out of the label today: - **Ray's Vale configuration** (`.vale.ini`, `.vale/`) sits at the repository root, so a PR that adds or edits a prose-lint rule can never carry the label even though it is documentation content by any reasonable reading. Concretely: ray-project#65239 adds KubeRay style rules and edits `doc/source/ray-contribute/writing-style.md`. Its [premerge build](https://buildkite.com/ray-project/premerge/builds/71732) has exactly one failing job, `lint: validate docs-go scope`. Every other check passes. - **The API-consistency checker's own source** (`ci/ray_ci/doc/`) is the tooling behind the `doc: check API doc consistency` step. Same shape: ray-project#65340 changes only that directory, and the label's guard is the sole red job on its [premerge build](https://buildkite.com/ray-project/premerge/builds/71727). In both cases the author's options today are to drop the label and wait on per-library example suites the PR cannot possibly affect, or to split a coherent change across two PRs. ## What changed Widen the guard's in-scope set from "under `doc/`" to "under `doc/`, the Vale prose-lint configuration (`.vale.ini`, `.vale/`), or the API-consistency checker (`ci/ray_ci/doc/`)". Both fail-closed paths (no merge-base, empty diff) are unchanged, and the `BUILD`-file exclusion now applies uniformly across the whole in-scope set rather than just `doc/`. Also updates the two places that state the predicate in prose, so they don't drift from the script: the `docs-go` section of `doc/source/ray-contribute/ci.md`, and `doc/.claude/CLAUDE.md`. ## Why this is safe The guard exists so `docs-go` can skip the 12 per-library docs example and llm test steps only on a PR that could not break them. The two additions clear that bar on different grounds, which is worth stating separately rather than blurring into one rule. **The Vale configuration** clears it on content: - **It defines no bazel target.** The separate `BUILD`-file exclusion is the mechanism that protects test targets, and it stays intact. - **It holds no executable Ray code**, so no doctest or example can change behavior because of it. - **The check that consumes it already runs unconditionally.** `lint: documentation_style` sits in the `lint-small-prose` matrix in `.buildkite/lint.rayci.yml` carrying `always`, which `always.rules.txt` emits for every changed file. Vale therefore runs on every pull request whether or not the label is present. - **No premerge step is traded away.** `test.rules.txt` already routes `.vale.ini` and `.vale/` to `doc` alone, in the rendering-and-validation-only block. That tag reaches `doc: build`, which carries `skip-on-premerge`. **The checker source** is executable CI code, so the reasoning above does not apply to it. It clears the bar on tag routing: - **`test.rules.txt` routes `ci/ray_ci/doc/` to `doc_api tools` and nothing else**, ahead of the broad `ci/ray_ci/` rule, and first match wins. - **Every step the label skips carries a library tag instead** — `core_python`, `data`, `llm`, `train`, `tune`, `rllib_directly`, `serve`, and the `*_doc` tags. A change confined to this directory never emits a tag that selects one of them. Since the label's `if:` can only suppress an already-emitted step, there is nothing for it to take away. - **Measured on the same commit, with and without the label.** ray-project#65340 was built twice: [71727](https://buildkite.com/ray-project/premerge/builds/71727) carried `["go", "docs-go"]` and [71736](https://buildkite.com/ray-project/premerge/builds/71736) carried `["go"]`. Both emitted the same 33 jobs, and diffing the two job-name sets yields no difference in either direction. The label's only effect on such a PR is whether this guard itself is emitted: it ran and failed in the first build, and was `broken` (never emitted) in the second. That is the claim above, observed rather than derived. - **The checks that do cover the directory are ungated.** The `doc_api` API checks and the `tools` job running this directory's six `ci_unit` py_test targets both run with the label present. Build 71727 is the direct evidence: it carried `docs-go` and ran `doc: check API annotations`, `doc: check API doc consistency`, and all six `//ci/ray_ci/doc:*` targets, all green. - **`BUILD` files stay excluded**, so a change to this directory's test targets still fails the guard. ray-project#65340 is exactly that case: it adds a `py_test` src, so it would still not qualify for the label after this change. That is the intended outcome. Each list is deliberately narrow. For Vale it covers the prose rules, not the CI wiring that runs them: `ci/lint/check-documentation-style.sh` and the Vale hook in `.pre-commit-config.yaml` stay out of scope, because a change to either one alters what actually runs. For the checker it covers `ci/ray_ci/doc/` only, not the shared `ci/ray_ci/` tooling that every bazel test step runs through. ## Two corrections on the same surface - **The script's header comment claimed the label skips the API consistency checks.** It doesn't. `doc.rayci.yml` leaves them deliberately ungated, precisely because an API reference page edit is the content-only change they must cover, and build 71727 confirms both ran under the label. `ci.md` already described this correctly, so only the script was wrong. - **The failure message advised an action that cannot work.** It said "Remove the 'docs-go' label so the appropriate tests run," but removing the label cannot produce a corrected build on the same commit. A Buildkite rebuild replays the label set from the build it was rebuilt from, and the pipeline sets `skip_pull_request_builds_for_existing_commits`, so the `unlabeled` event on an already-built commit produces no build at all. Verified on ray-project#65340: `docs-go` was removed at 19:59:30Z, build 71727 was created at 20:00:03Z as a UI rebuild, and its payload still carried `["go", "docs-go"]`. The message and both prose surfaces now say to remove the label *and push a new commit*. ## Checks - [x] I've signed off every commit (`git commit --signoff`). - [x] I've made sure the tests are passing. - Testing Strategy - [x] Manual tests `shellcheck` is clean. The guard was exercised end to end against a controlled base in a scratch repository, 15 cases — the 7 from the Vale-only version, unchanged, plus 8 for the new path: | Changed files | Expected | Result | | --- | --- | --- | | `.vale.ini` + `.vale/styles/**` + a `doc/` page (the ray-project#65239 shape) | pass | pass | | `.vale/styles/**` alone | pass | pass | | a `doc/` page alone (behavior before this change) | pass | pass | | `.vale/styles/**` + a file under `python/ray/` | fail | fail, names the Python file | | `.vale/BUILD.bazel` | fail | fail, names it as a `BUILD` file | | `ci/lint/check-documentation-style.sh` | fail | fail | | `.pre-commit-config.yaml` | fail | fail | | `ci/ray_ci/doc/api.py` alone | pass | pass | | `ci/ray_ci/doc/api.py` + a `doc/` page | pass | pass | | `ci/ray_ci/doc/mock/_internal/__init__.py` | pass | pass | | `ci/ray_ci/doc/BUILD.bazel` (the ray-project#65340 shape) | fail | fail, names it as a `BUILD` file | | `ci/ray_ci/doc/api.py` + a file under `python/ray/` | fail | fail, names the Python file | | `ci/ray_ci/tester.py` (shared tooling, not the checker) | fail | fail | | `ci/ray_ci/docker/**` (sibling path) | fail | fail | | `doc/BUILD.bazel` | fail | fail, unchanged behavior | Note that this PR itself edits `ci/lint/`, so it deliberately does not carry the `docs-go` label. The label's effect on ray-project#65239 is the real confirmation, and I'll rebase that PR onto this once it lands. ## Related ray-project#64775 reserved the `doc` tag for documentation validation. The `docs-go` label and this guard arrived with the content-only escape hatch that followed. ray-project#65340 is the checker-source change that motivated the second path. --------- Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: 400Ping <[email protected]>
## Why `python/ray/serve/request_router.py` re-exports the public request-router extension surface, but declares it implicitly through `# noqa: F401` imports rather than explicitly through `__all__`. This declares it. The seven names are each decorated `@PublicAPI(stability="alpha")` at their definition site and documented in the Serve API reference at `doc/source/serve/api/index.md` under their `serve.request_router.*` path. `doc/source/serve/advanced-guides/custom-request-router.md` and its `doc_code/custom_request_router.py` teach users to import from this module. So the change records an existing contract rather than creating a new one. It also makes the surface visible to the API-doc consistency check. `API._is_public_reexport()`, added in ray-project#65340, treats a name in a public module's `__all__` as public regardless of where its implementation lives, but it requires an *explicit* `__all__` entry, which this module didn't have. ## Coordination This is a small mechanical change, so per `AGENTS.md` it's worth saying it was coordinated rather than volunteered. It follows from a ruling Richard Liaw gave on Ray's API location policy: a private definition re-exported through a public module's `__all__` is compliant, and the test that matters is whether users have to import a private package. Declaring the surface here is the fix that ruling implies. Happy to close this if the Serve team would rather handle the module differently. ## `ReplicaResult` is deliberately excluded It's the one name in the file left out of `__all__`, because unlike the other seven it carries no API annotation (`class ReplicaResult(ABC)`, no decorator) and has no reference-page entry. Including it would newly assert a public contract instead of recording one. Its import keeps an F401 suppression since the re-export is still in use. **This is the one judgment call in the PR and it's yours to make.** If Serve considers `ReplicaResult` part of the public extension surface, say so and I'll add it. `PowerOfTwoChoicesRequestRouter` is out of scope: it's absent from both this module's re-exports and the autosummary, so it needs a separate decision. ## Removing the per-import suppressions The seven declared names lose their `# noqa: F401` comments. A name listed in `__all__` counts as used, so pyflakes and ruff no longer flag it. `ReplicaResult` keeps its suppression. ## Testing Verified statically: - `ruff check python/ray/serve/request_router.py` — passes. - `black --check` and `ruff format --check` — already formatted. - Full `pre-commit run` on the changed file — all applicable hooks pass (ruff, black, pydoclint, docstyle, import order, semgrep). - Confirmed the declared `__all__` is exactly the set of seven names in the `serve.request_router.*` autosummary block, with no extras and nothing missing. **Not verified locally: `api_policy_check`.** It needs a Ray build, and master's Python source doesn't import against a released binary, so I'm relying on CI for that check rather than claiming a local run. The expected effect is on the resolve check only. I'm specifically *not* claiming this clears the `tracked_doc_debt` entries for these symbols: those fail the must-be-documented check, which ray-project#65340 explicitly left untouched. If CI shows any of them can drop, I'll follow up separately rather than bundling it here. ## Duplicate check No open PR touches `python/ray/serve/request_router.py`. ray-project#65410 (`[serve] Enforce type checking on the scheduling/routing modules`) touches `_private/request_router/request_router.py` but not this module, so no conflict. ## AI assistance AI-assisted, per `AGENTS.md`: the analysis and the patch were drafted with Claude Code, and I reviewed every changed line. Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: 400Ping <[email protected]>
…eck (ray-project#65340) ## Why this change is needed The API-doc consistency check (`ci/ray_ci/doc/`) classifies a documented API as non-public when its canonical name resolves under a private module, keying on the `._internal.` segment in `API._is_private_name()`. Several public Ray Data APIs are re-exported into `ray.data.__all__` while their implementation lives in `_internal`, so the heuristic flags names that are legitimately public and correctly documented. Those false positives were suppressed with a per-team `doc_only_whitelist` — a hand-maintained list that had to grow by one entry every time a team re-exported another API from a private module. ## What this change does Reads the export instead of guessing from the path. A name that the documented module declares in its `__all__` is public regardless of where its implementation lives, so the new `API._is_public_reexport()` exempts it from the private-name rule and the list goes away. The exemption is deliberately narrow, so genuinely private symbols stay flagged: - **Only a public module's `__all__` counts.** A name documented through a private path (`ray.data._internal.foo.Bar`) keeps its verdict — a private module's `__all__` is not a public contract. - **An underscore leaf stays private** on either side of the re-export. `__all__` membership can never promote a `_foo` name. - **Module-attribute reachability alone changes nothing.** Absent an explicit `__all__` entry, the verdict is unchanged. Scope is limited to the resolve check's non-public classification (`split_resolvable_and_broken_doc_apis`). The "every `@PublicAPI` must be documented" check and the duplicate-documentation check are untouched, as is `API.is_public()` on the code side. ## Whitelist entries retired All seven `doc_only_whitelist` entries on the data team config: | Retired entry | Public name it's documented under | |---|---| | `ray.data._internal.compute.ActorPoolStrategy` | `ray.data.ActorPoolStrategy` | | `ray.data._internal.compute.TaskPoolStrategy` | `ray.data.TaskPoolStrategy` | | `ray.data._internal.execution.interfaces.execution_options.ExecutionOptions` | `ray.data.ExecutionOptions` | | `ray.data._internal.execution.interfaces.execution_options.ExecutionResources` | `ray.data.ExecutionResources` | | `ray.data._internal.logical.operators.n_ary_operator.MixStoppingCondition` | `ray.data.MixStoppingCondition` | | `ray.data._internal.random_config.RandomSeedConfig` | `ray.data.RandomSeedConfig` | | `ray.llm._internal.batch.processor.base.Processor` | `ray.data.llm.Processor` | Each is present in `ray.data.__all__` or `ray.data.llm.__all__`, and each is documented through its public `currentmodule` in `doc/source/data/api/`. None carries a `@Deprecated` annotation, so none relied on the whitelist for anything beyond the private-path suppression this change replaces. RLlib's `doc_only_whitelist` is a different case — instance attributes assigned in `setup()` that the import walk can't resolve — and is untouched. ## Related PRs - ray-project#64423 added the `doc_only_whitelist` workaround. - ray-project#64786 split the whitelists into permanent exemptions and tracked debt. ## Checks - [x] I've signed off every commit (`git commit --signoff`). - [x] I've made sure the tests are passing. - Testing Strategy - [x] Unit tests `ci/ray_ci/doc/test_api.py` gains coverage for the re-export case, for the same object documented through its private canonical path, and for the negative control — a class importable from the same public module but absent from its `__all__`, which must still be flagged. A private mock subpackage (`ci/ray_ci/doc/mock/_internal/`) provides the fixture so the test exercises the real `._internal.` code path rather than a spoofed `__module__`. Verified locally: the four `ci/ray_ci/doc` unit-test files pass (44 tests), and `pre-commit` is clean on the changed files. The end-to-end `api_policy_check` step needs a bazel-built Ray in the docbuild image, so the whitelist retirement is verified statically here (`__all__` membership and annotations read from source, per the table above) and premerge's `doc_api_policy_check` is the decisive check. --------- Signed-off-by: Douglas Strodtman <[email protected]>
…documentation content in the docs-go scope guard (ray-project#65342) ## Why this change is needed `ci/lint/validate_docs_go_scope.sh` fails any pull request carrying the `docs-go` label if a changed file lives outside `doc/`. Two kinds of documentation work live outside `doc/` and are therefore locked out of the label today: - **Ray's Vale configuration** (`.vale.ini`, `.vale/`) sits at the repository root, so a PR that adds or edits a prose-lint rule can never carry the label even though it is documentation content by any reasonable reading. Concretely: ray-project#65239 adds KubeRay style rules and edits `doc/source/ray-contribute/writing-style.md`. Its [premerge build](https://buildkite.com/ray-project/premerge/builds/71732) has exactly one failing job, `lint: validate docs-go scope`. Every other check passes. - **The API-consistency checker's own source** (`ci/ray_ci/doc/`) is the tooling behind the `doc: check API doc consistency` step. Same shape: ray-project#65340 changes only that directory, and the label's guard is the sole red job on its [premerge build](https://buildkite.com/ray-project/premerge/builds/71727). In both cases the author's options today are to drop the label and wait on per-library example suites the PR cannot possibly affect, or to split a coherent change across two PRs. ## What changed Widen the guard's in-scope set from "under `doc/`" to "under `doc/`, the Vale prose-lint configuration (`.vale.ini`, `.vale/`), or the API-consistency checker (`ci/ray_ci/doc/`)". Both fail-closed paths (no merge-base, empty diff) are unchanged, and the `BUILD`-file exclusion now applies uniformly across the whole in-scope set rather than just `doc/`. Also updates the two places that state the predicate in prose, so they don't drift from the script: the `docs-go` section of `doc/source/ray-contribute/ci.md`, and `doc/.claude/CLAUDE.md`. ## Why this is safe The guard exists so `docs-go` can skip the 12 per-library docs example and llm test steps only on a PR that could not break them. The two additions clear that bar on different grounds, which is worth stating separately rather than blurring into one rule. **The Vale configuration** clears it on content: - **It defines no bazel target.** The separate `BUILD`-file exclusion is the mechanism that protects test targets, and it stays intact. - **It holds no executable Ray code**, so no doctest or example can change behavior because of it. - **The check that consumes it already runs unconditionally.** `lint: documentation_style` sits in the `lint-small-prose` matrix in `.buildkite/lint.rayci.yml` carrying `always`, which `always.rules.txt` emits for every changed file. Vale therefore runs on every pull request whether or not the label is present. - **No premerge step is traded away.** `test.rules.txt` already routes `.vale.ini` and `.vale/` to `doc` alone, in the rendering-and-validation-only block. That tag reaches `doc: build`, which carries `skip-on-premerge`. **The checker source** is executable CI code, so the reasoning above does not apply to it. It clears the bar on tag routing: - **`test.rules.txt` routes `ci/ray_ci/doc/` to `doc_api tools` and nothing else**, ahead of the broad `ci/ray_ci/` rule, and first match wins. - **Every step the label skips carries a library tag instead** — `core_python`, `data`, `llm`, `train`, `tune`, `rllib_directly`, `serve`, and the `*_doc` tags. A change confined to this directory never emits a tag that selects one of them. Since the label's `if:` can only suppress an already-emitted step, there is nothing for it to take away. - **Measured on the same commit, with and without the label.** ray-project#65340 was built twice: [71727](https://buildkite.com/ray-project/premerge/builds/71727) carried `["go", "docs-go"]` and [71736](https://buildkite.com/ray-project/premerge/builds/71736) carried `["go"]`. Both emitted the same 33 jobs, and diffing the two job-name sets yields no difference in either direction. The label's only effect on such a PR is whether this guard itself is emitted: it ran and failed in the first build, and was `broken` (never emitted) in the second. That is the claim above, observed rather than derived. - **The checks that do cover the directory are ungated.** The `doc_api` API checks and the `tools` job running this directory's six `ci_unit` py_test targets both run with the label present. Build 71727 is the direct evidence: it carried `docs-go` and ran `doc: check API annotations`, `doc: check API doc consistency`, and all six `//ci/ray_ci/doc:*` targets, all green. - **`BUILD` files stay excluded**, so a change to this directory's test targets still fails the guard. ray-project#65340 is exactly that case: it adds a `py_test` src, so it would still not qualify for the label after this change. That is the intended outcome. Each list is deliberately narrow. For Vale it covers the prose rules, not the CI wiring that runs them: `ci/lint/check-documentation-style.sh` and the Vale hook in `.pre-commit-config.yaml` stay out of scope, because a change to either one alters what actually runs. For the checker it covers `ci/ray_ci/doc/` only, not the shared `ci/ray_ci/` tooling that every bazel test step runs through. ## Two corrections on the same surface - **The script's header comment claimed the label skips the API consistency checks.** It doesn't. `doc.rayci.yml` leaves them deliberately ungated, precisely because an API reference page edit is the content-only change they must cover, and build 71727 confirms both ran under the label. `ci.md` already described this correctly, so only the script was wrong. - **The failure message advised an action that cannot work.** It said "Remove the 'docs-go' label so the appropriate tests run," but removing the label cannot produce a corrected build on the same commit. A Buildkite rebuild replays the label set from the build it was rebuilt from, and the pipeline sets `skip_pull_request_builds_for_existing_commits`, so the `unlabeled` event on an already-built commit produces no build at all. Verified on ray-project#65340: `docs-go` was removed at 19:59:30Z, build 71727 was created at 20:00:03Z as a UI rebuild, and its payload still carried `["go", "docs-go"]`. The message and both prose surfaces now say to remove the label *and push a new commit*. ## Checks - [x] I've signed off every commit (`git commit --signoff`). - [x] I've made sure the tests are passing. - Testing Strategy - [x] Manual tests `shellcheck` is clean. The guard was exercised end to end against a controlled base in a scratch repository, 15 cases — the 7 from the Vale-only version, unchanged, plus 8 for the new path: | Changed files | Expected | Result | | --- | --- | --- | | `.vale.ini` + `.vale/styles/**` + a `doc/` page (the ray-project#65239 shape) | pass | pass | | `.vale/styles/**` alone | pass | pass | | a `doc/` page alone (behavior before this change) | pass | pass | | `.vale/styles/**` + a file under `python/ray/` | fail | fail, names the Python file | | `.vale/BUILD.bazel` | fail | fail, names it as a `BUILD` file | | `ci/lint/check-documentation-style.sh` | fail | fail | | `.pre-commit-config.yaml` | fail | fail | | `ci/ray_ci/doc/api.py` alone | pass | pass | | `ci/ray_ci/doc/api.py` + a `doc/` page | pass | pass | | `ci/ray_ci/doc/mock/_internal/__init__.py` | pass | pass | | `ci/ray_ci/doc/BUILD.bazel` (the ray-project#65340 shape) | fail | fail, names it as a `BUILD` file | | `ci/ray_ci/doc/api.py` + a file under `python/ray/` | fail | fail, names the Python file | | `ci/ray_ci/tester.py` (shared tooling, not the checker) | fail | fail | | `ci/ray_ci/docker/**` (sibling path) | fail | fail | | `doc/BUILD.bazel` | fail | fail, unchanged behavior | Note that this PR itself edits `ci/lint/`, so it deliberately does not carry the `docs-go` label. The label's effect on ray-project#65239 is the real confirmation, and I'll rebase that PR onto this once it lands. ## Related ray-project#64775 reserved the `doc` tag for documentation validation. The `docs-go` label and this guard arrived with the content-only escape hatch that followed. ray-project#65340 is the checker-source change that motivated the second path. --------- Signed-off-by: Douglas Strodtman <[email protected]>
## Why `python/ray/serve/request_router.py` re-exports the public request-router extension surface, but declares it implicitly through `# noqa: F401` imports rather than explicitly through `__all__`. This declares it. The seven names are each decorated `@PublicAPI(stability="alpha")` at their definition site and documented in the Serve API reference at `doc/source/serve/api/index.md` under their `serve.request_router.*` path. `doc/source/serve/advanced-guides/custom-request-router.md` and its `doc_code/custom_request_router.py` teach users to import from this module. So the change records an existing contract rather than creating a new one. It also makes the surface visible to the API-doc consistency check. `API._is_public_reexport()`, added in ray-project#65340, treats a name in a public module's `__all__` as public regardless of where its implementation lives, but it requires an *explicit* `__all__` entry, which this module didn't have. ## Coordination This is a small mechanical change, so per `AGENTS.md` it's worth saying it was coordinated rather than volunteered. It follows from a ruling Richard Liaw gave on Ray's API location policy: a private definition re-exported through a public module's `__all__` is compliant, and the test that matters is whether users have to import a private package. Declaring the surface here is the fix that ruling implies. Happy to close this if the Serve team would rather handle the module differently. ## `ReplicaResult` is deliberately excluded It's the one name in the file left out of `__all__`, because unlike the other seven it carries no API annotation (`class ReplicaResult(ABC)`, no decorator) and has no reference-page entry. Including it would newly assert a public contract instead of recording one. Its import keeps an F401 suppression since the re-export is still in use. **This is the one judgment call in the PR and it's yours to make.** If Serve considers `ReplicaResult` part of the public extension surface, say so and I'll add it. `PowerOfTwoChoicesRequestRouter` is out of scope: it's absent from both this module's re-exports and the autosummary, so it needs a separate decision. ## Removing the per-import suppressions The seven declared names lose their `# noqa: F401` comments. A name listed in `__all__` counts as used, so pyflakes and ruff no longer flag it. `ReplicaResult` keeps its suppression. ## Testing Verified statically: - `ruff check python/ray/serve/request_router.py` — passes. - `black --check` and `ruff format --check` — already formatted. - Full `pre-commit run` on the changed file — all applicable hooks pass (ruff, black, pydoclint, docstyle, import order, semgrep). - Confirmed the declared `__all__` is exactly the set of seven names in the `serve.request_router.*` autosummary block, with no extras and nothing missing. **Not verified locally: `api_policy_check`.** It needs a Ray build, and master's Python source doesn't import against a released binary, so I'm relying on CI for that check rather than claiming a local run. The expected effect is on the resolve check only. I'm specifically *not* claiming this clears the `tracked_doc_debt` entries for these symbols: those fail the must-be-documented check, which ray-project#65340 explicitly left untouched. If CI shows any of them can drop, I'll follow up separately rather than bundling it here. ## Duplicate check No open PR touches `python/ray/serve/request_router.py`. ray-project#65410 (`[serve] Enforce type checking on the scheduling/routing modules`) touches `_private/request_router/request_router.py` but not this module, so no conflict. ## AI assistance AI-assisted, per `AGENTS.md`: the analysis and the patch were drafted with Claude Code, and I reviewed every changed line. Signed-off-by: Douglas Strodtman <[email protected]>
Why this change is needed
The API-doc consistency check (
ci/ray_ci/doc/) classifies a documented API as non-public when its canonical name resolves under a private module, keying on the._internal.segment inAPI._is_private_name().Several public Ray Data APIs are re-exported into
ray.data.__all__while their implementation lives in_internal, so the heuristic flags names that are legitimately public and correctly documented. Those false positives were suppressed with a per-teamdoc_only_whitelist— a hand-maintained list that had to grow by one entry every time a team re-exported another API from a private module.What this change does
Reads the export instead of guessing from the path. A name that the documented module declares in its
__all__is public regardless of where its implementation lives, so the newAPI._is_public_reexport()exempts it from the private-name rule and the list goes away.The exemption is deliberately narrow, so genuinely private symbols stay flagged:
__all__counts. A name documented through a private path (ray.data._internal.foo.Bar) keeps its verdict — a private module's__all__is not a public contract.__all__membership can never promote a_fooname.__all__entry, the verdict is unchanged.Scope is limited to the resolve check's non-public classification (
split_resolvable_and_broken_doc_apis). The "every@PublicAPImust be documented" check and the duplicate-documentation check are untouched, as isAPI.is_public()on the code side.Whitelist entries retired
All seven
doc_only_whitelistentries on the data team config:ray.data._internal.compute.ActorPoolStrategyray.data.ActorPoolStrategyray.data._internal.compute.TaskPoolStrategyray.data.TaskPoolStrategyray.data._internal.execution.interfaces.execution_options.ExecutionOptionsray.data.ExecutionOptionsray.data._internal.execution.interfaces.execution_options.ExecutionResourcesray.data.ExecutionResourcesray.data._internal.logical.operators.n_ary_operator.MixStoppingConditionray.data.MixStoppingConditionray.data._internal.random_config.RandomSeedConfigray.data.RandomSeedConfigray.llm._internal.batch.processor.base.Processorray.data.llm.ProcessorEach is present in
ray.data.__all__orray.data.llm.__all__, and each is documented through its publiccurrentmoduleindoc/source/data/api/. None carries a@Deprecatedannotation, so none relied on the whitelist for anything beyond the private-path suppression this change replaces.RLlib's
doc_only_whitelistis a different case — instance attributes assigned insetup()that the import walk can't resolve — and is untouched.Related PRs
doc_only_whitelistworkaround.Checks
git commit --signoff).ci/ray_ci/doc/test_api.pygains coverage for the re-export case, for the same object documented through its private canonical path, and for the negative control — a class importable from the same public module but absent from its__all__, which must still be flagged. A private mock subpackage (ci/ray_ci/doc/mock/_internal/) provides the fixture so the test exercises the real._internal.code path rather than a spoofed__module__.Verified locally: the four
ci/ray_ci/docunit-test files pass (44 tests), andpre-commitis clean on the changed files. The end-to-endapi_policy_checkstep needs a bazel-built Ray in the docbuild image, so the whitelist retirement is verified statically here (__all__membership and annotations read from source, per the table above) and premerge'sdoc_api_policy_checkis the decisive check.