From b4e389d4be53734256f93f70181b7894aed57748 Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Tue, 6 Oct 2026 19:23:20 +0100 Subject: [PATCH 1/6] Publish llms.txt and Markdown pages for the common.ai provider docs Coding agents read docs best as Markdown with an llms.txt index, the way Pydantic AI publishes https://pydantic.dev/docs/ai/llms.txt. This adds that to the common.ai provider docs build: - sphinx-llm writes page.html.md next to every page.html and links it from the HTML head with rel="alternate" type="text/markdown". - A new airflow_llms_txt extension fixes the Markdown for Airflow docs (mermaid, code captions, admonitions, compact tables, same-page links, license headers, |version| links), links each exampleinclude excerpt to the full example file on GitHub, and writes llms.txt grouped by the docs navigation with absolute URLs and per-page descriptions, plus llms-full.txt with the same pages in one file. Enabled for common.ai only via PROVIDER_PACKAGES_WITH_LLMS_TXT. --- devel-common/pyproject.toml | 1 + devel-common/src/docs/provider_conf.py | 57 ++ devel-common/src/docs/utils/conf_constants.py | 4 +- .../src/sphinx_exts/airflow_llms_txt.py | 484 ++++++++++ providers/common/ai/docs/operations.rst | 3 + providers/common/ai/docs/rag_pipelines.rst | 3 + providers/common/ai/docs/sandbox/backends.rst | 830 ++++++++++++++++++ .../common/ai/docs/sandbox/configuration.rst | 3 + providers/common/ai/docs/tool_approval.rst | 8 + uv.lock | 35 + 10 files changed, 1427 insertions(+), 1 deletion(-) create mode 100644 devel-common/src/sphinx_exts/airflow_llms_txt.py create mode 100644 providers/common/ai/docs/sandbox/backends.rst diff --git a/devel-common/pyproject.toml b/devel-common/pyproject.toml index 6dc6c92a9af3..a959fa4144ad 100644 --- a/devel-common/pyproject.toml +++ b/devel-common/pyproject.toml @@ -88,6 +88,7 @@ dependencies = [ "sphinx-copybutton>=0.5.2", "sphinx-design>=0.5.0", "sphinx-jinja>=2.0.2", + "sphinx-llm>=1.1.0,<1.2", # airflow_llms_txt subclasses its Markdown translator "sphinx-rtd-theme>=2.0.0", "sphinx>=7", "sphinxcontrib-applehelp>=1.0.4", diff --git a/devel-common/src/docs/provider_conf.py b/devel-common/src/docs/provider_conf.py index 4df107b7d412..c80e00a8134e 100644 --- a/devel-common/src/docs/provider_conf.py +++ b/devel-common/src/docs/provider_conf.py @@ -33,6 +33,7 @@ # serve to show the default. import logging import os +import subprocess from typing import Any import rich @@ -147,6 +148,62 @@ ] ) +# Providers that publish a Markdown copy of every page plus llms.txt for LLMs and coding agents. +PROVIDER_PACKAGES_WITH_LLMS_TXT = [ + "apache-airflow-providers-common-ai", +] + + +def _example_source_ref(tag: str) -> str: + """ + Return the git ref example source links point at: HEAD if it is pushed, else the release tag. + + Docs built from ``main`` describe more than the last release, so linking the tag there would + point at example files that do not exist in it yet. A HEAD no remote branch or tag contains, + such as the commit the docs publish workflow makes when it cherry-picks fixes onto a release + tag, does not exist on GitHub, so those builds link the tag. + """ + + def git(*args: str) -> str: + try: + result = subprocess.run( + ["git", *args], cwd=AIRFLOW_REPO_ROOT_PATH, capture_output=True, text=True, check=False + ) + except OSError: # no git, e.g. building from an sdist + return "" + return result.stdout.strip() + + head = git("rev-parse", "--verify", "--quiet", "HEAD^{commit}") + if not head or head == git("rev-parse", "--verify", "--quiet", f"{tag}^{{commit}}"): + return tag + pushed = git("for-each-ref", "--contains", head, "--count=1", "refs/remotes", "refs/tags") + return head if pushed else tag + + +if PACKAGE_NAME in PROVIDER_PACKAGES_WITH_LLMS_TXT: + extensions.append("airflow_llms_txt") + llms_txt_site_url = f"https://airflow.apache.org/docs/{PACKAGE_NAME}/{PACKAGE_VERSION}/" + _release_tag = f"providers-{PACKAGE_ID.replace('.', '-')}/{PACKAGE_VERSION}" + llms_txt_source_url = f"https://github.com/apache/airflow/blob/{_example_source_ref(_release_tag)}/" + llms_txt_release_source_url = f"https://github.com/apache/airflow/blob/{_release_tag}/" + llms_txt_repo_root = AIRFLOW_REPO_ROOT_PATH.as_posix() + llms_txt_intro = ( + f"Install with `pip install {PACKAGE_NAME}`. This index covers version {PACKAGE_VERSION}. " + "Each link is a Markdown copy of a docs page; drop the trailing `.md` for the HTML page. " + "Code samples are excerpts of example Dags, and each one links to the full file." + ) + llms_txt_root_description = "Package overview, its requirements and what each optional extra installs." + # Long or generic pages an agent rarely needs first. + llms_txt_optional_docs = ["_api/**", "changelog", "security", "installing-providers-from-sources"] + # Not useful to an agent at all; their Markdown copies are still published. + llms_txt_skip_docs = ["_api/tests/**", "commits"] + llms_txt_nested_enabled = False + # One Markdown copy per page, ``page.html.md``: what llms.txt and ``rel=alternate`` link to. + llms_txt_suffix_mode = "append" + # Run the Markdown build after the HTML build, not alongside it: both run autoapi, which + # rewrites the ``_api`` sources in place while the other build may be reading them. + llms_txt_build_parallel = False + # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. empty_subpackages = ["apache", "atlassian", "common", "cncf", "dbt", "ibm", "microsoft"] diff --git a/devel-common/src/docs/utils/conf_constants.py b/devel-common/src/docs/utils/conf_constants.py index fd2116bbab65..d961402673c3 100644 --- a/devel-common/src/docs/utils/conf_constants.py +++ b/devel-common/src/docs/utils/conf_constants.py @@ -74,7 +74,9 @@ def get_rst_epilogue(package_version: str, airflow_core: bool) -> str: ) -SMARTQUOTES_EXCLUDES = {"builders": ["man", "text", "spelling"]} +# ``llms-markdown`` is sphinx-llm's Markdown build: its files are served without a charset, so +# curly quotes in them turn into mojibake for clients that default ``text/*`` to Latin-1. +SMARTQUOTES_EXCLUDES = {"builders": ["man", "text", "spelling", "llms-markdown"]} BASIC_SPHINX_EXTENSIONS = [ "sphinx.ext.autodoc", diff --git a/devel-common/src/sphinx_exts/airflow_llms_txt.py b/devel-common/src/sphinx_exts/airflow_llms_txt.py new file mode 100644 index 000000000000..050bc335d6e5 --- /dev/null +++ b/devel-common/src/sphinx_exts/airflow_llms_txt.py @@ -0,0 +1,484 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +Publish Markdown copies of each page and an ``llms.txt`` index for LLMs and coding agents. + +`sphinx-llm `__ does the heavy lifting: it runs a second +Sphinx build with a Markdown builder, writes ``page.html.md`` next to every ``page.html`` and +adds ```` to each HTML page. This extension adds what +Airflow docs need on top of it: + +* Markdown handlers for nodes the stock translator drops or misrenders: ``mermaid`` diagrams, + code-block captions, keyword-only ``*`` markers in API signatures and toctree captions. +* License-header comments are removed, so they do not open every page. +* ``exampleinclude`` headers link to the full example file on GitHub at the release tag, since + the excerpts leave out imports. +* ``llms.txt`` is rewritten: sections follow the root toctree captions, every link is absolute, + and descriptions come from each page's first paragraph rather than its first line of text. +* ``llms-full.txt`` holds the same pages in the same order, each headed by its URL, with links + made absolute so they still work once the pages share one file. +""" + +from __future__ import annotations + +import posixpath +import re +from collections.abc import Iterator +from pathlib import Path +from typing import TYPE_CHECKING, Any +from urllib.parse import urljoin + +from docutils import nodes +from sphinx import addnodes +from sphinx.util import logging +from sphinx.util.matching import Matcher +from sphinx_llm.markdown_builder import SphinxLlmMarkdownBuilder, SphinxLlmMarkdownTranslator +from sphinx_markdown_builder.contexts import IndentContext, SubContext, SubContextParams, TableContext + +if TYPE_CHECKING: + from sphinx.application import Sphinx + from sphinx.config import Config + from sphinx.environment import BuildEnvironment + +logger = logging.getLogger(__name__) + +MARKDOWN_BUILDER = SphinxLlmMarkdownBuilder.name +# Pages whose first paragraph is shorter than this get no description rather than a fragment. +MIN_DESCRIPTION_LENGTH = 20 +MAX_DESCRIPTION_LENGTH = 240 +_SENTENCE_END = re.compile(r"(?<=[.!?])\s+(?=[A-Z`])") +# Paragraphs under these are not the page's own opening prose. +_NOT_PROSE = ( + nodes.Admonition, + nodes.comment, + nodes.compound, + nodes.list_item, + nodes.system_message, + nodes.table, + nodes.topic, + addnodes.desc, +) +# llms.txt is built from the HTML build's doctrees, where Sphinx has already curled the quotes. +# The files are served without a charset, so keep them ASCII (see SMARTQUOTES_EXCLUDES). +_TYPOGRAPHY = str.maketrans( + { + "\u2018": "'", + "\u2019": "'", + "\u201c": '"', + "\u201d": '"', + "\u2013": "-", + "\u2014": "-", + "\u2026": "...", + "\u00a0": " ", + } +) +_INLINE_CODE = re.compile(r"(`[^`]*`)") +_MARKDOWN_LINK = re.compile(r"(\]\()([^)\s]+)(\))") + + +class CompactTableContext(TableContext): + """ + A pipe table without the column padding. + + ``tabulate`` pads every cell to the widest one in its column, which is pure whitespace to a + model reading the file: about a tenth of ``llms-full.txt`` before this. + """ + + def make(self) -> str: + ctx = SubContext() + prefix = self.internal_context.make() + if prefix: + ctx.add(prefix) + rows = [self.make_row(row) for row in [*self.headers, *self.body]] + if rows: + width = max(len(row) for row in rows) + lines = [ + "| " + + " | ".join(cell.replace("|", r"\|") for cell in [*row, *[""] * (width - len(row))]) + + " |" + for row in rows + ] + lines.insert(1, "|" + "---|" * width) + ctx.add("\n".join(lines), prefix_eol=2) + return ctx.make() + + +class AirflowMarkdownTranslator(SphinxLlmMarkdownTranslator): + """Render the Sphinx nodes Airflow docs use that sphinx-markdown-builder skips or misrenders.""" + + def _push_box(self, title: str) -> None: + # Admonitions become a quoted block that starts with their label, rather than an + # ``#### NOTE`` heading that breaks the heading order and never says where the note ends. + self._push_context(IndentContext("> ", empty=True, params=SubContextParams(2, 2))) + self.add(f"**{title.capitalize()}:**", suffix_eol=2) + + def _fetch_ref_uri(self, node: nodes.reference) -> str: + # A link to a section on the same page (```Confidence`_``) has a refid but no refuri and + # no ``internal`` flag, so the base translators leave its target empty. + if node.get("refid") and not node.get("refuri"): + return self.builder.link_token(self.builder.current_doc_name, node["refid"]) + return super()._fetch_ref_uri(node) + + def visit_meta(self, node: nodes.Element) -> None: + raise nodes.SkipNode + + def visit_toctree(self, node: addnodes.toctree) -> None: + # Hidden toctrees can reach the writer unresolved; like HTML, show nothing for them. + # Visible ones are resolved into link lists before this, so any left are unexpected. + if not node.get("hidden"): + super().unknown_visit(node) + raise nodes.SkipNode + + def visit_table(self, node: nodes.Element) -> None: + self._push_context(CompactTableContext(params=SubContextParams(2, 1))) + + def depart_table(self, node: nodes.Element) -> None: + self._pop_context(node) + + def visit_mermaid(self, node: nodes.Element) -> None: + self.add(f"```mermaid\n{node['code'].strip()}\n```", prefix_eol=2, suffix_eol=2) + raise nodes.SkipNode + + def visit_caption(self, node: nodes.Element) -> None: + self.add(f"**{node.astext()}**", prefix_eol=2, suffix_eol=1) + raise nodes.SkipNode + + # ``abbreviation`` wraps the bare ``*`` that marks keyword-only parameters in signatures. + def visit_abbreviation(self, node: nodes.Element) -> None: + pass + + def depart_abbreviation(self, node: nodes.Element) -> None: + pass + + def visit_title(self, node: nodes.Element) -> None: + # A visible toctree's caption is a title inside its wrapper; as a heading it would be a + # second H1 on the page. + parent = node.parent + if isinstance(parent, nodes.compound) and "toctree-wrapper" in parent["classes"]: + self.add(f"**{node.astext()}**", prefix_eol=2, suffix_eol=1) + raise nodes.SkipNode + super().visit_title(node) + + def depart_title(self, node: nodes.Element) -> None: + self._pop_context(node) + + +def _escape_link_text(text: str) -> str: + return text.replace("[", r"\[").replace("]", r"\]") + + +def _inline_markdown(node: nodes.Node, env: BuildEnvironment) -> str: + """Flatten a title or paragraph to one line of Markdown, keeping inline code as code.""" + parts: list[str] = [] + for child in node.children: + if isinstance(child, addnodes.pending_xref) and not child.get("refexplicit"): + parts.append(_xref_title(child, env) or _inline_markdown(child, env)) + elif isinstance(child, nodes.literal): + parts.append(f"`{child.astext()}`") + elif isinstance(child, nodes.Text): + parts.append(child.astext()) + elif isinstance(child, nodes.Element): + parts.append(_inline_markdown(child, env)) + return re.sub(r"\s+", " ", "".join(parts)).strip().translate(_TYPOGRAPHY) + + +def _xref_title(xref: addnodes.pending_xref, env: BuildEnvironment) -> str | None: + """ + Return the title a ``:doc:`` or ``:ref:`` without explicit text resolves to. + + Doctrees read back from the environment are unresolved, so such a reference still holds its + raw target (``operators/llm``) rather than the page or section title the HTML shows. + """ + target = xref.get("reftarget", "") + if xref.get("reftype") == "doc": + refdoc = xref.get("refdoc", "") + docname = ( + target.lstrip("/") + if target.startswith("/") + else posixpath.join(posixpath.dirname(refdoc), target) + ) + title = env.titles.get(posixpath.normpath(docname)) + return _inline_markdown(title, env) if title else None + if xref.get("reftype") == "ref": + label = env.get_domain("std").labels.get(target.lower()) + return label[2] if label else None + return None + + +def _separate_markdown_doctrees(app: Sphinx, config: Config) -> None: + """ + Give the Markdown build a doctree cache of its own. + + Without parallel mode sphinx-llm points the Markdown build at the HTML build's doctree cache. + The Markdown build would then reuse doctrees read for HTML (curly quotes, none of this + extension's ``doctree-read`` changes) or, once re-read, overwrite them. Its own directory sits + inside sphinx-llm's temporary output, which is deleted after the Markdown files are copied. + Sphinx creates the environment after ``config-inited``, so the change takes effect. + """ + if app.tags.has("sphinx_llm_markdown"): + app.doctreedir = Path(app.outdir) / ".doctrees" + + +def _is_markdown_build(app: Sphinx) -> bool: + return app.builder is not None and app.builder.name == MARKDOWN_BUILDER + + +def _link_example_sources(app: Sphinx, doctree: nodes.document) -> None: + """ + Replace each ``exampleinclude`` header with a link to the whole example file. + + Runs before ``exampleinclude``'s own ``doctree-read`` handler, which would otherwise turn the + header into a bare module path plus a "View Source" button that has no Markdown equivalent. + """ + if not _is_markdown_build(app): + return + # Imported by bare name, as conf.py loads it: another import path gives a different class. + from exampleinclude import ExampleHeader + + repo_root = Path(app.config.llms_txt_repo_root).resolve() + source_url = app.config.llms_txt_source_url.rstrip("/") + for header in list(doctree.findall(ExampleHeader)): + path = Path(header["filename"]).resolve() + if not source_url or not path.is_relative_to(repo_root): + header.parent.remove(header) + continue + repo_path = path.relative_to(repo_root).as_posix() + paragraph = nodes.paragraph() + paragraph += nodes.Text("Excerpt from ") + link = nodes.reference("", "", refuri=f"{source_url}/{repo_path}", internal=False) + link += nodes.literal(repo_path, repo_path) + paragraph += link + paragraph += nodes.Text(":") + header.replace_self(paragraph) + + +def _clean_markdown_doctree(app: Sphinx, doctree: nodes.document, docname: str) -> None: + """ + Drop RST comments and fix up link targets. + + The comments are the license header on every page. ``|version|`` in a URL is not an RST + substitution; ``extra_provider_files_with_substitutions`` replaces it in the built HTML files + only, so the Markdown build has to do the same on the doctree. Hand-written links to the + release tag on GitHub then get the same ref as the ``exampleinclude`` links. + """ + if not _is_markdown_build(app): + return + site_root = urljoin(app.config.llms_txt_site_url, "/") + release_url = app.config.llms_txt_release_source_url + source_url = app.config.llms_txt_source_url + for reference in doctree.findall(nodes.reference): + refuri = reference.get("refuri", "") + if "|version|" in refuri: + refuri = reference["refuri"] = refuri.replace("|version|", app.config.version) + if release_url and source_url and release_url != source_url: + for kind in ("blob", "tree"): + prefix = release_url.replace("/blob/", f"/{kind}/") + if refuri.startswith(prefix): + refuri = reference["refuri"] = ( + source_url.replace("/blob/", f"/{kind}/") + refuri[len(prefix) :] + ) + # Links into other packages' docs are site-root relative, which means nothing to a model + # that got the page without its URL. + if refuri.startswith("/") and not refuri.startswith("//"): + reference["refuri"] = urljoin(site_root, refuri) + for comment in list(doctree.findall(nodes.comment)): + comment.parent.remove(comment) + for quote in list(doctree.findall(nodes.block_quote)): + if not quote.children: + quote.parent.remove(quote) + + +def _page_description(env: BuildEnvironment, docname: str) -> str: + """Return the page's meta description or the opening sentences of its first paragraph.""" + doctree = env.get_doctree(docname) + for meta in doctree.findall(nodes.meta): + if meta.get("name") == "description" and meta.get("content"): + return meta["content"] + for paragraph in doctree.findall(nodes.paragraph): + # ``example-header`` is the file path ``exampleinclude`` puts above a code excerpt. + if "example-header" in paragraph["classes"] or any( + isinstance(ancestor, _NOT_PROSE) for ancestor in _ancestors(paragraph) + ): + continue + text = _inline_markdown(paragraph, env) + if len(text) >= MIN_DESCRIPTION_LENGTH: + return _summarize(text) + return "" + + +def _summarize(text: str) -> str: + """Return whole sentences of ``text`` up to the length cap, cutting the first one if it is longer.""" + description = "" + for sentence in _SENTENCE_END.split(text): + if description and len(description) + len(sentence) + 1 > MAX_DESCRIPTION_LENGTH: + break + description = f"{description} {sentence}".strip() + if len(description) > MAX_DESCRIPTION_LENGTH: + description = description[:MAX_DESCRIPTION_LENGTH].rsplit(" ", 1)[0] + " ..." + # A paragraph that introduces a list or code block ends on a colon. + return re.sub(r":$", ".", description) + + +def _ancestors(node: nodes.Node) -> Iterator[nodes.Element]: + parent = node.parent + while parent is not None: + yield parent + parent = parent.parent + + +def _page_title(env: BuildEnvironment, docname: str, explicit_title: str | None) -> str: + if explicit_title: + return explicit_title + title_node = env.titles.get(docname) + return _inline_markdown(title_node, env) if title_node else docname + + +def _toctree_docs(env: BuildEnvironment, docname: str, seen: set[str]) -> list[tuple[str, str | None]]: + """Return ``docname`` and everything below it in toctree order, each once.""" + if docname in seen: + return [] + seen.add(docname) + docs: list[tuple[str, str | None]] = [(docname, None)] + for child in env.toctree_includes.get(docname, []): + docs.extend(_toctree_docs(env, child, seen)) + return docs + + +def _write_llms_txt(app: Sphinx, exception: Exception | None) -> None: + """ + Replace sphinx-llm's flat ``llms.txt`` with one grouped by the root toctree captions. + + Runs after sphinx-llm has copied the Markdown pages into the HTML output (priority 101). + """ + if exception is not None or app.builder.name != "html" or not app.config.llms_txt_enabled: + return + env = app.env + outdir = Path(app.outdir) + if not (outdir / f"{app.config.root_doc}.html.md").is_file(): + # sphinx-llm logs why its Markdown build failed; an index of missing pages helps nobody. + logger.warning("No Markdown pages in %s; not writing llms.txt or llms-full.txt", outdir) + return + site_url = app.config.llms_txt_site_url.rstrip("/") + optional = Matcher(app.config.llms_txt_optional_docs) + skipped = Matcher(app.config.llms_txt_skip_docs) + + def md_url(docname: str) -> str: + return f"{site_url}/{docname}.html.md" + + def entry(docname: str, title: str | None = None, *, describe: bool = True) -> str: + line = f"- [{_escape_link_text(_page_title(env, docname, title))}]({md_url(docname)})" + description = _page_description(env, docname) if describe else "" + return f"{line}: {description}" if description else line + + root_doc = app.config.root_doc + root = env.get_doctree(root_doc) + # A caption's own pages come first; each page with pages under it gets a section of its own. + # Each section is its caption and its (docname, llms.txt line) pairs. + sections: list[tuple[str, list[tuple[str, str]]]] = [] + optional_entries: list[str] = [] + seen: set[str] = {root_doc} + for toctree in root.findall(addnodes.toctree): + leaves: list[tuple[str, str]] = [] + sections.append((toctree.get("caption") or "Pages", leaves)) + for title, ref in toctree["entries"]: + if ref == "self": + line = f"- [{_escape_link_text(title or 'Home')}]({md_url(root_doc)})" + if app.config.llms_txt_root_description: + line += f": {app.config.llms_txt_root_description}" + leaves.append((root_doc, line)) + continue + if "://" in ref: + continue + docs = [ + doc + for doc, _ in _toctree_docs(env, ref, seen) + if not skipped(doc) and (outdir / f"{doc}.html.md").is_file() + ] + if optional(ref): + if ref in docs: + optional_entries.append(entry(ref, title, describe=False)) + continue + lines = [(doc, entry(doc, title if doc == ref else None)) for doc in docs if not optional(doc)] + if len(lines) > 1: + sections.append((_page_title(env, ref, title), lines)) + else: + leaves.extend(lines) + sections = [(caption, lines) for caption, lines in sections if lines] + ordered_docs = [doc for _, lines in sections for doc, _ in lines] + if root_doc not in ordered_docs: + ordered_docs.insert(0, root_doc) + + title = f"{app.config.project} {app.config.release}" + summary = app.config.llms_txt_description or _page_description(env, app.config.root_doc) + pages = [ + f"---\n\nSource: {md_url(doc)}\n\n" + + _absolute_links((outdir / f"{doc}.html.md").read_text(encoding="utf-8").strip(), md_url(doc)) + for doc in ordered_docs + ] + (outdir / "llms-full.txt").write_text( + "\n\n".join([f"# {title}", f"> {summary}", *pages]) + "\n", encoding="utf-8" + ) + optional_entries.append( + f"- [llms-full.txt]({site_url}/llms-full.txt): The pages in the sections above, " + "in the same order, in one file." + ) + + out = [f"# {title}", "", f"> {summary}", ""] + if app.config.llms_txt_intro: + out += [app.config.llms_txt_intro.strip(), ""] + for caption, lines in sections: + out += [f"## {caption}", "", *(line for _, line in lines), ""] + if optional_entries: + out += ["## Optional", "", *optional_entries, ""] + (outdir / "llms.txt").write_text("\n".join(out), encoding="utf-8") + logger.info("Wrote grouped llms.txt with %d sections", len(sections)) + + +def _absolute_links(markdown: str, page_url: str) -> str: + """Resolve the page's relative Markdown links against its URL, leaving code blocks alone.""" + lines = [] + in_code = False + for line in markdown.splitlines(): + fence = line.lstrip().startswith("```") + in_code ^= fence + if in_code or fence: + lines.append(line) + continue + # Odd-numbered parts are inline code spans, which stay as written. + parts = _INLINE_CODE.split(line) + for i in range(0, len(parts), 2): + parts[i] = _MARKDOWN_LINK.sub(lambda m: f"{m[1]}{urljoin(page_url, m[2])}{m[3]}", parts[i]) + lines.append("".join(parts)) + return "\n".join(lines) + + +def setup(app: Sphinx) -> dict[str, Any]: + app.setup_extension("sphinx_llm.txt") + app.set_translator(MARKDOWN_BUILDER, AirflowMarkdownTranslator, override=True) + app.add_config_value("llms_txt_site_url", "", "env") + app.add_config_value("llms_txt_source_url", "", "env") + app.add_config_value("llms_txt_release_source_url", "", "env") + app.add_config_value("llms_txt_repo_root", "", "env") + app.add_config_value("llms_txt_intro", "", "env") + app.add_config_value("llms_txt_root_description", "", "env") + app.add_config_value("llms_txt_optional_docs", [], "env") + app.add_config_value("llms_txt_skip_docs", [], "env") + app.connect("config-inited", _separate_markdown_doctrees) + app.connect("doctree-read", _link_example_sources, priority=400) + app.connect("doctree-resolved", _clean_markdown_doctree) + app.connect("build-finished", _write_llms_txt, priority=102) + return {"parallel_read_safe": True, "parallel_write_safe": True} diff --git a/providers/common/ai/docs/operations.rst b/providers/common/ai/docs/operations.rst index 0eae34cd5e6b..3a5052f72629 100644 --- a/providers/common/ai/docs/operations.rst +++ b/providers/common/ai/docs/operations.rst @@ -20,6 +20,9 @@ Reliability and operations ========================== +.. meta:: + :description: Keep AI tasks reliable and affordable: cheap retries with durable execution, model-driven retry policies, OpenTelemetry tracing, provider fallback, agent security and troubleshooting. + An AI task fails in more ways than a SQL task, and it costs money each time it runs. - :doc:`recovery` keeps an agent run going through a provider outage, and replays the diff --git a/providers/common/ai/docs/rag_pipelines.rst b/providers/common/ai/docs/rag_pipelines.rst index 96592e0e0486..2c9854e44141 100644 --- a/providers/common/ai/docs/rag_pipelines.rst +++ b/providers/common/ai/docs/rag_pipelines.rst @@ -20,6 +20,9 @@ Document and RAG pipelines ========================== +.. meta:: + :description: Build a retrieval pipeline from three ordinary tasks: load documents, embed them with LlamaIndex, and retrieve the closest chunks to answer a question with LLMOperator. + .. note:: Experimental: this can change or be removed in a minor release of this provider. diff --git a/providers/common/ai/docs/sandbox/backends.rst b/providers/common/ai/docs/sandbox/backends.rst new file mode 100644 index 000000000000..99defefa9602 --- /dev/null +++ b/providers/common/ai/docs/sandbox/backends.rst @@ -0,0 +1,830 @@ + .. Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + .. http://www.apache.org/licenses/LICENSE-2.0 + + .. Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +Sandbox backends +================ + +.. meta:: + :description: The sandbox backends that ship with the provider (Modal, OpenSandbox and sbx Docker Sandboxes), what each needs and isolates, which to use in production, and how to write your own. + +.. note:: + + Experimental: this can change or be removed in a minor release of this provider. + See :ref:`howto/stability`. + +.. _sandbox-backend-modal: + +Modal (hosted) +-------------- + +:class:`~airflow.providers.common.ai.sandbox.modal.ModalSandboxBackend` runs each +sandbox in Modal, provisioned over the API. Of the backends that ship with the +provider, **this is the managed one to use in production**, and with +:ref:`OpenSandbox `, :ref:`OpenShell `, +:ref:`Boat ` and :ref:`Islo ` one of the five a +worker on Kubernetes can use: nothing has to be installed on the worker, model-written code never executes on the worker host, and Modal reclaims +a sandbox at its own lifetime whether or not the worker survives. It needs the +``modal`` extra and Modal credentials, from a ``modal`` connection or the worker +environment, as under :ref:`Quick start `. + +Constructor parameters: + +- ``modal_conn_id``: ``modal`` connection the token and, optionally, the Modal + ``environment`` come from. Default ``"modal_default"``; ``None`` uses the worker's + credentials without looking for a connection. How a missing or partial connection + resolves is on the :ref:`Modal connection page `. A credential + problem fails the task, except in the toolset's own teardown, which logs it so a + finished run is not failed. The connection type comes from the Modal provider, which + the ``modal`` extra installs and which needs Airflow 3. +- ``image``: Registry tag for the sandbox image, or a prepared ``modal.Image`` + carrying pre-installed packages. Default ``"python:3.12-slim"``. +- ``app_name``: Modal app the sandboxes are created under. Default + ``"airflow-sandbox"``. +- ``create_app_if_missing``: Create that app if it does not exist. Default ``True``. +- ``sandbox_timeout``: Maximum lifetime of a sandbox in seconds. Default ``3600``. + Modal's own default is 300, which is below a plausible agent run. +- ``idle_timeout``: Seconds of inactivity after which Modal reclaims the sandbox, + or ``None`` to rely on ``sandbox_timeout`` alone. Default ``None``; see + :ref:`sandbox-timeouts`. +- ``workdir``: Working directory for commands, created if the image lacks it. + Default ``"/workspace"``. It is a starting directory, not a jail: absolute paths + and ``..`` are passed through, and commands run as root, so the model can read + and write anywhere in the sandbox filesystem. The sandbox boundary is what + contains that. +- ``cpu``, ``memory``, ``gpu``, ``region``, ``cloud``: passed through to Modal. + ``None`` lets Modal choose. An unrecognized ``region`` or ``cloud`` fails the + task rather than falling back. +- ``tags``: Extra Modal tags on every sandbox, e.g. ``{"dag_id": "my_dag"}``. + The backend's own ``airflow_`` keys overwrite a tag of the same name. +- ``egress_enforcement``: ``"strict"`` (default) or ``"sni"``. See below. + +**A sandbox can be provisioned by one task and used by another.** Modal finds a +sandbox by id from any process, so this backend implements +:class:`~airflow.providers.common.ai.sandbox.AttachableSandboxBackend`: a +``@task`` calls ``create`` and later ``destroy``, and a ``SandboxToolset`` with +``attach_to`` uses the sandbox in between. The ownership rules ride on Modal tags, +``airflow_owner`` from ``SandboxSpec.owner``, ``airflow_holder`` while a run holds +the sandbox, ``airflow_expires_at`` so the attaching side knows the clock and +``airflow_network`` so it knows the policy, and ``Sandbox.list(tags=...)`` finds +them. Reading tags back needs ``modal>=1.5.2``, which is the extra's floor. How +to use it is on :ref:`Configuration `. + +**Network policy.** ``block_network=True`` maps exactly onto Modal's own +``block_network``, which drops all outbound traffic including DNS. A spec that +names ``allow_egress_to`` is **refused by default**, because Modal cannot combine +an allowlist with ``block_network`` at all, and its hostname allowlist is enforced +by matching the name in the TLS handshake, which means: + +- TLS on port 443 to a listed host connects; any other host is refused at once. +- **Non-TLS traffic is dropped, not refused.** A plain HTTP connection to a listed + host stalls until the client gives up, around two minutes of TCP retries for one + address, so with the 60 s default command budget the model reads + ``[timed out after 60s]`` and concludes its command was slow, never that the + network stopped it. +- **The destination address is not part of the decision.** A connection opened to + an unrelated address while presenting a listed name is routed to the listed host + and answered by it: connecting to ``8.8.8.8:443`` with ``pypi.org`` in the + handshake returns the certificate and content of ``pypi.org``. The allowlist is a + name-routed egress proxy, not a filter on where packets may go. +- **DNS resolution stays open for every hostname**, listed or not, against + authoritative servers outside Modal. A freshly generated label under a domain the + operator controls resolves and returns its answer, so this is a two-way channel. +- A host that shares a **TLS endpoint** with a listed one can be reached by + presenting the listed name in the handshake and the other in the request. With + ``pypi.org`` as the only allowed host, a TLS session opened to + ``files.pythonhosted.org`` while presenting ``pypi.org`` was allowed through and + answered. Other tenants of the same CDN returned ``421 Misdirected Request``; it is + co-tenancy of the same TLS endpoint that matters, which you cannot check from + outside and which can change without notice. + +So the allowlist says which name a TLS session may be routed to, and nothing else. +Pass ``ModalSandboxBackend(egress_enforcement="sni")`` to say you accept that and +have the allowlist applied: + +.. code-block:: python + + SandboxToolset( + ModalSandboxBackend(egress_enforcement="sni"), + spec=SandboxSpec(block_network=True, allow_egress_to=["pypi.org", "files.pythonhosted.org"]), + ) + +Entries must be bare hostnames or one leading ``*.`` label; a URL, a ``host:port``, +an address or a single-label name is refused, because Modal applies the list without +checking it and any of those would silently match nothing. + +**An address allowlist is enforced properly, and needs no opt-in.** +``allow_egress_to_cidrs`` maps onto Modal's ``outbound_cidr_allowlist``, which +decides on the destination address for any port and protocol. Measured on +2026-09-22 with ``["1.1.1.1/32"]``: the listed address connected on 443 and on 53, +an unlisted address timed out on both, and ``block_network`` with the list set was +refused at create, as with the hostname list. This is the right mode for one +service at a fixed public address, which is the case the hostname list serves +worst. It cannot serve a package registry behind a CDN, whose addresses rotate +faster than a sandbox lives. + +.. code-block:: python + + SandboxToolset( + ModalSandboxBackend(), + spec=SandboxSpec(block_network=True, allow_egress_to_cidrs=["203.0.113.0/24", "198.51.100.7/32"]), + ) + +Four things to know about it: + +- **The address has to be public, and IPv4.** Private ranges are unreachable from a + Modal sandbox whatever the allowlist says: measured, connections to ``10.20.0.1``, + ``172.16.0.1``, ``192.168.1.1`` and the cloud metadata address timed out both under + an open network and with those ranges on the allowlist, so a service on your own private + network cannot be reached this way; it needs a public address, or a way onto your + network that Modal provides and this backend does not configure. Modal's allowlist + also rejects IPv6 ranges outright, and the sandbox has no IPv6 route, so an IPv6 + entry is refused here with the reason. + +- **Hostnames still resolve.** Modal's own resolver inside the sandbox answers + every lookup, so ``pypi.org`` resolves to its addresses and a connection to them + then times out. The tool description tells the model this so a successful lookup + is not read as a reachable host. DNS is therefore still a channel out, as it is + under the hostname list; only ``block_network=True`` with no allowlist closes it. +- **Entries are canonical CIDR.** A bare address is written as ``/32``. A range with + host bits set, such as ``203.0.113.1/24``, is refused rather than widened to + ``203.0.113.0/24``, because that is not what was written. A hostname, a + URL or a ``host:port`` is refused, since Modal would accept it and match nothing. + ``0.0.0.0/0`` and ``::/0`` are refused too: an allowlist of every address is an + open network, and ``block_network=False`` is how to ask for one. +- **Combining the two lists weakens the address one.** Modal applies them + together, and traffic matching either passes. Measured, adding ``pypi.org`` to the + hostname list beside ``["1.1.1.1/32"]`` made a TCP connection to ``8.8.8.8:443`` + succeed, because port 443 is then routed by handshake name for every address. So + a combined spec has the address list's guarantee on every port except 443, and + the hostname list's caveats there. The hostname half keeps its + ``egress_enforcement="sni"`` opt-in when combined, and the backend logs a warning + at create naming the weakening. + +**What the image needs.** ``write_file`` and ``list_directory`` use Modal's own +filesystem API, served by a helper Modal injects into the sandbox, so they need +nothing from the image. ``read_file`` deliberately does not: Modal's read API takes +no length, so it cannot honor a read budget, and a single call on a file that +streams without end (``/dev/zero``, a FIFO, a procfs entry) would pull it into +worker memory unbounded. That tool runs the base class's shell implementation, +which caps the read inside the guest, and the image needs ``stat``, ``head`` and +``base64``. Any Debian or Ubuntu based image, including ``python:*-slim``, has +them. + +**Symlinks.** Because ``write_file`` goes through the native API, writing to a path +that is a symlink replaces the link with a regular file and leaves the original +target untouched, where a shell redirect would follow the link. + +.. _sandbox-backend-islo: + +Islo (hosted microVM) +--------------------- + +:class:`~airflow.providers.common.ai.sandbox.islo.IsloSandboxBackend` runs each +sandbox in an `islo.dev `__ microVM, provisioned over the API. +Like Modal and unlike ``sbx``, the worker only speaks HTTP: it needs no local +daemon and no host virtualization, so it runs from a containerized worker and on +Kubernetes. + +Install the SDK extra: + +.. code-block:: bash + + pip install "apache-airflow-providers-common-ai[islo]" + +.. code-block:: python + + from airflow.providers.common.ai.sandbox import IsloSandboxBackend + from airflow.providers.common.ai.toolsets import SandboxToolset + + SandboxToolset(IsloSandboxBackend()) + +Credentials are ambient. On first use the SDK reads ``ISLO_API_KEY``, and optionally +``ISLO_BASE_URL`` and ``ISLO_COMPUTE_URL``, from the worker environment. Modal's +``modal`` connection comes from the Modal provider; an ``islo`` connection type waits +for an Islo provider. + +Constructor parameters: + +- ``image``, ``vcpus``, ``memory_mb``: image and sizing. ``None`` (default) uses + the server default for each. The server default image is Debian based, and any + Debian or Ubuntu based image, including ``python:*-slim``, has the GNU ``find``, + ``stat`` and ``tail`` the file operations need; Alpine and other busybox images + do not. +- ``pause_after_idle``: Seconds without a command or file operation after which + the server pauses the microVM and stops charging for its compute. Default + ``600``; ``None`` disables it. +- ``auto_resume``: ``"on_activity"`` (default) resumes a paused sandbox on the + next tool call, so a long think between calls costs a resume rather than the + run; ``"never"`` leaves it paused, and the backend then treats a paused sandbox + as unusable. +- ``delete_after``: Seconds after **creation** at which the server deletes the + sandbox, whether or not it is in use. Default ``86400``; ``None`` disables it. + This is the backstop for a worker killed mid-run; it is not renewed while the + sandbox is busy, so keep it longer than the longest run you expect. + +``SandboxSpec.env`` becomes the process environment of every command, and +``block_network`` maps to the API's ``internet_enabled``. Four things Islo cannot +do are refused at ``create`` rather than silently dropped: ``allow_egress_to`` and +``allow_egress_to_cidrs`` (the API turns outbound access on or off, with no +per-host or per-address rule), a ``PATH`` entry in ``env`` (the runner sets +``PATH`` for every command itself), and ``owner`` (this backend keeps no +per-sandbox metadata, so it cannot be attached to from another task). + +File reads, writes and exports move file contents through Islo's native +streaming APIs. Everything else runs through a shell wrapper in the sandbox, so +the image needs ``sh``, ``mkdir`` and ``rm`` for the wrapper, ``tail`` to bound +command output, ``dirname`` to create a written file's parent directory, +``stat`` to size an over-budget read and to check a file before it is exported, +``realpath`` to resolve a relative export path (the download API takes absolute +paths only), and GNU ``find`` for directory listings. The compute API caps each output stream +at 1 MiB and keeps the tail. The backend captures each stream to a scratch file in +the sandbox and returns only its last ``max_output_bytes`` -- where a traceback +and the exit status live -- so the worker sees a window sized to the caller's +budget, a budget above the server cap is clamped to it, and total output is +bounded by the sandbox's own ephemeral disk rather than by worker memory. + +The backend enforces the command deadline itself, because the API's +``timeout_secs`` is accepted but not enforced, and times it from the API's answer +to the start request, so a slow start does not use it up. Polling rides out +transient API errors until the deadline. If the command is still running when +the deadline passes, the backend deletes the microVM and reports the command as +timed out with ``sandbox_terminated`` set, so the toolset provisions a fresh +sandbox for the next call. A deletion the API refused is logged rather than +failing the task, and ``delete_after`` reclaims the microVM later; with +``delete_after=None`` nothing does, and the warning says so. If the API was still +failing at the deadline, nothing is known about the command, so the task fails +instead and Airflow's retry takes over. + +A missing file, a directory passed as a file, a relative path, and a write onto a +directory or under a pseudo-filesystem such as ``/proc`` or ``/sys`` come back to +the model as a recoverable error it can correct, once the backend has confirmed +the sandbox itself is still usable. + +.. _sandbox-backend-opensandbox: + +OpenSandbox (self-hosted remote) +-------------------------------- + +:class:`~airflow.providers.common.ai.sandbox.opensandbox.OpenSandboxBackend` +runs sandboxes through an `OpenSandbox `__ server. +The server may use Docker or Kubernetes; Airflow workers only use its HTTP API +and do not need access to the container runtime. + +Install the SDK extra: + +.. code-block:: bash + + pip install "apache-airflow-providers-common-ai[opensandbox]" + +Use a generic Airflow connection, resolved lazily on first use: + +.. code-block:: python + + from airflow.providers.common.ai.sandbox import OpenSandboxBackend + from airflow.providers.common.ai.toolsets import SandboxToolset + + SandboxToolset(OpenSandboxBackend(opensandbox_conn_id="opensandbox_default")) + +The connection ``host`` is required; ``port`` is optional, ``schema`` defaults to +``http``, and ``password`` carries the API key when required. Extras may set +``request_timeout`` (default 30 seconds) and ``use_server_proxy`` (default +``true``). Set ``opensandbox_conn_id=None`` to let the SDK read +``OPEN_SANDBOX_DOMAIN`` and ``OPEN_SANDBOX_API_KEY``. + +``SandboxSpec.env`` is sent at creation. A default spec sends a deny-all +network policy; ``allow_egress_to`` becomes explicit allow rules. With +``block_network=False``, the backend omits network policy entirely so a +deployment without the egress sidecar can still run an intentionally open +sandbox. Deny/allowlist policy requires the sidecar, so the backend reads the +enforced policy back after creation and destroys the sandbox if it does not +match the requested spec. ``allow_egress_to_cidrs`` is refused; this backend does +not translate address ranges into OpenSandbox rules. + +The read-back also checks the mode the sidecar enforces the policy in, set by +``[egress] mode`` in the server configuration. Only ``dns+nft`` drops connections at +the address layer. In ``dns`` mode, the server's default, the sidecar filters name +resolution and nothing else, so a deny-all sandbox could still connect to any +numeric address, including a DNS-over-HTTPS resolver that would look up any name for +it, and a sandbox with an allowlist could connect to addresses outside the list. The +backend destroys the sandbox and fails the task on any mode but ``dns+nft``, so set +``mode = "dns+nft"`` on a server that runs sandboxes with a deny-all policy or an +allowlist, or pass ``SandboxSpec(block_network=False)`` for a sandbox that may reach +the network. + +Every sandbox carries ``created-by: airflow`` metadata and an +``airflow-sandbox-*`` name for attribution and cleanup. The server enforces a +sandbox lifetime (default 3600 seconds). If the SDK event stream stalls, the +worker abandons the call after the command budget plus a grace period, destroys +the sandbox, and reports ``sandbox_terminated`` so the toolset provisions a fresh +one. Output is bounded per stream after the SDK yields it; a single newline-free +line is the SDK-level exception, because the SDK assembles that line before the +backend sees it. + +Constructor parameters: + +- ``image``: image used by the server. Default ``"python:3.12-slim"``. +- ``cpu`` and ``memory``: resource limits. Defaults ``"1"`` and ``"2Gi"``. +- ``sandbox_timeout``: server-side lifetime in seconds. Default ``3600``. +- ``ready_timeout``: provisioning/reconnect timeout. Default ``120``. +- ``use_server_proxy``: override the connection extra for file and command calls. + +The runtime remains a deployment choice. The default Docker runtime shares the +host kernel; choose a stronger runtime such as Kata when your threat model needs +a VM boundary. + +.. _sandbox-backend-openshell: + +OpenShell (self-hosted remote) +------------------------------ + +:class:`~airflow.providers.common.ai.sandbox.openshell.OpenShellSandboxBackend` +runs sandboxes through an `NVIDIA OpenShell `__ +gateway, which runs each one on Docker, Podman or Kubernetes. Inside the +container the workload is confined by Landlock and seccomp; on the Docker driver it +has only a loopback network interface, and a per-sandbox supervisor opens every +outbound connection on its behalf, against a policy the backend writes and reads back. Airflow workers +only need gRPC access to the gateway. + +Choose it over :ref:`OpenSandbox ` when you want the +sandbox runtime itself to enforce deny-all and the hostname allowlist, rather than +an egress sidecar that has to run in the right mode. It is Apache-2.0 and runs on a +single machine with no account, so it is also the self-hosted backend to try first +on a laptop. For a production gateway on Kubernetes, prefer OpenSandbox or Modal: +this backend has been verified on OpenShell's Docker driver only, which OpenShell +scopes to local development and single-machine gateways. + +Install the SDK extra: + +.. code-block:: bash + + pip install "apache-airflow-providers-common-ai[openshell]" + +**Credentials are ambient; there is no Airflow connection for this backend.** +The gateway's endpoint, mTLS material and OIDC token live in the gateway +registration that the ``openshell`` CLI keeps under +``$XDG_CONFIG_HOME/openshell/gateways//`` (``~/.config`` by default), and +the OpenShell SDK reads them from there itself: ``metadata.json`` with the +endpoint, and ``mtls/ca.crt``, ``mtls/tls.crt`` and ``mtls/tls.key`` for mTLS, +or the CLI's cached token for an OIDC gateway. The backend only names the +registration. A worker without the CLI needs the same files, provisioned by the +Deployment Manager: + +.. code-block:: json + + {"name": "prod", "gateway_endpoint": "https://openshell.example.com:17670", "auth_mode": "mtls"} + +.. code-block:: python + + from airflow.providers.common.ai.sandbox import OpenShellSandboxBackend + from airflow.providers.common.ai.toolsets import SandboxToolset + + SandboxToolset(OpenShellSandboxBackend(gateway="prod")) + +An OIDC registration must be writable and per worker. The SDK refreshes an +expiring OIDC token itself and writes the new one back into the registration, +so a registration mounted read-only, from a Kubernetes Secret or ConfigMap for +example, fails the task at the first refresh, and copies of one registration on +several workers share a refresh token that the first refresh can invalidate for +the others. mTLS is the supported setup for workers that mount the registration +read-only. + +Whoever holds that credential is inside the trust boundary. On a gateway +without OIDC, an mTLS client is a gateway-wide administrator: it can change the +policy and settings of every sandbox. ``openshell-gateway generate-certs`` issues +a single client identity whose certificate does not expire for practical +purposes, so use your own PKI, with expiry and rotation, for a worker credential. + +**Network policy.** A default ``SandboxSpec()`` sends a policy with no egress +rule, which OpenShell enforces as no egress: a connection fails with +``EACCES``, and a name lookup is answered by the supervisor with a synthetic +``198.18.0.0/15`` address rather than failing, so no query leaves the sandbox +although the tool description's "including DNS" wording reads stricter than the +lookup behaves. ``allow_egress_to`` becomes one rule admitting each listed host +on port 443 for any program in the sandbox; ports are part of every rule, so +plain HTTP and other ports stay closed. HTTPS to a listed host is terminated by +the supervisor, which injects its CA through ``SSL_CERT_FILE``, +``REQUESTS_CA_BUNDLE`` and similar variables; a client with its own trust store +(a JVM, a statically linked binary) has to be pointed at it. A leading ``*.`` +label is accepted on a name of three labels or more. + +The backend verifies the policy rather than trusting the request. After create +it reads the effective policy back and destroys the sandbox unless it admits +exactly the requested hosts, comes from the sandbox rather than a gateway-wide +policy, keeps Landlock at ``hard_requirement``, and has neither +``proposal_approval_mode=auto`` nor agent policy proposals enabled at any scope. +Auto-approval is refused because OpenShell turns a denied connection into a +proposed allow rule and, in that mode, approves it without review. The same +check runs before every command and file operation and after each one that +succeeds, because an administrator, an approved +draft or a gateway-wide policy can widen a running sandbox; a change destroys the +sandbox and fails the task. That detects a widening, it does not prevent one: a +command already running when the policy changes can use it. The check sees +OpenShell's policy, not the network under the gateway: on Kubernetes, a sandbox +pod is kept behind its supervisor by a NetworkPolicy, which only a CNI that +enforces NetworkPolicy upholds. Every denied connection also becomes a draft +proposal in the gateway's approval inbox, even in manual mode, so operators see +which destinations an agent tried. + +Refused at create: ``block_network=False`` (every OpenShell rule names a host and +its ports, so an open network cannot be expressed), ``allow_egress_to_cidrs`` +(address rules admit TCP on listed ports only), ``SandboxSpec.owner``, and +``SandboxSpec.env`` keys the supervisor owns: it removes ``HTTP_PROXY`` and the +other proxy variables from every command and replaces ``SSL_CERT_FILE``, +``REQUESTS_CA_BUNDLE``, ``CURL_CA_BUNDLE``, ``GIT_SSL_CAINFO``, +``NODE_EXTRA_CA_CERTS`` and ``DENO_CERT`` with its own, without an error, and +reserves ``OPENSHELL_*``. Keys starting with ``_airflow_`` are refused too, because the +command wrapper below names its own shell variables that way. Everything else in +``SandboxSpec.env``, ``PATH`` included, reaches commands as given, since they run +without a login shell. + +**Commands.** OpenShell's own exec timeout reports exit 124 and leaves the +command running, so the backend runs each command through a small shell wrapper +in the sandbox. The command arrives on stdin and runs in a session of its own, +with the command and its output spooled to ``/tmp``; one that cannot be written +there, because ``/tmp`` is full for example, is not run and is reported as an +error. When the budget runs out the wrapper kills the processes in that session, +scanning again until a pass finds none to kill, at most 50 times, and returns the +tail of each stream. A process the command left in the background keeps running +after a command that finishes in time, and one that started a session of its own +(``setsid``, a daemonizing server) escapes the kill on timeout, as can a command +that keeps forking faster than the sweep. If the gateway stops relaying the +command for longer than its budget plus 30 seconds, ``sandbox_terminated`` is +reported and the backend asks the gateway to delete the sandbox; if that call +fails too, it logs a warning and the sandbox is left for the reaper described +below. Nothing crosses the stream +until the command ends, so a proxy or load balancer in front of the gateway +needs an idle timeout longer than the longest command budget plus 30 seconds. A +command the gateway could not start, because its relay into the sandbox did not +open, is reported to the model as not run. A gateway restart stops every process +in its sandboxes. If the gateway brings the sandbox back, its files are kept and a +command in flight is reported to the model as having an unknown outcome rather +than retried; if it does not, the task fails. A dropped connection to a gateway +that stays up is reported the same way, but does not stop the command: it runs +until its budget runs out, and the model is told it may still be running. + +**Files.** ``write_file`` sends content on stdin in chunks of 768 KiB, since the +gateway limits one command argument to 32 KiB and one request to 1 MiB; a larger +write is not atomic, and it follows a symlink like a shell redirect. ``read_file`` +transfers raw bytes, capped inside the guest. Both refuse a named pipe, since +opening one waits for another process and nothing would end the wait in the +sandbox; ``run_command`` with a timeout can still read or write one. The image needs ``setsid`` (from +util-linux), GNU coreutils and findutils, and a ``/bin/sh`` that is dash or bash, +which ``python:*-slim`` and other Debian or Ubuntu based images have; an image +without ``setsid`` fails the task at its first command. BusyBox ``ash``, the +``/bin/sh`` of Alpine images, is not supported: the timeout sweep does not finish +under it, so a command that runs out of time is not killed, and after its budget +plus 30 seconds the backend asks the gateway to delete the sandbox instead. The gateway's own default image has no ``python3``, which is +why the backend defaults to ``python:3.12-slim``. + +**Cleanup.** OpenShell has no server-side sandbox lifetime. ``destroy`` deletes +the sandbox, but one whose worker died is kept until someone deletes it, even +after its main process has ended. Sandboxes are named ``airflow-`` plus 11 hex +characters, within OpenShell's 19-character limit, and labeled +``created-by=airflow`` and ``airflow-created-at=``, so a reaper can +delete by age: + +.. code-block:: python + + import time + + from openshell import SandboxClient + + client = SandboxClient.from_active_cluster(cluster="prod") + cutoff = time.time() - 6 * 3600 + for sandbox in client.list_all(workspace="default", label_selector="created-by=airflow"): + if int(sandbox.labels.get("airflow-created-at", "0")) < cutoff: + client.delete(sandbox.name, workspace="default", allow_missing=True) + +Constructor parameters: + +- ``gateway``: the CLI gateway registration to use. ``None`` (default) uses + ``$OPENSHELL_GATEWAY``, then the CLI's active gateway. +- ``workspace``: OpenShell workspace. Default ``"default"``. +- ``image``: image used by the gateway. Default ``"python:3.12-slim"``. +- ``cpu`` and ``memory``: resource limits as Kubernetes quantities. Defaults + ``"1"`` and ``"2Gi"``. ``nproc`` in the sandbox still reports the host's CPUs. +- ``ready_timeout``: seconds to wait for a new sandbox. Default ``120``; a first + pull of a large image can take longer, so pre-pull it on the gateway host. +- ``request_timeout``: seconds for each gateway call other than a command. + Default ``30``. + +The kernel the sandboxes run on needs Landlock ABI 3 or later (Linux 6.2+) and +seccomp user notification, and the gateway needs Docker 28 or later, Podman 5, or +a Kubernetes cluster with the Agent Sandbox controller. On macOS the gateway runs +against the Linux VM of a Docker runtime such as OrbStack or colima. OpenShell scopes its Docker driver to +local development and single-machine gateways. This backend has been verified with +the Docker driver only; on Kubernetes, egress enforcement also depends on the +cluster's CNI enforcing NetworkPolicy. The gateway sends anonymous +telemetry unless it runs with ``OPENSHELL_TELEMETRY_ENABLED=false``. + +.. _sandbox-backend-boat: + +Boat (hosted) +------------- + +:class:`~airflow.providers.common.ai.sandbox.boat.BoatSandboxBackend` runs each +sandbox on `Boat `__, the hosted cloud-computer +API formerly called Ascii Box. The Airflow worker needs only network access and +an API key: no local daemon, Docker socket, KVM or nested virtualization, so it +runs from a containerized worker and on Kubernetes. + +Install the SDK extra: + +.. code-block:: bash + + pip install "apache-airflow-providers-common-ai[boat]" + +.. code-block:: python + + from airflow.providers.common.ai.sandbox import BoatSandboxBackend, SandboxSpec + from airflow.providers.common.ai.toolsets import SandboxToolset + + SandboxToolset( + BoatSandboxBackend(), + spec=SandboxSpec(block_network=False), + ) + +Credentials can come from a generic Airflow connection, resolved lazily on first +use: + +.. code-block:: python + + SandboxToolset( + BoatSandboxBackend(boat_conn_id="boat_default"), + spec=SandboxSpec(block_network=False), + ) + +The connection ``password`` is the Boat API key and is required. ``host``, when +set, is the full API base URL, such as ``https://boat.dev/api/v1``, which is also +the default. It must start with ``https://`` or ``http://``: a bare domain such as +``boat.dev``, which is what Airflow's connection URI form leaves in ``host``, is +refused, since the API key would otherwise be sent to it over plain HTTP. With +``boat_conn_id=None``, the default, the backend reads ``BOAT_API_KEY`` (required) +and optional ``BOAT_BASE_URL`` from the worker environment instead, and +``BOAT_BASE_URL`` must carry the scheme too. + +Constructor parameters: + +- ``org``: the Boat wallet each sandbox is billed to, by organization id or name, + or ``"personal"``. Default ``"personal"``, which bills your own account whatever + its active wallet is. See the warning below before naming an organization. +- ``machine_type``: ``"small"``, ``"default"`` or ``"large"``. +- ``ttl_seconds``: server-side TTL after which Boat stops the sandbox, a whole + number of seconds up to ``2592000`` (30 days). Default ``3600``. +- ``ready_timeout``: provisioning deadline in seconds, from the create request + until the sandbox is ready. Default ``300``. +- ``request_timeout``: HTTP timeout in seconds for an API call that answers at + once, such as the create request, a status check or a delete, and the time + added to the operation's own for a call that waits on one: a command's + deadline, or 120 seconds for a file write. Default ``30``. + +A create request that times out, fails in transport, or gets a server error may +still have started a sandbox, so it is sent again with the same idempotency key, +and Boat answers with the sandbox the first request created rather than starting +a second one. While Boat is still creating that sandbox, it answers the resent +request with 409 ``idempotency_in_progress``, and the backend sends it again two +seconds after each such answer until ``ready_timeout`` runs out. Each resend gets +what is left of ``ready_timeout`` plus ``request_timeout``, so provisioning takes +at most their sum, and a sandbox a resend finds too late to become ready in time +is deleted rather than left running until its TTL. If a resend fails any other +way, or Boat is still creating the sandbox when ``ready_timeout`` runs out, the +backend never receives the sandbox's id, so any sandbox the first request started +keeps a server-assigned name and runs until Boat stops it at ``ttl_seconds``. + +Every sandbox is created with Boat's ``noEnv`` flag, so it gets none of your Boat +account's stored environment variables, secret files or credentials, and cannot +act on your account or your other sandboxes. + +.. warning:: + + Boat gives every member of an organization use of a ``noEnv`` sandbox billed + to that organization: they can open it and run commands in it, so they can + read and write anything in it, including the ``SandboxSpec.env`` values each + command receives. Pass ``org`` only when everyone in that organization may see + what the agent works on. + +``SandboxSpec.env`` is passed when the sandbox is created and also exported at +the start of every command, so each value is sent again with every command +request. **Boat cannot enforce a deny-all network policy, a per-domain egress +allowlist, or a CIDR egress allowlist**, so the backend refuses +``block_network=True``, ``allow_egress_to``, and ``allow_egress_to_cidrs`` +rather than silently provisioning something weaker than the spec asked for. +Since ``block_network`` defaults to ``True``, that includes a bare +``SandboxSpec()``: pass ``SandboxSpec(block_network=False)`` to state that open +egress is acceptable, or use Modal when it is not. + +Writes use Boat's native file API, which accepts only paths that resolve under +``/home/user`` (where relative paths land) or ``/tmp``. The parent directory is +created first with ``mkdir -p`` in the guest, so a ``write_file`` anywhere else +fails with ``mkdir``'s own error when the guest user cannot create the parent +directory, and with Boat's ``invalid_path`` error when that directory exists or +could be created. Either way the model gets it back as a tool error it can +retry. Reads deliberately keep the inherited bounded shell implementation, so +``max_bytes`` is enforced inside the guest before file contents reach worker +memory. + +That path rule binds only ``write_file``; it is not a jail. Commands run as the +guest user ``user``, which `Boat documents `__ as +having root through ``sudo`` with no password, so a command the model writes can +read and write anywhere in the sandbox filesystem. The sandbox also has a public +IPv4 or IPv6 address, and its firewall is inside the guest: Boat's +`hosting guide `__ opens a port to the internet +with ``ufw``, which a command can do too. The sandbox boundary is what contains +that. + +A command's deadline is enforced inside the sandbox by GNU coreutils +``timeout``, which sends ``SIGTERM`` and then ``SIGKILL`` five seconds later, so +a command that runs out of time returns the tail of what it printed, and the +sandbox and its files survive. Boat's own deadline is set 15 seconds past that +one, and Boat's API caps it at 600 seconds, so any command that asks for more +than 585 seconds gets 585, and the result reports that deadline to the model. +Only when Boat's own deadline ends the call, because the one in the guest did +not, is the sandbox torn down, as is a sandbox that never becomes ready. A file +read, listing, or write that Boat's deadline ends that way fails the task, since +there is no sandbox left for the model to retry against. If the worker dies +first, the server-side TTL stops the sandbox. Sandboxes are created without +snapshots, so stopping one erases its disk rather than keeping it for an +operator to remove, and with monitoring off, so Boat keeps no history of the +commands, their output, or the environment variables exported into them. + +.. _sandbox-backend-sbx: + +sbx (Docker Sandboxes, local) +----------------------------- + +:class:`~airflow.providers.common.ai.sandbox.SbxSandboxBackend` runs each sandbox +in a Docker Sandboxes microVM by driving the ``sbx`` CLI. Each sandbox is a real +microVM with its own kernel. + +.. warning:: + + **Use this backend for local development, not production.** Docker Sandboxes + is built for running coding agents against a checkout on your own machine, and + driving it from an Airflow worker is off-label use. A production worker would + need the ``sbx`` binary on the host, an authenticated Docker account + (``sbx login``), a one-time ``sbx policy init``, and on Linux, KVM or nested + virtualization, which a worker in an unprivileged container cannot provide. + + **Orphans are not reclaimed.** There is no server-side lifetime. If the worker is + killed outright, the microVM and its workspace directory survive; sandboxes are + named ``airflow-sandbox-*`` so an operator can find and remove them. + +Installing the CLI is a Deployment Manager prerequisite (``brew install +docker/tap/sbx`` or ``winget install Docker.sbx``); the backend needs no Python +dependency. The template image must provide GNU coreutils ``timeout``, ``base64``, +``stat``, ``head``, ``find``, ``mkdir`` and ``dirname``, which any Debian or Ubuntu +based image has. + +Constructor parameters: + +- ``image``: Container image for the sandbox. Default ``"python:3.12-slim"``. +- ``memory``: Memory limit in binary units. ``sbx`` enforces a 1 GiB minimum. + Default ``"2g"``. +- ``cpus``: CPUs to allocate. ``None`` (default) uses the ``sbx`` default, which + is every host CPU. +- ``sbx_path``: Path to the ``sbx`` binary. Default ``"sbx"``. +- ``create_timeout``: Seconds allowed for provisioning; a first-run microVM boot + plus an image pull can be slow. Default ``600``. +- ``host_network_policy``: What ``sbx policy`` is set to on this host. + ``"unknown"`` (default) makes ``create`` refuse any spec asking for a network + guarantee this backend cannot make, and since ``block_network`` defaults to + ``True`` that includes a bare ``SandboxSpec()``. Set ``"deny-all"`` after running + ``sbx policy init deny-all``, or ``"allow-all"`` to state that egress is open + and pass ``SandboxSpec(block_network=False)`` to match. + +The ``sbx`` CLI has no way to pass environment variables at creation, so the backend +writes ``SandboxSpec.env`` as ``export`` lines to ``/etc/profile`` inside the +sandbox. Anything in the sandbox can read that file for as long as the sandbox +exists. + +.. _sandbox-backend-differences: + +What differs between the backends +--------------------------------- + +Swapping the backend is one constructor argument, and tool names, spec and prompt +do not change. Four behaviours do, so read them before assuming the same Dag +behaves identically everywhere: + +- **CPU.** ``sbx`` gives a sandbox every host CPU; Modal defaults to a request of + 0.125 of one, so set ``cpu``; OpenSandbox and OpenShell take ``cpu`` as a limit the + server enforces; Boat sizes by ``machine_type``; Islo uses the server default unless + you set ``vcpus``. +- **Egress allowlists.** ``sbx`` enforces ``allow_egress_to`` at the host policy + layer; Modal matches TLS handshake names, which is weaker and has to be opted + into; OpenSandbox enforces it in an egress sidecar, and the backend reads the + enforced policy and the sidecar's mode back rather than trusting the create + request, refusing a sidecar that filters only name resolution (``dns``) rather + than connections (``dns+nft``); OpenShell enforces it in a per-sandbox supervisor + on port 443 only, and reads the effective policy back at create and around every + operation. ``allow_egress_to_cidrs`` is enforced at the address layer on Modal and + refused on ``sbx``, OpenSandbox, OpenShell and Islo; OpenShell's address rules admit + TCP on listed ports only, and it also refuses ``block_network=False``. Islo has no + per-host form and refuses the spec; Boat has no form of egress control at all and + refuses every network restriction. Both refuse rather than provision something + weaker. +- **Command timeouts.** A timeout destroys an ``sbx`` or Islo sandbox and its files; + Modal, Boat and a server-enforced OpenSandbox timeout preserve the sandbox and + files. OpenSandbox destroys it only if the command event stream itself stalls + past the client-side grace period, and Boat only if its own deadline, set past + the one in the guest, ends the call. OpenShell kills the command's session and + keeps the sandbox; if the gateway stops relaying the command, the backend asks it + to delete the sandbox, and only a delete that fails too leaves it for the reaper + described under :ref:`OpenShell `. +- **Symlinks.** ``write_file`` through a symlink follows the link on ``sbx``, Boat + and OpenShell, which write the target and leave the link in place, and replaces + the link with a regular file on Modal and OpenSandbox. +- **Attaching.** A Modal sandbox can be provisioned by one task and used by an + agent in another (:ref:`sandbox-attach`). An ``sbx`` microVM lives on the worker + that created it and cannot be reached from another task, OpenSandbox, Boat and + Islo have no per-sandbox metadata the ownership rules could be kept in, and + OpenShell does not implement attaching yet, so all five refuse ``SandboxSpec.owner`` + and the toolset refuses ``attach_to`` for them. + +.. _sandbox-byo: + +Bringing your own backend +------------------------- + +Any vendor that can create a sandbox, run a command in it and destroy it can plug +in. Subclass :class:`~airflow.providers.common.ai.sandbox.SandboxBackend` in your +own package and pass an instance to ``SandboxToolset``. + +**Three methods are required**: ``create``, ``run_command`` and ``destroy``. The +file operations ship as defaults implemented over ``run_command``, because +reading, writing, listing and exporting a file are all expressible as shell +commands. The default ``export_file``, behind ``SandboxToolset(exports=...)``, +copies a file in 4 MiB slices, one command each, and needs ``stat``, ``tail``, +``head`` and ``base64`` in the guest. It relies on ``run_command`` returning each +slice's output intact, or setting ``stdout_truncated`` when it could not. Override +it when the vendor can stream a download, as the ``sbx``, OpenSandbox and Islo +backends do. Override the others only when the vendor has a native file API: + +.. code-block:: python + + from airflow.providers.common.ai.sandbox import ( + SandboxBackend, + SandboxExecResult, + SandboxSpec, + ) + + + class AcmeSandboxBackend(SandboxBackend): + name = "acme" + + def create(self, *, spec: SandboxSpec | None = None) -> str: + return acme_sdk.create_sandbox().id + + def run_command(self, sandbox, command, *, timeout, max_output_bytes): + r = acme_sdk.exec(sandbox, command, timeout=timeout) + return SandboxExecResult(exit_code=r.exit_code, stdout=r.stdout, stderr=r.stderr) + + def destroy(self, sandbox) -> None: + acme_sdk.delete_sandbox(sandbox) + + # Optional: inherited from SandboxBackend unless the vendor has + # something better than shelling out. + def read_file(self, sandbox, path, *, max_bytes) -> bytes: + return acme_sdk.download(sandbox, path, limit=max_bytes) + +Four rules for an implementation: + +- Constructors run at Dag-parse time, so resolve credentials lazily, on first use. +- ``destroy`` must be idempotent; destroying an already-gone sandbox is not an error. +- Raise ``SandboxTerminalError`` when retrying cannot help and ``SandboxError`` + when it might. The first fails the task for Airflow to retry; the second + becomes a bounded prompt back to the model. +- If you cannot enforce something the ``SandboxSpec`` asks for, **raise**. Never + provision a weaker sandbox than the Dag author asked for. + +**If your sandboxes can be found again from another process**, subclass +:class:`~airflow.providers.common.ai.sandbox.AttachableSandboxBackend` instead, +and a ``@task`` can provision a sandbox for an agent task to attach to +(:ref:`sandbox-attach`). It adds two methods, ``read_tags`` and ``write_tags``, +over whatever key-value metadata the vendor keeps on a sandbox, and the ownership +rules are written once on the base class on top of them. Three things the base +class relies on: ``read_tags`` raises ``SandboxTerminalError`` for a sandbox that +does not exist or has ended; ``write_tags`` replaces the whole set, because +releasing a claim is a rewrite without the holder key; and ``create`` stamps +``SandboxSpec.owner`` under ``OWNER_TAG``, the sandbox's end time as Unix seconds +under ``EXPIRES_AT_TAG``, and the network policy under ``NETWORK_TAG`` using +``encode_network_policy(spec)``, all importable from +``airflow.providers.common.ai.sandbox.base``. If the vendor lets a caller of your +backend set metadata too, make your reserved keys overwrite theirs. Stamping the +working directory under ``WORKDIR_TAG`` is optional; without it the attaching +backend asks the sandbox. The toolset shortens ``run_command`` to the remaining +lifetime itself; a backend clamps only if its own file operations need it. diff --git a/providers/common/ai/docs/sandbox/configuration.rst b/providers/common/ai/docs/sandbox/configuration.rst index 34129a3d245b..db008a3589af 100644 --- a/providers/common/ai/docs/sandbox/configuration.rst +++ b/providers/common/ai/docs/sandbox/configuration.rst @@ -18,6 +18,9 @@ Configure a sandbox =================== +.. meta:: + :description: Configure what a sandbox is provisioned with (network, environment, credentials), get results out of it, share one between tasks, and how it behaves on failure, retry and cleanup. + .. note:: Experimental: this can change or be removed in a minor release of this provider. diff --git a/providers/common/ai/docs/tool_approval.rst b/providers/common/ai/docs/tool_approval.rst index 425054b19603..f1ae3d4872e9 100644 --- a/providers/common/ai/docs/tool_approval.rst +++ b/providers/common/ai/docs/tool_approval.rst @@ -20,6 +20,14 @@ Approve an agent's tool calls ============================= +.. meta:: + :description: Pause an agent before it runs a tool you marked for approval, such as one that refunds an order or writes to a table, and let a person approve or reject that call from the Required Actions page. + +.. note:: + + Experimental: this can change or be removed in a minor release of this provider. + See :ref:`howto/stability`. + .. seealso:: To approve, edit or reject an LLM operator's output instead, see :doc:`approval_gates`; to review an agent's final answer over several rounds, see :doc:`hitl_review`. diff --git a/uv.lock b/uv.lock index cedd5d8256d6..c544d2966f80 100644 --- a/uv.lock +++ b/uv.lock @@ -2785,6 +2785,7 @@ docs = [ { name = "sphinx-copybutton" }, { name = "sphinx-design" }, { name = "sphinx-jinja" }, + { name = "sphinx-llm" }, { name = "sphinx-rtd-theme" }, { name = "sphinxcontrib-applehelp" }, { name = "sphinxcontrib-devhelp" }, @@ -2974,6 +2975,7 @@ requires-dist = [ { name = "sphinx-copybutton", marker = "extra == 'docs'", specifier = ">=0.5.2" }, { name = "sphinx-design", marker = "extra == 'docs'", specifier = ">=0.5.0" }, { name = "sphinx-jinja", marker = "extra == 'docs'", specifier = ">=2.0.2" }, + { name = "sphinx-llm", marker = "extra == 'docs'", specifier = ">=1.1.0,<1.2" }, { name = "sphinx-rtd-theme", marker = "extra == 'docs'", specifier = ">=2.0.0" }, { name = "sphinxcontrib-applehelp", marker = "extra == 'docs'", specifier = ">=1.0.4" }, { name = "sphinxcontrib-devhelp", marker = "extra == 'docs'", specifier = ">=1.0.2" }, @@ -24846,6 +24848,39 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/20/9f/81fe50b1861bda8c02b4272a166d14455411e04865ddaf3616f25d12cd50/sphinx_jinja-2.0.2-py3-none-any.whl", hash = "sha256:705ebeb9b7a6018ca3f93724315a7c1effa6ba3db44d630e7eaaa15e4ac081a8", size = 4355, upload-time = "2022-07-05T11:57:47.861Z" }, ] +[[package]] +name = "sphinx-llm" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py" }, + { name = "sphinx", version = "8.1.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" }, + { name = "sphinx", version = "9.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, + { name = "sphinx-markdown-builder" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9b/2b/2529cb0b1acb85489167904649387ea7b17e3172ac3286fc0c8af2887bc5/sphinx_llm-1.1.0.tar.gz", hash = "sha256:5f3b41c0d7888c75a6fe9f92b1a965c50ee233eaf38673c0ef3501072599c617", size = 408770, upload-time = "2026-09-21T10:15:26.81Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/06/8db70029d13ae3b5ef4dabd7496e15941f0f700b9e2f1fb77859bef97263/sphinx_llm-1.1.0-py3-none-any.whl", hash = "sha256:40cfadbfeb4483f4fd5b6c1c0b1a48152847f30febfa94fc413bbbe09c137953", size = 85878, upload-time = "2026-09-21T10:15:25.627Z" }, +] + +[[package]] +name = "sphinx-markdown-builder" +version = "0.6.11" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "docutils", version = "0.21.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "docutils", version = "0.22.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, + { name = "sphinx", version = "8.1.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, + { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" }, + { name = "sphinx", version = "9.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, + { name = "tabulate" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ad/13/102d7134743120db25e636ffb57a30818e95a416583dca83aadac9c5dd87/sphinx_markdown_builder-0.6.11.tar.gz", hash = "sha256:ba3bf33e0e42ff30ae686ac73957a95e6d045790dcfbaca012dd8ae01794e577", size = 24020, upload-time = "2026-08-16T06:51:38.158Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c9/71/06b415631c2e494c80546073b46013d1715dceb3abe30bd63b34b4e7d9ca/sphinx_markdown_builder-0.6.11-py3-none-any.whl", hash = "sha256:acfb94d6ee66c7a47da0ca0420578fa16f115812af25b8fd21755d5909aacf51", size = 18088, upload-time = "2026-08-16T06:51:36.81Z" }, +] + [[package]] name = "sphinx-rtd-theme" version = "3.1.0" From 82388d4b9975eefd42cb9a5859e31ee327871c88 Mon Sep 17 00:00:00 2001 From: Sameer Mesiah Date: Fri, 9 Oct 2026 23:53:08 +0100 Subject: [PATCH 2/6] Add tests and Markdown redirect coverage for LLM docs Generate Markdown redirect stubs and fail builds with missing Markdown copies. Add tests for the extension, redirect resolution and example source references. Fix navigation caption rendering in Markdown. --- devel-common/src/docs/provider_conf.py | 30 +- devel-common/src/docs/utils/example_source.py | 43 ++ .../src/sphinx_exts/airflow_llms_txt.py | 99 ++- devel-common/src/sphinx_exts/redirects.py | 42 +- .../unit/docs/utils/test_example_source.py | 71 ++ .../unit/sphinx_exts/test_airflow_llms_txt.py | 640 ++++++++++++++++++ .../tests/unit/sphinx_exts/test_redirects.py | 153 ++++- uv.lock | 353 ++++++---- 8 files changed, 1206 insertions(+), 225 deletions(-) create mode 100644 devel-common/src/docs/utils/example_source.py create mode 100644 devel-common/tests/unit/docs/utils/test_example_source.py create mode 100644 devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py diff --git a/devel-common/src/docs/provider_conf.py b/devel-common/src/docs/provider_conf.py index c80e00a8134e..22f8159263ec 100644 --- a/devel-common/src/docs/provider_conf.py +++ b/devel-common/src/docs/provider_conf.py @@ -33,7 +33,6 @@ # serve to show the default. import logging import os -import subprocess from typing import Any import rich @@ -65,6 +64,7 @@ get_intersphinx_mapping, get_rst_epilogue, ) +from docs.utils.example_source import example_source_ref from sphinx_exts.provider_yaml_utils import load_package_data PACKAGE_NAME = os.environ.get("AIRFLOW_PACKAGE_NAME", "") @@ -154,37 +154,11 @@ ] -def _example_source_ref(tag: str) -> str: - """ - Return the git ref example source links point at: HEAD if it is pushed, else the release tag. - - Docs built from ``main`` describe more than the last release, so linking the tag there would - point at example files that do not exist in it yet. A HEAD no remote branch or tag contains, - such as the commit the docs publish workflow makes when it cherry-picks fixes onto a release - tag, does not exist on GitHub, so those builds link the tag. - """ - - def git(*args: str) -> str: - try: - result = subprocess.run( - ["git", *args], cwd=AIRFLOW_REPO_ROOT_PATH, capture_output=True, text=True, check=False - ) - except OSError: # no git, e.g. building from an sdist - return "" - return result.stdout.strip() - - head = git("rev-parse", "--verify", "--quiet", "HEAD^{commit}") - if not head or head == git("rev-parse", "--verify", "--quiet", f"{tag}^{{commit}}"): - return tag - pushed = git("for-each-ref", "--contains", head, "--count=1", "refs/remotes", "refs/tags") - return head if pushed else tag - - if PACKAGE_NAME in PROVIDER_PACKAGES_WITH_LLMS_TXT: extensions.append("airflow_llms_txt") llms_txt_site_url = f"https://airflow.apache.org/docs/{PACKAGE_NAME}/{PACKAGE_VERSION}/" _release_tag = f"providers-{PACKAGE_ID.replace('.', '-')}/{PACKAGE_VERSION}" - llms_txt_source_url = f"https://github.com/apache/airflow/blob/{_example_source_ref(_release_tag)}/" + llms_txt_source_url = f"https://github.com/apache/airflow/blob/{example_source_ref(_release_tag)}/" llms_txt_release_source_url = f"https://github.com/apache/airflow/blob/{_release_tag}/" llms_txt_repo_root = AIRFLOW_REPO_ROOT_PATH.as_posix() llms_txt_intro = ( diff --git a/devel-common/src/docs/utils/example_source.py b/devel-common/src/docs/utils/example_source.py new file mode 100644 index 000000000000..2b1c614f6247 --- /dev/null +++ b/devel-common/src/docs/utils/example_source.py @@ -0,0 +1,43 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +import subprocess + +from docs.utils.conf_constants import AIRFLOW_REPO_ROOT_PATH + + +def example_source_ref(tag: str) -> str: + """Return HEAD if a remote-tracking ref or tag contains it; otherwise return the release tag.""" + + def git(*args: str) -> str: + try: + result = subprocess.run( + ["git", *args], cwd=AIRFLOW_REPO_ROOT_PATH, capture_output=True, text=True, check=False + ) + except OSError: # Git may be unavailable when building from an sdist. + return "" + return result.stdout.strip() + + head = git("rev-parse", "--verify", "--quiet", "HEAD^{commit}") + if not head or head == git("rev-parse", "--verify", "--quiet", f"{tag}^{{commit}}"): + return tag + + # Main builds need current examples; unpublished release-fix commits fall back to the tag. + pushed = git("for-each-ref", "--contains", head, "--count=1", "refs/remotes", "refs/tags") + return head if pushed else tag diff --git a/devel-common/src/sphinx_exts/airflow_llms_txt.py b/devel-common/src/sphinx_exts/airflow_llms_txt.py index 050bc335d6e5..8f653ec5a233 100644 --- a/devel-common/src/sphinx_exts/airflow_llms_txt.py +++ b/devel-common/src/sphinx_exts/airflow_llms_txt.py @@ -39,19 +39,23 @@ import re from collections.abc import Iterator from pathlib import Path -from typing import TYPE_CHECKING, Any -from urllib.parse import urljoin +from typing import TYPE_CHECKING, Any, cast +from urllib.parse import urljoin, urlsplit, urlunsplit from docutils import nodes from sphinx import addnodes +from sphinx.errors import ExtensionError from sphinx.util import logging from sphinx.util.matching import Matcher from sphinx_llm.markdown_builder import SphinxLlmMarkdownBuilder, SphinxLlmMarkdownTranslator from sphinx_markdown_builder.contexts import IndentContext, SubContext, SubContextParams, TableContext +from sphinx_exts.redirects import iter_redirects + if TYPE_CHECKING: from sphinx.application import Sphinx from sphinx.config import Config + from sphinx.domains.std import StandardDomain from sphinx.environment import BuildEnvironment logger = logging.getLogger(__name__) @@ -165,12 +169,14 @@ def depart_abbreviation(self, node: nodes.Element) -> None: pass def visit_title(self, node: nodes.Element) -> None: - # A visible toctree's caption is a title inside its wrapper; as a heading it would be a - # second H1 on the page. + # Render navigation captions in bold rather than as section headings. parent = node.parent - if isinstance(parent, nodes.compound) and "toctree-wrapper" in parent["classes"]: + if (isinstance(parent, addnodes.compact_paragraph) and parent.get("toctree")) or ( + isinstance(parent, nodes.compound) and "toctree-wrapper" in parent.get("classes", []) + ): self.add(f"**{node.astext()}**", prefix_eol=2, suffix_eol=1) raise nodes.SkipNode + super().visit_title(node) def depart_title(self, node: nodes.Element) -> None: @@ -214,21 +220,18 @@ def _xref_title(xref: addnodes.pending_xref, env: BuildEnvironment) -> str | Non title = env.titles.get(posixpath.normpath(docname)) return _inline_markdown(title, env) if title else None if xref.get("reftype") == "ref": - label = env.get_domain("std").labels.get(target.lower()) + domain = cast("StandardDomain", env.get_domain("std")) + label = domain.labels.get(target.lower()) return label[2] if label else None return None def _separate_markdown_doctrees(app: Sphinx, config: Config) -> None: - """ - Give the Markdown build a doctree cache of its own. + """Give the Markdown build its own doctree cache.""" + # sphinx-llm's sequential build shares the HTML cache, which can reuse + # incompatible doctrees or overwrite them. Set a separate cache before + # Sphinx creates the environment. - Without parallel mode sphinx-llm points the Markdown build at the HTML build's doctree cache. - The Markdown build would then reuse doctrees read for HTML (curly quotes, none of this - extension's ``doctree-read`` changes) or, once re-read, overwrite them. Its own directory sits - inside sphinx-llm's temporary output, which is deleted after the Markdown files are copied. - Sphinx creates the environment after ``config-inited``, so the change takes effect. - """ if app.tags.has("sphinx_llm_markdown"): app.doctreedir = Path(app.outdir) / ".doctrees" @@ -267,14 +270,8 @@ def _link_example_sources(app: Sphinx, doctree: nodes.document) -> None: def _clean_markdown_doctree(app: Sphinx, doctree: nodes.document, docname: str) -> None: - """ - Drop RST comments and fix up link targets. + """Remove RST comments and normalize version, GitHub source and site-root links for Markdown.""" - The comments are the license header on every page. ``|version|`` in a URL is not an RST - substitution; ``extra_provider_files_with_substitutions`` replaces it in the built HTML files - only, so the Markdown build has to do the same on the doctree. Hand-written links to the - release tag on GitHub then get the same ref as the ``exampleinclude`` links. - """ if not _is_markdown_build(app): return site_root = urljoin(app.config.llms_txt_site_url, "/") @@ -358,6 +355,58 @@ def _toctree_docs(env: BuildEnvironment, docname: str, seen: set[str]) -> list[t return docs +def _write_markdown_redirects(app: Sphinx) -> None: + """Write Markdown stubs for redirected documentation pages.""" + outdir = Path(app.outdir) + + for from_path, to_path in iter_redirects(app): + # Preserve Markdown belonging to an actual source document. + docname = from_path.removesuffix(".html") + if docname in app.env.found_docs: + continue + + target = urlsplit(to_path) + resolved_path = posixpath.normpath(posixpath.join(posixpath.dirname(from_path), target.path)) + + # Only change links within this package to Markdown. + # Other packages and external sites might only publish HTML. + if ( + not target.scheme + and not target.netloc + and not target.path.startswith("/") + and resolved_path != ".." + and not resolved_path.startswith("../") + and target.path.endswith(".html") + ): + target = target._replace(path=f"{target.path}.md") + + destination = urlunsplit(target) + output = outdir / f"{from_path}.md" + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text( + f"# Page moved\n\nThis page has moved to [the new page](<{destination}>).\n", + encoding="utf-8", + ) + + +def _check_markdown_coverage(outdir: Path) -> None: + """Fail if an eligible HTML page has no Markdown copy.""" + excluded = {"genindex.html", "search.html", "py-modindex.html"} + missing = [] + + for page in sorted(outdir.rglob("*.html")): + relative = page.relative_to(outdir) + if "_modules" in relative.parts or page.name in excluded: + continue + if not page.with_name(page.name + ".md").is_file(): + missing.append(relative.as_posix()) + + if missing: + raise ExtensionError( + "HTML pages missing Markdown copies:\n" + "\n".join(f" {page}" for page in missing) + ) + + def _write_llms_txt(app: Sphinx, exception: Exception | None) -> None: """ Replace sphinx-llm's flat ``llms.txt`` with one grouped by the root toctree captions. @@ -368,10 +417,10 @@ def _write_llms_txt(app: Sphinx, exception: Exception | None) -> None: return env = app.env outdir = Path(app.outdir) - if not (outdir / f"{app.config.root_doc}.html.md").is_file(): - # sphinx-llm logs why its Markdown build failed; an index of missing pages helps nobody. - logger.warning("No Markdown pages in %s; not writing llms.txt or llms-full.txt", outdir) - return + + _write_markdown_redirects(app) + _check_markdown_coverage(outdir) + site_url = app.config.llms_txt_site_url.rstrip("/") optional = Matcher(app.config.llms_txt_optional_docs) skipped = Matcher(app.config.llms_txt_skip_docs) diff --git a/devel-common/src/sphinx_exts/redirects.py b/devel-common/src/sphinx_exts/redirects.py index 351c8bb2029f..d98f683e3fe6 100644 --- a/devel-common/src/sphinx_exts/redirects.py +++ b/devel-common/src/sphinx_exts/redirects.py @@ -43,67 +43,57 @@ def build_redirect_page(to_path: str) -> str: return TEMPLATE.format(target=json.dumps(to_path), url=to_path) -def generate_redirects(app): - """Generate redirects files.""" +def iter_redirects(app): + """Yield source and resolved destination paths for redirects.""" redirect_file_path = os.path.join(app.srcdir, app.config.redirects_file) if not os.path.exists(redirect_file_path): - log.info("Could not found the redirect file: %s", redirect_file_path) + log.info("Could not find the redirect file: %s", redirect_file_path) return in_suffix = next(iter(app.config.source_suffix.keys())) - if not isinstance(app.builder, builders.StandaloneHTMLBuilder): - return - with open(redirect_file_path) as redirects: for line in redirects: - # Skip empty line - if not line.strip(): + if not line.strip() or line.startswith("#"): continue - # Skip comments - if line.startswith("#"): - continue - - # Split line into the original path `from_path` and where the URL should redirect to `to_path` from_path, _, to_path = line.rstrip().partition(" ") log.debug("Redirecting '%s' to '%s'", from_path, to_path) - # in_suffix is often ".rst" from_path = from_path.replace(in_suffix, ".html") to_path = to_path.replace(in_suffix, ".html") - to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep)) - 1) - # The redirect path needs to move back to the root of the apache-airflow docs directory - # or the root of the docs directory altogether for provider distributions. + # Preserve the existing handling of provider redirect paths. + depth = len(from_path.split(os.path.sep)) - 1 if ( from_path.startswith("_api/airflow/") and "_api/airflow/providers" not in from_path and "providers" in to_path ): - to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep)) - 1) - elif "../" and "providers" in to_path: - to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep))) + to_path_prefix = f"..{os.path.sep}" * depth + elif "providers" in to_path: + to_path_prefix = f"..{os.path.sep}" * (depth + 1) else: - to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep)) - 1) + to_path_prefix = f"..{os.path.sep}" * depth to_path = to_path_prefix + to_path log.debug("Resolved redirect '%s' to '%s'", from_path, to_path) + yield from_path, to_path - # This will be used to save an HTML file with `TEMPLATE` formatted - redirected_filename = os.path.join(app.builder.outdir, from_path) - redirected_directory = os.path.dirname(redirected_filename) - os.makedirs(redirected_directory, exist_ok=True) +def generate_redirects(app): + """Generate HTML redirect files.""" + if not isinstance(app.builder, builders.StandaloneHTMLBuilder): + return with open(redirected_filename, "w") as f: f.write(build_redirect_page(to_path)) def setup(app): - """Setup plugin""" + """Setup plugin.""" app.add_config_value("redirects_file", "redirects", "env") app.connect("builder-inited", generate_redirects) return {"version": "builtin", "parallel_read_safe": True, "parallel_write_safe": True} diff --git a/devel-common/tests/unit/docs/utils/test_example_source.py b/devel-common/tests/unit/docs/utils/test_example_source.py new file mode 100644 index 000000000000..d6b3cd27f936 --- /dev/null +++ b/devel-common/tests/unit/docs/utils/test_example_source.py @@ -0,0 +1,71 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +import subprocess +from unittest import mock + +import pytest + +from docs.utils.example_source import example_source_ref + + +@pytest.mark.parametrize( + ("outputs", "expected"), + [ + pytest.param([""], "release-tag", id="head-unavailable"), + pytest.param( + ["head-sha", "head-sha"], + "release-tag", + id="head-matches-release-tag", + ), + pytest.param( + ["head-sha", "tag-sha", "refs/remotes/upstream/main\n"], + "head-sha", + id="head-in-remote-branch", + ), + pytest.param( + ["head-sha", "", "refs/tags/another-tag\n"], + "head-sha", + id="head-in-tag", + ), + pytest.param( + ["head-sha", "tag-sha", ""], + "release-tag", + id="head-only-local", + ), + ], +) +def test_example_source_ref(outputs, expected): + results = [subprocess.CompletedProcess(args=["git"], returncode=0, stdout=output) for output in outputs] + + with mock.patch( + "docs.utils.example_source.subprocess.run", + autospec=True, + side_effect=results, + ): + assert example_source_ref("release-tag") == expected + + +def test_example_source_ref_without_git(): + with mock.patch( + "docs.utils.example_source.subprocess.run", + autospec=True, + side_effect=OSError("Git is unavailable"), + ): + assert example_source_ref("release-tag") == "release-tag" diff --git a/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py new file mode 100644 index 000000000000..2b38f70b65dc --- /dev/null +++ b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py @@ -0,0 +1,640 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +import io +from pathlib import Path +from types import SimpleNamespace + +import pytest +from docutils import nodes +from sphinx import addnodes +from sphinx.application import Sphinx +from sphinx.errors import ExtensionError + +from sphinx_exts import airflow_llms_txt + + +def make_app(tmp_path, *, found_docs=()): + source = tmp_path / "source" + output = tmp_path / "output" + source.mkdir() + output.mkdir() + (source / "redirects.txt").write_text("", encoding="utf-8") + + return SimpleNamespace( + srcdir=source, + outdir=output, + builder=SimpleNamespace(name="html"), + env=SimpleNamespace(found_docs=set(found_docs)), + config=SimpleNamespace( + redirects_file="redirects.txt", + source_suffix={".rst": "restructuredtext"}, + llms_txt_enabled=True, + root_doc="index", + ), + ) + + +@pytest.mark.parametrize( + ("source", "target", "expected"), + [ + pytest.param( + "old.rst", + "new.rst", + "new.html.md", + id="normal", + ), + pytest.param( + "hooks/index.rst", + "concepts.rst", + "../concepts.html.md", + id="nested", + ), + pytest.param( + "old.rst", + "new.rst#section", + "new.html.md#section", + id="anchor", + ), + pytest.param( + "old.rst", + "new.rst?view=full#section", + "new.html.md?view=full#section", + id="query-and-anchor", + ), + pytest.param( + "old.rst", + "../other/new.rst", + "../other/new.html", + id="outside-package", + ), + pytest.param( + "old.rst", + "https://example.org/new.html", + "https://example.org/new.html", + id="external", + ), + ], +) +def test_write_markdown_redirects(tmp_path, source, target, expected): + app = make_app(tmp_path) + (app.srcdir / "redirects.txt").write_text(f"{source} {target}\n", encoding="utf-8") + + airflow_llms_txt._write_markdown_redirects(app) + + output = app.outdir / source.replace(".rst", ".html.md") + assert output.read_text(encoding="utf-8") == ( + f"# Page moved\n\nThis page has moved to [the new page](<{expected}>).\n" + ) + + +def test_redirect_preserves_actual_document(tmp_path): + app = make_app(tmp_path, found_docs={"old"}) + (app.srcdir / "redirects.txt").write_text("old.rst new.rst\n", encoding="utf-8") + output = app.outdir / "old.html.md" + output.write_text("# Actual documentation\n", encoding="utf-8") + + airflow_llms_txt._write_markdown_redirects(app) + + assert output.read_text(encoding="utf-8") == "# Actual documentation\n" + + +def test_redirect_updates_existing_stub(tmp_path): + app = make_app(tmp_path) + (app.srcdir / "redirects.txt").write_text("old.rst new.rst\n", encoding="utf-8") + output = app.outdir / "old.html.md" + output.write_text("Old redirect destination", encoding="utf-8") + + airflow_llms_txt._write_markdown_redirects(app) + + assert "()" in output.read_text(encoding="utf-8") + assert "Old redirect destination" not in output.read_text(encoding="utf-8") + + +def test_complete_markdown_coverage(tmp_path): + for name in ("index.html", "operators/llm.html"): + page = tmp_path / name + page.parent.mkdir(parents=True, exist_ok=True) + page.write_text("HTML", encoding="utf-8") + page.with_name(page.name + ".md").write_text("# Documentation", encoding="utf-8") + + airflow_llms_txt._check_markdown_coverage(tmp_path) + + +def test_missing_markdown_lists_all_missing_pages(tmp_path): + for name in ("index.html", "operators/llm.html"): + page = tmp_path / name + page.parent.mkdir(parents=True, exist_ok=True) + page.write_text("HTML", encoding="utf-8") + + with pytest.raises(ExtensionError) as exc: + airflow_llms_txt._check_markdown_coverage(tmp_path) + + assert str(exc.value) == ("HTML pages missing Markdown copies:\n index.html\n operators/llm.html") + + +@pytest.mark.parametrize( + "name", + [ + "genindex.html", + "search.html", + "py-modindex.html", + "_modules/index.html", + "_modules/airflow/providers/example.html", + ], +) +def test_coverage_excludes_special_pages(tmp_path, name): + page = tmp_path / name + page.parent.mkdir(parents=True, exist_ok=True) + page.write_text("HTML", encoding="utf-8") + + airflow_llms_txt._check_markdown_coverage(tmp_path) + + +def test_missing_root_markdown_fails_build(tmp_path): + app = make_app(tmp_path, found_docs={"index"}) + (app.outdir / "index.html").write_text("HTML", encoding="utf-8") + + with pytest.raises(ExtensionError, match="index.html"): + airflow_llms_txt._write_llms_txt(app, None) + + +@pytest.mark.parametrize( + ("builder", "enabled", "exception"), + [ + pytest.param("html", True, RuntimeError("Build failed"), id="failed-build"), + pytest.param("html", False, None, id="disabled"), + pytest.param( + airflow_llms_txt.MARKDOWN_BUILDER, + True, + None, + id="markdown-build", + ), + ], +) +def test_index_generation_skipped(tmp_path, builder, enabled, exception): + app = make_app(tmp_path) + app.builder.name = builder + app.config.llms_txt_enabled = enabled + (app.outdir / "index.html").write_text("HTML", encoding="utf-8") + + airflow_llms_txt._write_llms_txt(app, exception) + + assert not (app.outdir / "llms.txt").exists() + assert not (app.outdir / "llms-full.txt").exists() + + +def test_indexes_follow_navigation_and_use_versioned_urls(tmp_path): + names = {"index", "guide", "second", "changelog", "commits"} + app = make_app(tmp_path, found_docs=names) + site_url = "https://airflow.apache.org/docs/apache-airflow-providers-common-ai/0.10.0" + + root = nodes.document("", "") + navigation = addnodes.toctree() + navigation["caption"] = "Guides" + navigation["entries"] = [ + ("Getting started", "guide"), + (None, "second"), + (None, "changelog"), + (None, "commits"), + ] + root += navigation + + doctrees = {"index": root} + for name in names - {"index"}: + tree = nodes.document("", "") + tree += nodes.paragraph("", f"This is the documentation description for {name}.") + doctrees[name] = tree + + app.env.titles = {name: nodes.title("", name.capitalize()) for name in names} + app.env.toctree_includes = {} + app.env.get_doctree = doctrees.__getitem__ + + app.config.llms_txt_site_url = site_url + "/" + app.config.llms_txt_optional_docs = ["changelog"] + app.config.llms_txt_skip_docs = ["commits"] + app.config.project = "Common AI" + app.config.release = "0.10.0" + app.config.llms_txt_description = "Common AI documentation." + app.config.llms_txt_intro = "Install the Common AI provider." + app.config.llms_txt_root_description = "" + + for name in names: + (app.outdir / f"{name}.html").write_text("HTML", encoding="utf-8") + content = f"# {name.capitalize()}\n" + if name == "guide": + content += "[Next](second.html.md)\n" + (app.outdir / f"{name}.html.md").write_text(content, encoding="utf-8") + + airflow_llms_txt._write_llms_txt(app, None) + + index = (app.outdir / "llms.txt").read_text(encoding="utf-8") + full = (app.outdir / "llms-full.txt").read_text(encoding="utf-8") + + assert index.startswith("# Common AI 0.10.0\n") + assert "Install the Common AI provider." in index + assert "## Guides" in index + assert ( + f"- [Getting started]({site_url}/guide.html.md): This is the documentation description for guide." + ) in index + assert index.index("/guide.html.md") < index.index("/second.html.md") + + optional = index.split("## Optional\n", 1)[1] + assert f"- [Changelog]({site_url}/changelog.html.md)" in optional + assert f"[llms-full.txt]({site_url}/llms-full.txt)" in optional + assert "/commits.html.md" not in index + + assert full.index("Source: " + site_url + "/index.html.md") < full.index( + "Source: " + site_url + "/guide.html.md" + ) + assert full.index("Source: " + site_url + "/guide.html.md") < full.index( + "Source: " + site_url + "/second.html.md" + ) + assert f"[Next]({site_url}/second.html.md)" in full + assert "Source: " + site_url + "/changelog.html.md" not in full + assert "Source: " + site_url + "/commits.html.md" not in full + + +@pytest.mark.parametrize( + ("inside_repo", "source_url", "builder"), + [ + pytest.param( + True, "https://github.com/apache/airflow/blob/abc", airflow_llms_txt.MARKDOWN_BUILDER, id="linked" + ), + pytest.param( + False, + "https://github.com/apache/airflow/blob/abc", + airflow_llms_txt.MARKDOWN_BUILDER, + id="outside-repo", + ), + pytest.param(True, "", airflow_llms_txt.MARKDOWN_BUILDER, id="no-source-url"), + pytest.param(True, "https://github.com/apache/airflow/blob/abc", "html", id="html-unchanged"), + ], +) +def test_example_source_links(tmp_path, monkeypatch, inside_repo, source_url, builder): + monkeypatch.syspath_prepend(str(Path(airflow_llms_txt.__file__).parent)) + + from exampleinclude import ExampleHeader + + repo = tmp_path / "repo" + example = ( + repo / "providers/common/ai/tests/system/example.py" + if inside_repo + else tmp_path / "outside/example.py" + ) + tree = nodes.document("", "") + header = ExampleHeader() + header["filename"] = str(example) + tree += header + + app = SimpleNamespace( + builder=SimpleNamespace(name=builder), + config=SimpleNamespace( + llms_txt_repo_root=str(repo), + llms_txt_source_url=source_url + "/" if source_url else "", + ), + ) + + airflow_llms_txt._link_example_sources(app, tree) + + if builder == "html": + assert tree.children == [header] + elif not inside_repo or not source_url: + assert not tree.children + else: + assert not list(tree.findall(ExampleHeader)) + references = list(tree.findall(nodes.reference)) + assert len(references) == 1 + assert references[0]["refuri"] == (source_url + "/providers/common/ai/tests/system/example.py") + assert references[0].astext() == ("providers/common/ai/tests/system/example.py") + assert tree.astext() == ("Excerpt from providers/common/ai/tests/system/example.py:") + + +@pytest.mark.parametrize( + ("url", "expected"), + [ + pytest.param( + "https://example.org/docs/|version|/guide", + "https://example.org/docs/0.10.0/guide", + id="version", + ), + pytest.param( + "https://github.com/apache/airflow/blob/release-tag/example.py", + "https://github.com/apache/airflow/blob/head-sha/example.py", + id="github-file", + ), + pytest.param( + "https://github.com/apache/airflow/tree/release-tag/examples", + "https://github.com/apache/airflow/tree/head-sha/examples", + id="github-directory", + ), + pytest.param( + "/docs/apache-airflow/stable/index.html", + "https://airflow.apache.org/docs/apache-airflow/stable/index.html", + id="site-root", + ), + pytest.param( + "//example.org/page", + "//example.org/page", + id="protocol-relative-unchanged", + ), + pytest.param( + "concepts.html.md#section", + "concepts.html.md#section", + id="relative-unchanged", + ), + pytest.param( + "https://example.org/page", + "https://example.org/page", + id="external-unchanged", + ), + ], +) +def test_clean_markdown_link_targets(url, expected): + tree = nodes.document("", "") + reference = nodes.reference("", "Link", refuri=url) + tree += reference + + app = SimpleNamespace( + builder=SimpleNamespace(name=airflow_llms_txt.MARKDOWN_BUILDER), + config=SimpleNamespace( + version="0.10.0", + llms_txt_site_url=("https://airflow.apache.org/docs/common-ai/0.10.0/"), + llms_txt_release_source_url=("https://github.com/apache/airflow/blob/release-tag/"), + llms_txt_source_url=("https://github.com/apache/airflow/blob/head-sha/"), + ), + ) + + airflow_llms_txt._clean_markdown_doctree(app, tree, "index") + + assert reference["refuri"] == expected + + +def test_clean_markdown_removes_comments_and_empty_quotes(): + tree = nodes.document("", "") + tree += nodes.comment("", "License header") + tree += nodes.block_quote() + populated_quote = nodes.block_quote() + populated_quote += nodes.paragraph("", "Keep this quotation.") + tree += populated_quote + + app = SimpleNamespace( + builder=SimpleNamespace(name=airflow_llms_txt.MARKDOWN_BUILDER), + config=SimpleNamespace( + llms_txt_site_url="https://airflow.apache.org/", + llms_txt_release_source_url="", + llms_txt_source_url="", + ), + ) + + airflow_llms_txt._clean_markdown_doctree(app, tree, "index") + + assert not list(tree.findall(nodes.comment)) + assert list(tree.findall(nodes.block_quote)) == [populated_quote] + assert tree.astext() == "Keep this quotation." + + +def test_clean_doctree_leaves_html_unchanged(): + tree = nodes.document("", "") + comment = nodes.comment("", "License header") + reference = nodes.reference("", "Link", refuri="/docs/|version|/") + tree += comment + tree += reference + app = SimpleNamespace(builder=SimpleNamespace(name="html")) + + airflow_llms_txt._clean_markdown_doctree(app, tree, "index") + + assert comment in tree.children + assert reference["refuri"] == "/docs/|version|/" + + +@pytest.mark.parametrize( + ("markdown", "expected"), + [ + pytest.param( + "[Next](other.html.md#section)", + "[Next](https://example.org/docs/other.html.md#section)", + id="relative-link", + ), + pytest.param( + "[Parent](../index.html.md)", + "[Parent](https://example.org/index.html.md)", + id="parent-link", + ), + pytest.param( + "[Section](#setup)", + "[Section](https://example.org/docs/page.html.md#setup)", + id="same-page-link", + ), + pytest.param( + "[External](https://other.example/page)", + "[External](https://other.example/page)", + id="external-link", + ), + pytest.param( + "`[Example](other.html.md)` [Next](other.html.md)", + "`[Example](other.html.md)` [Next](https://example.org/docs/other.html.md)", + id="inline-code", + ), + pytest.param( + "```python\n[Example](other.html.md)\n```\n[Next](other.html.md)", + "```python\n[Example](other.html.md)\n```\n[Next](https://example.org/docs/other.html.md)", + id="fenced-code", + ), + ], +) +def test_absolute_links(markdown, expected): + assert airflow_llms_txt._absolute_links(markdown, "https://example.org/docs/page.html.md") == expected + + +def test_navigation_handles_nested_pages_duplicates_and_cycles(): + env = SimpleNamespace( + toctree_includes={ + "index": ["guide", "second", "guide"], + "guide": ["child", "second"], + "child": ["index"], + } + ) + seen = set() + + assert airflow_llms_txt._toctree_docs(env, "index", seen) == [ + ("index", None), + ("guide", None), + ("child", None), + ("second", None), + ] + assert airflow_llms_txt._toctree_docs(env, "guide", seen) == [] + + +@pytest.mark.parametrize("markdown_build", [True, False]) +def test_markdown_doctree_cache_is_separate(tmp_path, markdown_build): + original = tmp_path / "html-doctrees" + app = SimpleNamespace( + outdir=tmp_path / "markdown-output", + doctreedir=original, + tags=SimpleNamespace(has=lambda tag: markdown_build and tag == "sphinx_llm_markdown"), + ) + + airflow_llms_txt._separate_markdown_doctrees(app, SimpleNamespace()) + + expected = app.outdir / ".doctrees" if markdown_build else original + assert app.doctreedir == expected + + +@pytest.fixture +def rendered_markdown(tmp_path, monkeypatch): + source = tmp_path / "source" + output = tmp_path / "output" + source.mkdir() + + # The extension imports redirects and exampleinclude by bare module name. + extension_dir = Path(airflow_llms_txt.__file__).parent + source_root = extension_dir.parent + + (source / "conf.py").write_text( + "import sys\n" + f"sys.path.insert(0, {str(source_root)!r})\n" + f"sys.path.insert(0, {str(extension_dir)!r})\n" + "extensions = [\n" + ' "redirects",\n' + ' "sphinx_exts.airflow_llms_txt",\n' + ' "sphinxcontrib.mermaid",\n' + "]\n" + 'root_doc = "index"\n' + 'redirects_file = "redirects.txt"\n' + "llms_txt_enabled = True\n" + 'llms_txt_suffix_mode = "append"\n' + "llms_txt_build_parallel = False\n", + encoding="utf-8", + ) + (source / "redirects.txt").write_text("", encoding="utf-8") + (source / "index.rst").write_text( + """\ +Rendering +========= + +.. _setup-section: + +Setup +----- + +See `Setup`_. + +.. note:: + + Important configuration advice. + +Following paragraph outside the note. + +.. list-table:: + :header-rows: 1 + + * - Name + - Value + * - Short + - A much longer value + +.. code-block:: python + :caption: Example code + + print("hello") + +.. mermaid:: + + graph TD + A --> B + +.. py:function:: configure(*, model_id) + + Configure a model. + +.. toctree:: + :caption: Further reading + + child +""", + encoding="utf-8", + ) + (source / "child.rst").write_text( + "Child page\n==========\n\nChild documentation.\n", + encoding="utf-8", + ) + + warnings = io.StringIO() + app = Sphinx( + srcdir=str(source), + confdir=str(source), + outdir=str(output), + doctreedir=str(tmp_path / "doctrees"), + buildername="html", + status=io.StringIO(), + warning=warnings, + freshenv=True, + ) + app.build(force_all=True) + + assert app.statuscode == 0, warnings.getvalue() + pages = list(output.rglob("index*.md")) + assert len(pages) == 1 + return pages[0].read_text(encoding="utf-8") + + +def test_rendered_mermaid(rendered_markdown): + assert "```mermaid\n" in rendered_markdown + assert "graph TD\n" in rendered_markdown + assert "A --> B" in rendered_markdown + + +def test_rendered_code_caption_and_sample(rendered_markdown): + assert "**Example code**" in rendered_markdown + assert 'print("hello")' in rendered_markdown + assert rendered_markdown.index("**Example code**") < (rendered_markdown.index('print("hello")')) + + +def test_rendered_keyword_only_marker(rendered_markdown): + signature = next(line for line in rendered_markdown.splitlines() if "configure(" in line) + assert "*" in signature + assert "model_id" in signature + + +def test_rendered_toctree_caption(rendered_markdown): + assert "**Further reading**" in rendered_markdown + assert "[Child page]" in rendered_markdown + assert "# Further reading" not in rendered_markdown + + +def test_rendered_admonition_has_clear_boundaries(rendered_markdown): + lines = rendered_markdown.splitlines() + assert any(line.startswith(">") and "**Note:**" in line for line in lines) + assert any(line.startswith(">") and "Important configuration advice." in line for line in lines) + following = next(line for line in lines if "Following paragraph outside the note." in line) + assert not following.startswith(">") + + +def test_rendered_table_is_compact(rendered_markdown): + table_lines = [line.strip() for line in rendered_markdown.splitlines() if line.strip().startswith("|")] + assert "| Name | Value |" in table_lines + assert "|---|---|" in table_lines + assert "| Short | A much longer value |" in table_lines + + +def test_rendered_same_page_link(rendered_markdown): + assert "[Setup]()" not in rendered_markdown + assert "[Setup]" in rendered_markdown + assert "#setup-section" in rendered_markdown or "#setup" in rendered_markdown diff --git a/devel-common/tests/unit/sphinx_exts/test_redirects.py b/devel-common/tests/unit/sphinx_exts/test_redirects.py index 9f9c1dadbb5e..9606021adab4 100644 --- a/devel-common/tests/unit/sphinx_exts/test_redirects.py +++ b/devel-common/tests/unit/sphinx_exts/test_redirects.py @@ -16,18 +16,165 @@ # under the License. from __future__ import annotations -import sys -from pathlib import Path +import os +from types import SimpleNamespace +from unittest import mock import pytest +from sphinx.builders.html import StandaloneHTMLBuilder +from sphinx_exts import redirects +from sphinx_exts.redirects import build_redirect_page # noqa: E402 SPHINX_EXTS_PATH = Path(__file__).parents[3] / "src" / "sphinx_exts" if SPHINX_EXTS_PATH.as_posix() not in sys.path: # The extensions are loaded by Sphinx from this directory and import each other by bare name. sys.path.append(SPHINX_EXTS_PATH.as_posix()) -from sphinx_exts.redirects import build_redirect_page # noqa: E402 +@pytest.fixture +def app(tmp_path): + source = tmp_path / "source" + output = tmp_path / "output" + source.mkdir() + output.mkdir() + + return SimpleNamespace( + srcdir=source, + config=SimpleNamespace( + redirects_file="redirects.txt", + source_suffix={".rst": "restructuredtext"}, + ), + builder=SimpleNamespace(outdir=output), + ) + + +@pytest.mark.parametrize( + ("source", "target", "expected_source", "expected_target"), + [ + pytest.param( + "old.rst", + "new.rst", + "old.html", + "new.html", + id="root-page", + ), + pytest.param( + "hooks/index.rst", + "concepts.rst", + "hooks/index.html", + "../concepts.html", + id="nested-page", + ), + pytest.param( + "guides/nested/old.rst", + "guides/new.rst", + "guides/nested/old.html", + "../../guides/new.html", + id="deeply-nested-page", + ), + pytest.param( + "old.rst", + "new.rst#section", + "old.html", + "new.html#section", + id="anchor", + ), + pytest.param( + "_api/airflow/old.rst", + "providers/example/new.rst", + "_api/airflow/old.html", + "../../providers/example/new.html", + id="core-api-to-provider", + ), + pytest.param( + "hooks/old.rst", + "providers/example/new.rst", + "hooks/old.html", + "../../providers/example/new.html", + id="provider-destination", + ), + pytest.param( + "_api/airflow/providers/old.rst", + "providers/example/new.rst", + "_api/airflow/providers/old.html", + "../../../../providers/example/new.html", + id="provider-api-destination", + ), + ], +) +def test_iter_redirects(app, source, target, expected_source, expected_target): + # The existing resolver uses the platform separator for parent prefixes. + expected_target = expected_target.replace("../", f"..{os.path.sep}") + (app.srcdir / "redirects.txt").write_text(f"{source} {target}\n", encoding="utf-8") + + assert list(redirects.iter_redirects(app)) == [(expected_source, expected_target)] + + +def test_iter_redirects_skips_comments_and_empty_lines(app): + (app.srcdir / "redirects.txt").write_text( + "# Old documentation paths\n" + "\n" + " \n" + "first.rst new-first.rst\n" + "# Another comment\n" + "second.rst new-second.rst\n", + encoding="utf-8", + ) + + assert list(redirects.iter_redirects(app)) == [ + ("first.html", "new-first.html"), + ("second.html", "new-second.html"), + ] + + +def test_iter_redirects_without_redirect_file(app): + assert list(redirects.iter_redirects(app)) == [] + + +def test_iter_redirects_uses_configured_source_suffix(app): + app.config.source_suffix = {".md": "markdown"} + (app.srcdir / "redirects.txt").write_text("old.md new.md\n", encoding="utf-8") + + assert list(redirects.iter_redirects(app)) == [("old.html", "new.html")] + + +def test_generate_html_redirects(app): + output = app.builder.outdir + # A spec'd mock passes the existing HTML-builder isinstance check. + app.builder = mock.Mock(spec=StandaloneHTMLBuilder) + app.builder.outdir = output + (app.srcdir / "redirects.txt").write_text( + "old.rst new.rst\nhooks/index.rst concepts.rst\n", + encoding="utf-8", + ) + + redirects.generate_redirects(app) + + assert (output / "old.html").read_text(encoding="utf-8") == ( + '' + ) + destination = f"..{os.path.sep}concepts.html" + assert (output / "hooks/index.html").read_text(encoding="utf-8") == ( + f'' + ) + + +def test_generate_redirects_skips_non_html_builder(app): + (app.srcdir / "redirects.txt").write_text("old.rst new.rst\n", encoding="utf-8") + + redirects.generate_redirects(app) + + assert not list(app.builder.outdir.rglob("*")) + + +def test_generate_redirects_without_redirect_file(app): + output = app.builder.outdir + app.builder = mock.Mock(spec=StandaloneHTMLBuilder) + app.builder.outdir = output + + redirects.generate_redirects(app) + + assert not list(output.rglob("*")) @pytest.mark.parametrize( "to_path", diff --git a/uv.lock b/uv.lock index c544d2966f80..f91142b8375e 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 5 +revision = 3 requires-python = ">=3.11" resolution-markers = [ "python_full_version >= '3.15' and sys_platform == 'win32'", @@ -39,31 +39,108 @@ exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for exclude-newer-span = "P4D" [options.exclude-newer-package] +apache-airflow-providers-informatica = false +apache-airflow-providers-clickhousedb = false +apache-airflow-providers-amazon = false +apache-airflow-providers-elasticsearch = false +apache-airflow-providers-duckdb = false +apache-airflow-docker-tests = false +apache-airflow-providers-microsoft-winrm = false +typesafe-sdk = "2026-09-19T00:00:00Z" +apache-airflow-providers = false +apache-airflow-providers-fab = false +apache-airflow-providers-openlineage = false +apache-airflow-providers-sftp = false +apache-airflow-e2e-tests = false +apache-airflow-shared-logging = false +apache-airflow-providers-common-dataquality = false +apache-airflow-providers-apache-drill = false +apache-airflow-providers-pgvector = false +apache-airflow-providers-imap = false +apache-airflow-providers-qdrant = false +apache-airflow-providers-edge3 = false +apache-airflow-providers-neo4j = false +apache-airflow-providers-discord = false +apache-airflow-providers-opensearch = false +apache-airflow-providers-samba = false +apache-airflow-providers-arangodb = false +apache-airflow-providers-apache-spark = false +apache-airflow-providers-ftp = false +apache-airflow-providers-jenkins = false +apache-airflow-shared-listeners = false +apache-airflow-shared-providers-discovery = false +apache-airflow-providers-telegram = false +apache-airflow-providers-celery = false +apache-airflow-providers-docker = false +apache-airflow-providers-sendgrid = false +apache-airflow-providers-common-ai = false apache-airflow = false -apache-airflow-breeze = false -apache-airflow-core = false -apache-airflow-ctl = false -apache-airflow-ctl-tests = false +apache-airflow-shared-observability = false apache-airflow-dev = false +apache-airflow-providers-dbt-cloud = false +apache-airflow-providers-openfaas = false apache-airflow-devel-common = false -apache-airflow-docker-stack = false -apache-airflow-docker-tests = false -apache-airflow-e2e-tests = false -apache-airflow-helm-chart = false -apache-airflow-kubernetes-tests = false -apache-airflow-mypy = false -apache-airflow-providers = false -apache-airflow-providers-airbyte = false -apache-airflow-providers-akeyless = false +apache-airflow-providers-apache-cassandra = false +apache-airflow-providers-asana = false +apache-airflow-providers-oracle = false +apache-airflow-providers-mysql = false apache-airflow-providers-alibaba = false -apache-airflow-providers-amazon = false +apache-airflow-providers-microsoft-mssql = false +apache-airflow-providers-teradata = false +apache-airflow-providers-jdbc = false +apache-airflow-helm-chart = false apache-airflow-providers-anthropic = false -apache-airflow-providers-apache-arrow = false +apache-airflow-providers-common-io = false +apache-airflow-providers-cohere = false +apache-airflow-providers-pinecone = false +apache-airflow-providers-segment = false +apache-airflow-providers-redis = false +apache-airflow-shared-dagnode = false +apache-airflow-providers-apache-pinot = false +apache-airflow-providers-weaviate = false +google-cloud-aiplatform = "2026-08-13T00:00:00Z" +apache-airflow-providers-akeyless = false +apache-airflow-providers-salesforce = false +apache-airflow-providers-ssh = false +apache-airflow-providers-papermill = false +apache-airflow-providers-google = false +pydantic-ai-skills = "2026-07-16T00:00:00Z" apache-airflow-providers-apache-beam = false -apache-airflow-providers-apache-cassandra = false -apache-airflow-providers-apache-drill = false +apache-airflow-providers-microsoft-psrp = false +apache-airflow-providers-vertica = false +apache-airflow-providers-apache-hdfs = false +apache-airflow-shared-template-rendering = false +apache-airflow-mypy = false +apache-airflow-providers-http = false +apache-airflow-providers-slack = false +apache-airflow-providers-vespa = false +apache-airflow-providers-databricks = false +apache-airflow-shared-state = false +apache-airflow-docker-stack = false +apache-airflow-providers-sqlite = false +apache-airflow-providers-ibm-mq = false +apache-airflow-shared-module-loading = false +apache-airflow-providers-yandex = false +apache-airflow-shared-serialization = false +apache-airflow-scripts = false +apache-airflow-providers-exasol = false +apache-airflow-providers-mongo = false +apache-airflow-providers-apache-arrow = false +apache-airflow-providers-apprise = false +apache-airflow-providers-apache-impala = false +apache-airflow-ctl = false +apache-airflow-providers-github = false +apache-airflow-providers-snowflake = false +apache-airflow-providers-zendesk = false +apache-airflow-providers-presto = false +apache-airflow-providers-airbyte = false +apache-airflow-providers-apache-hive = false +apache-airflow-kubernetes-tests = false +apache-airflow-providers-modal = false +apache-airflow-providers-grpc = false apache-airflow-providers-apache-druid = false apache-airflow-providers-apache-flink = false +<<<<<<< HEAD apache-airflow-providers-apache-hdfs = false apache-airflow-providers-apache-hive = false apache-airflow-providers-apache-iceberg = false @@ -83,6 +160,8 @@ apache-airflow-providers-atlassian-jira = false apache-airflow-providers-celery = false apache-airflow-providers-clickhousedb = false apache-airflow-providers-cloudant = false +======= +>>>>>>> fc119c7bdf (Add tests and Markdown redirect coverage for LLM docs) apache-airflow-providers-cncf-kubernetes = false apache-airflow-providers-cohere = false apache-airflow-providers-common-ai = false @@ -133,58 +212,48 @@ apache-airflow-providers-openfaas = false apache-airflow-providers-openlineage = false apache-airflow-providers-opensearch = false apache-airflow-providers-opsgenie = false -apache-airflow-providers-oracle = false +apache-airflow-providers-apache-livy = false +apache-airflow-core = false +apache-airflow-providers-hashicorp = false apache-airflow-providers-pagerduty = false -apache-airflow-providers-papermill = false -apache-airflow-providers-pgvector = false -apache-airflow-providers-pinecone = false -apache-airflow-providers-postgres = false -apache-airflow-providers-presto = false -apache-airflow-providers-qdrant = false -apache-airflow-providers-redis = false -apache-airflow-providers-salesforce = false -apache-airflow-providers-samba = false -apache-airflow-providers-segment = false -apache-airflow-providers-sendgrid = false -apache-airflow-providers-sftp = false -apache-airflow-providers-singularity = false -apache-airflow-providers-slack = false -apache-airflow-providers-smtp = false -apache-airflow-providers-snowflake = false -apache-airflow-providers-sqlite = false -apache-airflow-providers-ssh = false +apache-airflow-providers-datadog = false +apache-airflow-providers-apache-kafka = false +apache-airflow-providers-influxdb = false +apache-airflow-providers-keycloak = false +apache-airflow-providers-trino = false +apache-airflow-providers-common-messaging = false apache-airflow-providers-standard = false +apache-airflow-providers-singularity = false +apache-airflow-providers-common-compat = false +apache-airflow-ctl-tests = false apache-airflow-providers-tableau = false -apache-airflow-providers-telegram = false -apache-airflow-providers-teradata = false -apache-airflow-providers-trino = false -apache-airflow-providers-vertica = false -apache-airflow-providers-vespa = false -apache-airflow-providers-weaviate = false -apache-airflow-providers-yandex = false -apache-airflow-providers-ydb = false -apache-airflow-providers-zendesk = false -apache-airflow-scripts = false +apache-airflow-providers-ibm-db2 = false +apache-airflow-providers-common-sql = false apache-airflow-shared-configuration = false -apache-airflow-shared-dagnode = false -apache-airflow-shared-listeners = false -apache-airflow-shared-logging = false -apache-airflow-shared-module-loading = false -apache-airflow-shared-observability = false +apache-airflow-providers-facebook = false +apache-airflow-providers-ydb = false +apache-airflow-providers-microsoft-azure = false apache-airflow-shared-plugins-manager = false -apache-airflow-shared-providers-discovery = false apache-airflow-shared-secrets-backend = false apache-airflow-shared-secrets-masker = false -apache-airflow-shared-serialization = false -apache-airflow-shared-state = false -apache-airflow-shared-template-rendering = false -apache-airflow-shared-timezones = false +apache-airflow-providers-git = false apache-airflow-task-sdk = false +apache-airflow-providers-atlassian-jira = false +apache-airflow-providers-odbc = false +apache-airflow-providers-postgres = false +apache-airflow-providers-openai = false apache-airflow-task-sdk-integration-tests = false +certifi = "2026-10-21T00:00:00Z" google-cloud-aiplatform = "2026-08-13T00:00:00Z" pip = false pypdf = "2026-10-29T00:00:00Z" uv = false +======= +apache-airflow-providers-smtp = false +apache-airflow-providers-dingding = false +apache-airflow-providers-cloudant = false +apache-airflow-providers-apache-kylin = false +>>>>>>> a7c3e05a04 (Add tests and Markdown redirect coverage for LLM docs) [manifest] members = [ @@ -780,7 +849,7 @@ name = "aiohttp-cors" version = "0.8.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "aiohttp" }, + { name = "aiohttp", marker = "python_full_version < '3.15'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/d89e846a5444b3d5eb8985a6ddb0daef3774928e1bfbce8e84ec97b0ffa7/aiohttp_cors-0.8.1.tar.gz", hash = "sha256:ccacf9cb84b64939ea15f859a146af1f662a6b1d68175754a07315e305fb1403", size = 38626, upload-time = "2025-03-31T14:16:20.048Z" } wheels = [ @@ -12323,7 +12392,7 @@ name = "colorful" version = "0.5.8" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "colorama", marker = "python_full_version < '3.15' and sys_platform == 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/82/31/109ef4bedeb32b4202e02ddb133162457adc4eb890a9ed9c05c9dd126ed0/colorful-0.5.8.tar.gz", hash = "sha256:bb16502b198be2f1c42ba3c52c703d5f651d826076817185f0294c1a549a7445", size = 209361, upload-time = "2025-10-29T11:53:21.663Z" } wheels = [ @@ -13926,7 +13995,7 @@ name = "geomet" version = "1.1.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "click" }, + { name = "click", marker = "python_full_version < '3.14'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/2a/8c/dde022aa6747b114f6b14a7392871275dea8867e2bd26cddb80cc6d66620/geomet-1.1.0.tar.gz", hash = "sha256:51e92231a0ef6aaa63ac20c443377ba78a303fd2ecd179dc3567de79f3c11605", size = 28732, upload-time = "2023-11-14T15:43:36.764Z" } wheels = [ @@ -14112,10 +14181,10 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "fasteners" }, - { name = "httplib2" }, - { name = "oauth2client" }, - { name = "six" }, + { name = "fasteners", marker = "python_full_version < '3.13'" }, + { name = "httplib2", marker = "python_full_version < '3.13'" }, + { name = "oauth2client", marker = "python_full_version < '3.13'" }, + { name = "six", marker = "python_full_version < '3.13'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/19/da/aefc4cf4c168b5d875344cd9dddc77e3a2d11986b630251af5ce47dd2843/google-apitools-0.5.31.tar.gz", hash = "sha256:4af0dd6dd4582810690251f0b57a97c1873dadfda54c5bc195844c8907624170", size = 173463, upload-time = "2020-05-14T17:25:19.126Z" } @@ -14136,10 +14205,10 @@ resolution-markers = [ "(python_full_version == '3.13.*' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "fasteners" }, - { name = "httplib2" }, - { name = "oauth2client" }, - { name = "six" }, + { name = "fasteners", marker = "python_full_version >= '3.13'" }, + { name = "httplib2", marker = "python_full_version >= '3.13'" }, + { name = "oauth2client", marker = "python_full_version >= '3.13'" }, + { name = "six", marker = "python_full_version >= '3.13'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/f5/e4/15fbddfffa968e10c602a30b7ca4703f3e41d2dbdef011e98eee85575133/google-apitools-0.5.35.tar.gz", hash = "sha256:911bc3698686c74187414c610ae30bd6e3c0a7404178fc6479ead6c420d2dd94", size = 531707, upload-time = "2025-09-24T20:22:51.11Z" } wheels = [ @@ -15401,7 +15470,7 @@ name = "gssapi" version = "1.12.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "decorator" }, + { name = "decorator", marker = "sys_platform != 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/6b/fb/9492eb37b5786369b7e96fff2cf4040713acb33b96124813e058cbbd4356/gssapi-1.12.0.tar.gz", hash = "sha256:0b48f17296f869db89221c3bde463fdff35152a4cb99ae4aaa42b0b64333fc6c", size = 95321, upload-time = "2026-08-26T03:00:50.067Z" } wheels = [ @@ -15577,8 +15646,8 @@ name = "httpcore2" version = "2.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "h11" }, - { name = "truststore" }, + { name = "h11", marker = "sys_platform != 'emscripten'" }, + { name = "truststore", marker = "sys_platform != 'emscripten'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/c0/61/afa9d6b7452f9eca73f73d45324eb0bb52f098fd5e6049bf6b8263be9b4e/httpcore2-2.16.0.tar.gz", hash = "sha256:c72cd0413563b17e1cd8354677dff887466f8ec2551679759e93126534428643", size = 69886, upload-time = "2026-10-21T07:09:45.31Z" } wheels = [ @@ -19627,9 +19696,9 @@ name = "opencensus" version = "0.11.4" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "google-api-core" }, - { name = "opencensus-context" }, - { name = "six" }, + { name = "google-api-core", marker = "python_full_version < '3.15'" }, + { name = "opencensus-context", marker = "python_full_version < '3.15'" }, + { name = "six", marker = "python_full_version < '3.15'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/15/a7/a46dcffa1b63084f9f17fe3c8cb20724c4c8f91009fd0b2cfdb27d5d2b35/opencensus-0.11.4.tar.gz", hash = "sha256:cbef87d8b8773064ab60e5c2a1ced58bbaa38a6d052c41aec224958ce544eff2", size = 64966, upload-time = "2024-01-03T18:04:07.085Z" } wheels = [ @@ -22860,9 +22929,9 @@ name = "python3-saml" version = "1.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "isodate" }, - { name = "lxml" }, - { name = "xmlsec" }, + { name = "isodate", marker = "python_full_version < '3.13'" }, + { name = "lxml", marker = "python_full_version < '3.13'" }, + { name = "xmlsec", marker = "python_full_version < '3.13'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/5d/98/6e0268c3a9893af3d4c5cf670183e0314cd6b5cb034a612d6a7cc5060df8/python3-saml-1.16.0.tar.gz", hash = "sha256:97c9669aecabc283c6e5fb4eb264f446b6e006f5267d01c9734f9d8bffdac133", size = 83468, upload-time = "2023-10-09T10:37:43.128Z" } wheels = [ @@ -23153,7 +23222,7 @@ version = "2.60.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "click" }, - { name = "filelock" }, + { name = "filelock", version = "3.32.7", source = { registry = "https://pypi.org/simple" } }, { name = "jsonschema" }, { name = "msgpack" }, { name = "packaging" }, @@ -23182,20 +23251,20 @@ wheels = [ [package.optional-dependencies] default = [ - { name = "aiohttp" }, - { name = "aiohttp-cors" }, - { name = "colorful" }, - { name = "grpcio" }, - { name = "opencensus" }, - { name = "opentelemetry-exporter-prometheus" }, - { name = "opentelemetry-proto" }, - { name = "opentelemetry-sdk" }, - { name = "prometheus-client" }, - { name = "py-spy" }, - { name = "pydantic" }, - { name = "requests" }, - { name = "smart-open" }, - { name = "virtualenv" }, + { name = "aiohttp", marker = "python_full_version < '3.15'" }, + { name = "aiohttp-cors", marker = "python_full_version < '3.15'" }, + { name = "colorful", marker = "python_full_version < '3.15'" }, + { name = "grpcio", marker = "python_full_version < '3.15'" }, + { name = "opencensus", marker = "python_full_version < '3.15'" }, + { name = "opentelemetry-exporter-prometheus", marker = "python_full_version < '3.15'" }, + { name = "opentelemetry-proto", marker = "python_full_version < '3.15'" }, + { name = "opentelemetry-sdk", marker = "python_full_version < '3.15'" }, + { name = "prometheus-client", marker = "python_full_version < '3.15'" }, + { name = "py-spy", marker = "python_full_version < '3.15'" }, + { name = "pydantic", marker = "python_full_version < '3.15'" }, + { name = "requests", marker = "python_full_version < '3.15'" }, + { name = "smart-open", marker = "python_full_version < '3.15'" }, + { name = "virtualenv", marker = "python_full_version < '3.15'" }, ] [[package]] @@ -23906,7 +23975,7 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "numpy" }, + { name = "numpy", marker = "python_full_version < '3.12'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", hash = "sha256:95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0", size = 30573822, upload-time = "2026-02-23T00:26:24.851Z" } wheels = [ @@ -23993,7 +24062,7 @@ resolution-markers = [ "(python_full_version == '3.12.*' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "numpy" }, + { name = "numpy", marker = "python_full_version >= '3.12'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/7e/74/66de6258867beb2ef08f35f9f2ac017a52cacd5081714d239ff1a442d458/scipy-1.18.1.tar.gz", hash = "sha256:52c4b7422442aba924d03ad4019852b08a92e64ea187b933135687bfe2747307", size = 30781235, upload-time = "2026-08-21T23:28:50.599Z" } wheels = [ @@ -24097,8 +24166,8 @@ name = "secretstorage" version = "3.5.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "cryptography" }, - { name = "jeepney" }, + { name = "cryptography", marker = "(python_full_version >= '3.14' and sys_platform == 'darwin') or (platform_machine != 'arm64' and sys_platform == 'darwin') or (sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')" }, + { name = "jeepney", marker = "(python_full_version >= '3.14' and sys_platform == 'darwin') or (platform_machine != 'arm64' and sys_platform == 'darwin') or (sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')" }, ] sdist = { url = "https://files.pythonhosted.org/packages/1c/03/e834bcd866f2f8a49a85eaff47340affa3bfa391ee9912a952a1faa68c7b/secretstorage-3.5.0.tar.gz", hash = "sha256:f04b8e4689cbce351744d5537bf6b1329c6fc68f91fa666f60a380edddcd11be", size = 19884, upload-time = "2025-11-23T19:02:53.191Z" } wheels = [ @@ -24307,7 +24376,7 @@ name = "smart-open" version = "9.0.2" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "wrapt" }, + { name = "wrapt", marker = "python_full_version < '3.15'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/56/1d/5d401eeef68919274e1df4e90d1c24f18b2408ffc49a4d6e952afa548219/smart_open-9.0.2.tar.gz", hash = "sha256:adfe6413bfb39c2895cf9d066c8bea326aeb8b3b717306e6a10c9efa931ae796", size = 65083, upload-time = "2026-11-03T07:57:32.382Z" } wheels = [ @@ -24392,7 +24461,7 @@ dependencies = [ { name = "certifi" }, { name = "charset-normalizer" }, { name = "cryptography" }, - { name = "filelock" }, + { name = "filelock", version = "3.32.7", source = { registry = "https://pypi.org/simple" } }, { name = "idna" }, { name = "packaging" }, { name = "platformdirs" }, @@ -24446,10 +24515,10 @@ resolution-markers = [ "python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", ] dependencies = [ - { name = "cryptography" }, - { name = "protobuf" }, - { name = "pytz" }, - { name = "tomlkit" }, + { name = "cryptography", marker = "python_full_version >= '3.15'" }, + { name = "protobuf", marker = "python_full_version >= '3.15'" }, + { name = "pytz", marker = "python_full_version >= '3.15'" }, + { name = "tomlkit", marker = "python_full_version >= '3.15'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/5f/89/198870b0bcf10bd5ae3cc7167350639dc1a07d0d0a854f0eef2390569e03/snowflake_connector_python-5.2.0.tar.gz", hash = "sha256:f358bf77d14e18f852cbaeabe31fcd41cb89bc39df43442f42647f675d984bb3", size = 2006186, upload-time = "2026-11-04T15:58:31.387Z" } wheels = [ @@ -24536,6 +24605,7 @@ resolution-markers = [ dependencies = [ { name = "snowflake-connector-python", version = "4.8.1", source = { registry = "https://pypi.org/simple" } }, { name = "sqlalchemy", version = "2.0.57", source = { registry = "https://pypi.org/simple" } }, +>>>>>>> fc119c7bdf (Add tests and Markdown redirect coverage for LLM docs) ] sdist = { url = "https://files.pythonhosted.org/packages/f2/0d/94458e9231da61efe076ff8b9d808da9c8e3be39d99eaff8e6fe85f7295e/snowflake_sqlalchemy-1.11.1.tar.gz", hash = "sha256:942b203de0404b79550c4098ca851aee2b0b22f695426b073e58d71772e38d51", size = 252184, upload-time = "2026-09-04T06:51:26.892Z" } wheels = [ @@ -24639,23 +24709,23 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "alabaster" }, - { name = "babel" }, - { name = "colorama", marker = "sys_platform == 'win32'" }, - { name = "docutils" }, - { name = "imagesize" }, - { name = "jinja2" }, - { name = "packaging" }, - { name = "pygments" }, - { name = "requests" }, - { name = "roman-numerals" }, - { name = "snowballstemmer" }, - { name = "sphinxcontrib-applehelp" }, - { name = "sphinxcontrib-devhelp" }, - { name = "sphinxcontrib-htmlhelp" }, - { name = "sphinxcontrib-jsmath" }, - { name = "sphinxcontrib-qthelp" }, - { name = "sphinxcontrib-serializinghtml" }, + { name = "alabaster", marker = "python_full_version < '3.12'" }, + { name = "babel", marker = "python_full_version < '3.12'" }, + { name = "colorama", marker = "python_full_version < '3.12' and sys_platform == 'win32'" }, + { name = "docutils", marker = "python_full_version < '3.12'" }, + { name = "imagesize", marker = "python_full_version < '3.12'" }, + { name = "jinja2", marker = "python_full_version < '3.12'" }, + { name = "packaging", marker = "python_full_version < '3.12'" }, + { name = "pygments", marker = "python_full_version < '3.12'" }, + { name = "requests", marker = "python_full_version < '3.12'" }, + { name = "roman-numerals", marker = "python_full_version < '3.12'" }, + { name = "snowballstemmer", marker = "python_full_version < '3.12'" }, + { name = "sphinxcontrib-applehelp", marker = "python_full_version < '3.12'" }, + { name = "sphinxcontrib-devhelp", marker = "python_full_version < '3.12'" }, + { name = "sphinxcontrib-htmlhelp", marker = "python_full_version < '3.12'" }, + { name = "sphinxcontrib-jsmath", marker = "python_full_version < '3.12'" }, + { name = "sphinxcontrib-qthelp", marker = "python_full_version < '3.12'" }, + { name = "sphinxcontrib-serializinghtml", marker = "python_full_version < '3.12'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/42/50/a8c6ccc36d5eacdfd7913ddccd15a9cee03ecafc5ee2bc40e1f168d85022/sphinx-9.0.4.tar.gz", hash = "sha256:594ef59d042972abbc581d8baa577404abe4e6c3b04ef61bd7fc2acbd51f3fa3", size = 8710502, upload-time = "2025-12-04T07:45:27.343Z" } wheels = [ @@ -24713,23 +24783,23 @@ resolution-markers = [ "(python_full_version == '3.13.*' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "alabaster" }, - { name = "babel" }, - { name = "colorama", marker = "sys_platform == 'win32'" }, - { name = "docutils" }, - { name = "imagesize" }, - { name = "jinja2" }, - { name = "packaging" }, - { name = "pygments" }, - { name = "requests" }, - { name = "roman-numerals" }, - { name = "snowballstemmer" }, - { name = "sphinxcontrib-applehelp" }, - { name = "sphinxcontrib-devhelp" }, - { name = "sphinxcontrib-htmlhelp" }, - { name = "sphinxcontrib-jsmath" }, - { name = "sphinxcontrib-qthelp" }, - { name = "sphinxcontrib-serializinghtml" }, + { name = "alabaster", marker = "python_full_version >= '3.12'" }, + { name = "babel", marker = "python_full_version >= '3.12'" }, + { name = "colorama", marker = "python_full_version >= '3.12' and sys_platform == 'win32'" }, + { name = "docutils", marker = "python_full_version >= '3.12'" }, + { name = "imagesize", marker = "python_full_version >= '3.12'" }, + { name = "jinja2", marker = "python_full_version >= '3.12'" }, + { name = "packaging", marker = "python_full_version >= '3.12'" }, + { name = "pygments", marker = "python_full_version >= '3.12'" }, + { name = "requests", marker = "python_full_version >= '3.12'" }, + { name = "roman-numerals", marker = "python_full_version >= '3.12'" }, + { name = "snowballstemmer", marker = "python_full_version >= '3.12'" }, + { name = "sphinxcontrib-applehelp", marker = "python_full_version >= '3.12'" }, + { name = "sphinxcontrib-devhelp", marker = "python_full_version >= '3.12'" }, + { name = "sphinxcontrib-htmlhelp", marker = "python_full_version >= '3.12'" }, + { name = "sphinxcontrib-jsmath", marker = "python_full_version >= '3.12'" }, + { name = "sphinxcontrib-qthelp", marker = "python_full_version >= '3.12'" }, + { name = "sphinxcontrib-serializinghtml", marker = "python_full_version >= '3.12'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/64/d4/413466f0be8b1cb0e3e43893a148b96d7462d0923d82b4166b21afc5f30c/sphinx-9.2.0.tar.gz", hash = "sha256:90470459f3cab15d9dfed146c71cf77694b0445df17b2e0e69059cb9f7fc9ee4", size = 8782438, upload-time = "2026-10-21T00:05:15.019Z" } wheels = [ @@ -24854,8 +24924,7 @@ version = "1.1.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "markdown-it-py" }, - { name = "sphinx", version = "8.1.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" }, + { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, { name = "sphinx", version = "9.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, { name = "sphinx-markdown-builder" }, ] @@ -24869,10 +24938,8 @@ name = "sphinx-markdown-builder" version = "0.6.11" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "docutils", version = "0.21.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "docutils", version = "0.22.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, - { name = "sphinx", version = "8.1.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.11.*'" }, + { name = "docutils" }, + { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, { name = "sphinx", version = "9.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, { name = "tabulate" }, ] @@ -27051,7 +27118,7 @@ name = "xmlsec" version = "1.3.18" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "lxml" }, + { name = "lxml", marker = "python_full_version < '3.13'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/4a/f9/034d0a8aeec12e68599583b992b88bb9a734861fd883665a38efc23a8118/xmlsec-1.3.18.tar.gz", hash = "sha256:84e29528b98b623ca3cf0495e46a6973513c0e7a525d23ae642277d6f29890cb", size = 75224, upload-time = "2026-10-29T11:01:30.721Z" } wheels = [ From 95af1d76faa30fe2da2fd53096eaab574019ead1 Mon Sep 17 00:00:00 2001 From: Sameer Mesiah Date: Sun, 25 Oct 2026 19:20:50 +0000 Subject: [PATCH 3/6] Improve LLM documentation build diagnostics and tests Restore explanations for source refs, doctree isolation and redirects. Add a concise missing-root Markdown error and test partial coverage. Tighten the same-page link assertion and regenerate uv.lock to reduce churn. --- devel-common/src/docs/utils/example_source.py | 5 +- .../src/sphinx_exts/airflow_llms_txt.py | 26 +- devel-common/src/sphinx_exts/redirects.py | 4 +- .../unit/sphinx_exts/test_airflow_llms_txt.py | 44 +- .../common/ai/docs/durable_execution.rst | 14 + uv.lock | 394 +++++++++--------- 6 files changed, 280 insertions(+), 207 deletions(-) diff --git a/devel-common/src/docs/utils/example_source.py b/devel-common/src/docs/utils/example_source.py index 2b1c614f6247..552286969393 100644 --- a/devel-common/src/docs/utils/example_source.py +++ b/devel-common/src/docs/utils/example_source.py @@ -38,6 +38,9 @@ def git(*args: str) -> str: if not head or head == git("rev-parse", "--verify", "--quiet", f"{tag}^{{commit}}"): return tag - # Main builds need current examples; unpublished release-fix commits fall back to the tag. + # Main docs may reference examples missing from the latest release tag. + # The docs publishing workflow can cherry-pick fixes onto a release tag, + # creating a local-only HEAD that is unavailable on GitHub. Prefer HEAD + # when a remote-tracking ref or tag contains it; otherwise use the release tag. pushed = git("for-each-ref", "--contains", head, "--count=1", "refs/remotes", "refs/tags") return head if pushed else tag diff --git a/devel-common/src/sphinx_exts/airflow_llms_txt.py b/devel-common/src/sphinx_exts/airflow_llms_txt.py index 8f653ec5a233..6712566582c8 100644 --- a/devel-common/src/sphinx_exts/airflow_llms_txt.py +++ b/devel-common/src/sphinx_exts/airflow_llms_txt.py @@ -228,9 +228,12 @@ def _xref_title(xref: addnodes.pending_xref, env: BuildEnvironment) -> str | Non def _separate_markdown_doctrees(app: Sphinx, config: Config) -> None: """Give the Markdown build its own doctree cache.""" - # sphinx-llm's sequential build shares the HTML cache, which can reuse - # incompatible doctrees or overwrite them. Set a separate cache before - # Sphinx creates the environment. + # In sequential mode, sphinx-llm shares the HTML build's cache, but + # extensions can transform doctrees differently for HTML and Markdown. + # This cache lives inside sphinx-llm's temporary Markdown output directory, + # which is deleted after the Markdown files are copied. + # Remove this workaround once Airflow uses the upstream cache-isolation fix. + # config-inited runs before Sphinx creates the environment. if app.tags.has("sphinx_llm_markdown"): app.doctreedir = Path(app.outdir) / ".doctrees" @@ -279,8 +282,15 @@ def _clean_markdown_doctree(app: Sphinx, doctree: nodes.document, docname: str) source_url = app.config.llms_txt_source_url for reference in doctree.findall(nodes.reference): refuri = reference.get("refuri", "") + + # |version| in a URL is not an RST substitution. + # extra_provider_files_with_substitutions rewrites only the built HTML, + # so Markdown needs the equivalent replacement on the doctree. if "|version|" in refuri: refuri = reference["refuri"] = refuri.replace("|version|", app.config.version) + + # Give handwritten GitHub release links the same source ref as + # exampleinclude links, so both point to examples matching these docs. if release_url and source_url and release_url != source_url: for kind in ("blob", "tree"): prefix = release_url.replace("/blob/", f"/{kind}/") @@ -417,6 +427,15 @@ def _write_llms_txt(app: Sphinx, exception: Exception | None) -> None: return env = app.env outdir = Path(app.outdir) + root_doc = app.config.root_doc + + # Report a missing root page before the coverage check lists every HTML page. + # sphinx-llm logs subprocess failures above without copying the Markdown output. + if not (outdir / f"{root_doc}.html.md").is_file(): + raise ExtensionError( + f"The Markdown build did not generate {root_doc}.html.md; " + "check the sphinx-llm build output above for errors." + ) _write_markdown_redirects(app) _check_markdown_coverage(outdir) @@ -433,7 +452,6 @@ def entry(docname: str, title: str | None = None, *, describe: bool = True) -> s description = _page_description(env, docname) if describe else "" return f"{line}: {description}" if description else line - root_doc = app.config.root_doc root = env.get_doctree(root_doc) # A caption's own pages come first; each page with pages under it gets a section of its own. # Each section is its caption and its (docname, llms.txt line) pairs. diff --git a/devel-common/src/sphinx_exts/redirects.py b/devel-common/src/sphinx_exts/redirects.py index d98f683e3fe6..408549eb6684 100644 --- a/devel-common/src/sphinx_exts/redirects.py +++ b/devel-common/src/sphinx_exts/redirects.py @@ -64,7 +64,9 @@ def iter_redirects(app): from_path = from_path.replace(in_suffix, ".html") to_path = to_path.replace(in_suffix, ".html") - # Preserve the existing handling of provider redirect paths. + # Redirects climb back to the package docs root, or to the shared docs + # root for provider destinations, which requires one extra parent level. + # Core API-to-provider redirects use the package-root depth instead. depth = len(from_path.split(os.path.sep)) - 1 if ( from_path.startswith("_api/airflow/") diff --git a/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py index 2b38f70b65dc..0906733c159c 100644 --- a/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py +++ b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py @@ -167,13 +167,24 @@ def test_coverage_excludes_special_pages(tmp_path, name): airflow_llms_txt._check_markdown_coverage(tmp_path) -def test_missing_root_markdown_fails_build(tmp_path): - app = make_app(tmp_path, found_docs={"index"}) - (app.outdir / "index.html").write_text("HTML", encoding="utf-8") +@pytest.mark.parametrize("root_doc", ["index", "guide/start"]) +def test_missing_root_markdown_fails_build(tmp_path, root_doc): + app = make_app(tmp_path, found_docs={root_doc, "other"}) + app.config.root_doc = root_doc - with pytest.raises(ExtensionError, match="index.html"): + for name in (root_doc, "other"): + page = app.outdir / f"{name}.html" + page.parent.mkdir(parents=True, exist_ok=True) + page.write_text("HTML", encoding="utf-8") + + with pytest.raises(ExtensionError) as exc: airflow_llms_txt._write_llms_txt(app, None) + assert str(exc.value) == ( + f"The Markdown build did not generate {root_doc}.html.md; " + "check the sphinx-llm build output above for errors." + ) + @pytest.mark.parametrize( ("builder", "enabled", "exception"), @@ -200,6 +211,25 @@ def test_index_generation_skipped(tmp_path, builder, enabled, exception): assert not (app.outdir / "llms-full.txt").exists() +def test_index_generation_reports_partial_markdown_coverage(tmp_path): + app = make_app( + tmp_path, + found_docs={"index", "guide", "operators/llm"}, + ) + + for name in ("index", "guide", "operators/llm"): + page = app.outdir / f"{name}.html" + page.parent.mkdir(parents=True, exist_ok=True) + page.write_text("HTML", encoding="utf-8") + + (app.outdir / "index.html.md").write_text("# Documentation\n", encoding="utf-8") + + with pytest.raises(ExtensionError) as exc: + airflow_llms_txt._write_llms_txt(app, None) + + assert str(exc.value) == ("HTML pages missing Markdown copies:\n guide.html\n operators/llm.html") + + def test_indexes_follow_navigation_and_use_versioned_urls(tmp_path): names = {"index", "guide", "second", "changelog", "commits"} app = make_app(tmp_path, found_docs=names) @@ -534,7 +564,7 @@ def rendered_markdown(tmp_path, monkeypatch): Setup ----- -See `Setup`_. +See :ref:`Setup `. .. note:: @@ -635,6 +665,4 @@ def test_rendered_table_is_compact(rendered_markdown): def test_rendered_same_page_link(rendered_markdown): - assert "[Setup]()" not in rendered_markdown - assert "[Setup]" in rendered_markdown - assert "#setup-section" in rendered_markdown or "#setup" in rendered_markdown + assert "[Setup](#setup-section)" in rendered_markdown diff --git a/providers/common/ai/docs/durable_execution.rst b/providers/common/ai/docs/durable_execution.rst index 077987486707..5196236398d7 100644 --- a/providers/common/ai/docs/durable_execution.rst +++ b/providers/common/ai/docs/durable_execution.rst @@ -27,6 +27,7 @@ twice. With durable execution, each step the agent completes is recorded in a jo kept for the task instance, and the retry replays the recorded steps instead of running them again. Only the steps the failed attempt never finished run live. +<<<<<<< HEAD On Airflow 3.3 and later, ``AgentOperator`` and ``@task.agent`` do this by default for every task that can retry. A task that cannot run again (no retries, and from Airflow 3.4 no ``retry_policy`` either) has nothing to replay, so it runs as before. To decide @@ -34,6 +35,19 @@ no ``retry_policy`` either) has nothing to replay, so it runs as before. To deci ``LLMBatchOperator`` re-attaches to its running batch instead (:ref:`llm-batch-reattach`). To resume a Strands Agents agent on a retry, see :ref:`howto/frameworks:strands-durable`; for an OpenAI Agents SDK agent, see :ref:`howto/frameworks:openai-agents-durable`. +======= +Durable execution only helps a task that has retries. To decide *whether* a failure is +worth retrying, see :doc:`retry_policies`; a retried ``LLMBatchOperator`` re-attaches to +its running batch instead (:ref:`llm-batch-reattach`). To resume a Strands Agents agent on a +retry, see :ref:`howto/frameworks:strands-durable`; for an OpenAI Agents SDK agent, see +:ref:`howto/frameworks:openai-agents-durable`. + +.. meta:: + :description: Set durable=True on an agent task so that a retry replays the model and tool calls that already finished instead of running and paying for them again. + +Turn it on +---------- +>>>>>>> 8c19ab81a5 (Improve LLM documentation build diagnostics and tests) When it is on ------------- diff --git a/uv.lock b/uv.lock index f91142b8375e..90fb02ac582c 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 5 requires-python = ">=3.11" resolution-markers = [ "python_full_version >= '3.15' and sys_platform == 'win32'", @@ -39,105 +39,29 @@ exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for exclude-newer-span = "P4D" [options.exclude-newer-package] -apache-airflow-providers-informatica = false -apache-airflow-providers-clickhousedb = false -apache-airflow-providers-amazon = false -apache-airflow-providers-elasticsearch = false -apache-airflow-providers-duckdb = false -apache-airflow-docker-tests = false -apache-airflow-providers-microsoft-winrm = false -typesafe-sdk = "2026-09-19T00:00:00Z" -apache-airflow-providers = false -apache-airflow-providers-fab = false -apache-airflow-providers-openlineage = false -apache-airflow-providers-sftp = false -apache-airflow-e2e-tests = false -apache-airflow-shared-logging = false -apache-airflow-providers-common-dataquality = false -apache-airflow-providers-apache-drill = false -apache-airflow-providers-pgvector = false -apache-airflow-providers-imap = false -apache-airflow-providers-qdrant = false -apache-airflow-providers-edge3 = false -apache-airflow-providers-neo4j = false -apache-airflow-providers-discord = false -apache-airflow-providers-opensearch = false -apache-airflow-providers-samba = false -apache-airflow-providers-arangodb = false -apache-airflow-providers-apache-spark = false -apache-airflow-providers-ftp = false -apache-airflow-providers-jenkins = false -apache-airflow-shared-listeners = false -apache-airflow-shared-providers-discovery = false -apache-airflow-providers-telegram = false -apache-airflow-providers-celery = false -apache-airflow-providers-docker = false -apache-airflow-providers-sendgrid = false -apache-airflow-providers-common-ai = false apache-airflow = false -apache-airflow-shared-observability = false +apache-airflow-breeze = false +apache-airflow-core = false +apache-airflow-ctl = false +apache-airflow-ctl-tests = false apache-airflow-dev = false -apache-airflow-providers-dbt-cloud = false -apache-airflow-providers-openfaas = false apache-airflow-devel-common = false -apache-airflow-providers-apache-cassandra = false -apache-airflow-providers-asana = false -apache-airflow-providers-oracle = false -apache-airflow-providers-mysql = false -apache-airflow-providers-alibaba = false -apache-airflow-providers-microsoft-mssql = false -apache-airflow-providers-teradata = false -apache-airflow-providers-jdbc = false +apache-airflow-docker-stack = false +apache-airflow-docker-tests = false +apache-airflow-e2e-tests = false apache-airflow-helm-chart = false -apache-airflow-providers-anthropic = false -apache-airflow-providers-common-io = false -apache-airflow-providers-cohere = false -apache-airflow-providers-pinecone = false -apache-airflow-providers-segment = false -apache-airflow-providers-redis = false -apache-airflow-shared-dagnode = false -apache-airflow-providers-apache-pinot = false -apache-airflow-providers-weaviate = false -google-cloud-aiplatform = "2026-08-13T00:00:00Z" -apache-airflow-providers-akeyless = false -apache-airflow-providers-salesforce = false -apache-airflow-providers-ssh = false -apache-airflow-providers-papermill = false -apache-airflow-providers-google = false -pydantic-ai-skills = "2026-07-16T00:00:00Z" -apache-airflow-providers-apache-beam = false -apache-airflow-providers-microsoft-psrp = false -apache-airflow-providers-vertica = false -apache-airflow-providers-apache-hdfs = false -apache-airflow-shared-template-rendering = false +apache-airflow-kubernetes-tests = false apache-airflow-mypy = false -apache-airflow-providers-http = false -apache-airflow-providers-slack = false -apache-airflow-providers-vespa = false -apache-airflow-providers-databricks = false -apache-airflow-shared-state = false -apache-airflow-docker-stack = false -apache-airflow-providers-sqlite = false -apache-airflow-providers-ibm-mq = false -apache-airflow-shared-module-loading = false -apache-airflow-providers-yandex = false -apache-airflow-shared-serialization = false -apache-airflow-scripts = false -apache-airflow-providers-exasol = false -apache-airflow-providers-mongo = false -apache-airflow-providers-apache-arrow = false -apache-airflow-providers-apprise = false -apache-airflow-providers-apache-impala = false -apache-airflow-ctl = false -apache-airflow-providers-github = false -apache-airflow-providers-snowflake = false -apache-airflow-providers-zendesk = false -apache-airflow-providers-presto = false +apache-airflow-providers = false apache-airflow-providers-airbyte = false -apache-airflow-providers-apache-hive = false -apache-airflow-kubernetes-tests = false -apache-airflow-providers-modal = false -apache-airflow-providers-grpc = false +apache-airflow-providers-akeyless = false +apache-airflow-providers-alibaba = false +apache-airflow-providers-amazon = false +apache-airflow-providers-anthropic = false +apache-airflow-providers-apache-arrow = false +apache-airflow-providers-apache-beam = false +apache-airflow-providers-apache-cassandra = false +apache-airflow-providers-apache-drill = false apache-airflow-providers-apache-druid = false apache-airflow-providers-apache-flink = false <<<<<<< HEAD @@ -218,42 +142,121 @@ apache-airflow-providers-hashicorp = false apache-airflow-providers-pagerduty = false apache-airflow-providers-datadog = false apache-airflow-providers-apache-kafka = false +apache-airflow-providers-apache-kylin = false +apache-airflow-providers-apache-livy = false +apache-airflow-providers-apache-pig = false +apache-airflow-providers-apache-pinot = false +apache-airflow-providers-apache-spark = false +apache-airflow-providers-apache-tinkerpop = false +apache-airflow-providers-apprise = false +apache-airflow-providers-arangodb = false +apache-airflow-providers-asana = false +apache-airflow-providers-atlassian-jira = false +apache-airflow-providers-celery = false +apache-airflow-providers-clickhousedb = false +apache-airflow-providers-cloudant = false +apache-airflow-providers-cncf-kubernetes = false +apache-airflow-providers-cohere = false +apache-airflow-providers-common-ai = false +apache-airflow-providers-common-compat = false +apache-airflow-providers-common-dataquality = false +apache-airflow-providers-common-io = false +apache-airflow-providers-common-messaging = false +apache-airflow-providers-common-sql = false +apache-airflow-providers-databricks = false +apache-airflow-providers-datadog = false +apache-airflow-providers-dbt-cloud = false +apache-airflow-providers-dingding = false +apache-airflow-providers-discord = false +apache-airflow-providers-docker = false +apache-airflow-providers-duckdb = false +apache-airflow-providers-edge3 = false +apache-airflow-providers-elasticsearch = false +apache-airflow-providers-exasol = false +apache-airflow-providers-fab = false +apache-airflow-providers-facebook = false +apache-airflow-providers-ftp = false +apache-airflow-providers-git = false +apache-airflow-providers-github = false +apache-airflow-providers-google = false +apache-airflow-providers-grpc = false +apache-airflow-providers-hashicorp = false +apache-airflow-providers-http = false +apache-airflow-providers-ibm-db2 = false +apache-airflow-providers-ibm-mq = false +apache-airflow-providers-imap = false apache-airflow-providers-influxdb = false +apache-airflow-providers-informatica = false +apache-airflow-providers-jdbc = false +apache-airflow-providers-jenkins = false apache-airflow-providers-keycloak = false -apache-airflow-providers-trino = false -apache-airflow-providers-common-messaging = false -apache-airflow-providers-standard = false +apache-airflow-providers-microsoft-azure = false +apache-airflow-providers-microsoft-mssql = false +apache-airflow-providers-microsoft-psrp = false +apache-airflow-providers-microsoft-winrm = false +apache-airflow-providers-modal = false +apache-airflow-providers-mongo = false +apache-airflow-providers-mysql = false +apache-airflow-providers-neo4j = false +apache-airflow-providers-odbc = false +apache-airflow-providers-openai = false +apache-airflow-providers-openfaas = false +apache-airflow-providers-openlineage = false +apache-airflow-providers-opensearch = false +apache-airflow-providers-opsgenie = false +apache-airflow-providers-oracle = false +apache-airflow-providers-pagerduty = false +apache-airflow-providers-papermill = false +apache-airflow-providers-pgvector = false +apache-airflow-providers-pinecone = false +apache-airflow-providers-postgres = false +apache-airflow-providers-presto = false +apache-airflow-providers-qdrant = false +apache-airflow-providers-redis = false +apache-airflow-providers-salesforce = false +apache-airflow-providers-samba = false +apache-airflow-providers-segment = false +apache-airflow-providers-sendgrid = false +apache-airflow-providers-sftp = false apache-airflow-providers-singularity = false -apache-airflow-providers-common-compat = false -apache-airflow-ctl-tests = false +apache-airflow-providers-slack = false +apache-airflow-providers-smtp = false +apache-airflow-providers-snowflake = false +apache-airflow-providers-sqlite = false +apache-airflow-providers-ssh = false +apache-airflow-providers-standard = false apache-airflow-providers-tableau = false -apache-airflow-providers-ibm-db2 = false -apache-airflow-providers-common-sql = false -apache-airflow-shared-configuration = false -apache-airflow-providers-facebook = false +apache-airflow-providers-telegram = false +apache-airflow-providers-teradata = false +apache-airflow-providers-trino = false +apache-airflow-providers-vertica = false +apache-airflow-providers-vespa = false +apache-airflow-providers-weaviate = false +apache-airflow-providers-yandex = false apache-airflow-providers-ydb = false -apache-airflow-providers-microsoft-azure = false +apache-airflow-providers-zendesk = false +apache-airflow-scripts = false +apache-airflow-shared-configuration = false +apache-airflow-shared-dagnode = false +apache-airflow-shared-listeners = false +apache-airflow-shared-logging = false +apache-airflow-shared-module-loading = false +apache-airflow-shared-observability = false apache-airflow-shared-plugins-manager = false +apache-airflow-shared-providers-discovery = false apache-airflow-shared-secrets-backend = false apache-airflow-shared-secrets-masker = false -apache-airflow-providers-git = false +apache-airflow-shared-serialization = false +apache-airflow-shared-state = false +apache-airflow-shared-template-rendering = false +apache-airflow-shared-timezones = false apache-airflow-task-sdk = false -apache-airflow-providers-atlassian-jira = false -apache-airflow-providers-odbc = false -apache-airflow-providers-postgres = false -apache-airflow-providers-openai = false apache-airflow-task-sdk-integration-tests = false certifi = "2026-10-21T00:00:00Z" google-cloud-aiplatform = "2026-08-13T00:00:00Z" pip = false pypdf = "2026-10-29T00:00:00Z" uv = false -======= -apache-airflow-providers-smtp = false -apache-airflow-providers-dingding = false -apache-airflow-providers-cloudant = false -apache-airflow-providers-apache-kylin = false ->>>>>>> a7c3e05a04 (Add tests and Markdown redirect coverage for LLM docs) [manifest] members = [ @@ -849,7 +852,7 @@ name = "aiohttp-cors" version = "0.8.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "aiohttp", marker = "python_full_version < '3.15'" }, + { name = "aiohttp" }, ] sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/d89e846a5444b3d5eb8985a6ddb0daef3774928e1bfbce8e84ec97b0ffa7/aiohttp_cors-0.8.1.tar.gz", hash = "sha256:ccacf9cb84b64939ea15f859a146af1f662a6b1d68175754a07315e305fb1403", size = 38626, upload-time = "2025-03-31T14:16:20.048Z" } wheels = [ @@ -12392,7 +12395,7 @@ name = "colorful" version = "0.5.8" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "colorama", marker = "python_full_version < '3.15' and sys_platform == 'win32'" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/82/31/109ef4bedeb32b4202e02ddb133162457adc4eb890a9ed9c05c9dd126ed0/colorful-0.5.8.tar.gz", hash = "sha256:bb16502b198be2f1c42ba3c52c703d5f651d826076817185f0294c1a549a7445", size = 209361, upload-time = "2025-10-29T11:53:21.663Z" } wheels = [ @@ -13995,7 +13998,7 @@ name = "geomet" version = "1.1.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "click", marker = "python_full_version < '3.14'" }, + { name = "click" }, ] sdist = { url = "https://files.pythonhosted.org/packages/2a/8c/dde022aa6747b114f6b14a7392871275dea8867e2bd26cddb80cc6d66620/geomet-1.1.0.tar.gz", hash = "sha256:51e92231a0ef6aaa63ac20c443377ba78a303fd2ecd179dc3567de79f3c11605", size = 28732, upload-time = "2023-11-14T15:43:36.764Z" } wheels = [ @@ -14181,10 +14184,10 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "fasteners", marker = "python_full_version < '3.13'" }, - { name = "httplib2", marker = "python_full_version < '3.13'" }, - { name = "oauth2client", marker = "python_full_version < '3.13'" }, - { name = "six", marker = "python_full_version < '3.13'" }, + { name = "fasteners" }, + { name = "httplib2" }, + { name = "oauth2client" }, + { name = "six" }, ] sdist = { url = "https://files.pythonhosted.org/packages/19/da/aefc4cf4c168b5d875344cd9dddc77e3a2d11986b630251af5ce47dd2843/google-apitools-0.5.31.tar.gz", hash = "sha256:4af0dd6dd4582810690251f0b57a97c1873dadfda54c5bc195844c8907624170", size = 173463, upload-time = "2020-05-14T17:25:19.126Z" } @@ -14205,10 +14208,10 @@ resolution-markers = [ "(python_full_version == '3.13.*' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "fasteners", marker = "python_full_version >= '3.13'" }, - { name = "httplib2", marker = "python_full_version >= '3.13'" }, - { name = "oauth2client", marker = "python_full_version >= '3.13'" }, - { name = "six", marker = "python_full_version >= '3.13'" }, + { name = "fasteners" }, + { name = "httplib2" }, + { name = "oauth2client" }, + { name = "six" }, ] sdist = { url = "https://files.pythonhosted.org/packages/f5/e4/15fbddfffa968e10c602a30b7ca4703f3e41d2dbdef011e98eee85575133/google-apitools-0.5.35.tar.gz", hash = "sha256:911bc3698686c74187414c610ae30bd6e3c0a7404178fc6479ead6c420d2dd94", size = 531707, upload-time = "2025-09-24T20:22:51.11Z" } wheels = [ @@ -15470,7 +15473,7 @@ name = "gssapi" version = "1.12.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "decorator", marker = "sys_platform != 'win32'" }, + { name = "decorator" }, ] sdist = { url = "https://files.pythonhosted.org/packages/6b/fb/9492eb37b5786369b7e96fff2cf4040713acb33b96124813e058cbbd4356/gssapi-1.12.0.tar.gz", hash = "sha256:0b48f17296f869db89221c3bde463fdff35152a4cb99ae4aaa42b0b64333fc6c", size = 95321, upload-time = "2026-08-26T03:00:50.067Z" } wheels = [ @@ -15646,8 +15649,8 @@ name = "httpcore2" version = "2.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "h11", marker = "sys_platform != 'emscripten'" }, - { name = "truststore", marker = "sys_platform != 'emscripten'" }, + { name = "h11" }, + { name = "truststore" }, ] sdist = { url = "https://files.pythonhosted.org/packages/c0/61/afa9d6b7452f9eca73f73d45324eb0bb52f098fd5e6049bf6b8263be9b4e/httpcore2-2.16.0.tar.gz", hash = "sha256:c72cd0413563b17e1cd8354677dff887466f8ec2551679759e93126534428643", size = 69886, upload-time = "2026-10-21T07:09:45.31Z" } wheels = [ @@ -19696,9 +19699,9 @@ name = "opencensus" version = "0.11.4" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "google-api-core", marker = "python_full_version < '3.15'" }, - { name = "opencensus-context", marker = "python_full_version < '3.15'" }, - { name = "six", marker = "python_full_version < '3.15'" }, + { name = "google-api-core" }, + { name = "opencensus-context" }, + { name = "six" }, ] sdist = { url = "https://files.pythonhosted.org/packages/15/a7/a46dcffa1b63084f9f17fe3c8cb20724c4c8f91009fd0b2cfdb27d5d2b35/opencensus-0.11.4.tar.gz", hash = "sha256:cbef87d8b8773064ab60e5c2a1ced58bbaa38a6d052c41aec224958ce544eff2", size = 64966, upload-time = "2024-01-03T18:04:07.085Z" } wheels = [ @@ -22929,9 +22932,9 @@ name = "python3-saml" version = "1.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "isodate", marker = "python_full_version < '3.13'" }, - { name = "lxml", marker = "python_full_version < '3.13'" }, - { name = "xmlsec", marker = "python_full_version < '3.13'" }, + { name = "isodate" }, + { name = "lxml" }, + { name = "xmlsec" }, ] sdist = { url = "https://files.pythonhosted.org/packages/5d/98/6e0268c3a9893af3d4c5cf670183e0314cd6b5cb034a612d6a7cc5060df8/python3-saml-1.16.0.tar.gz", hash = "sha256:97c9669aecabc283c6e5fb4eb264f446b6e006f5267d01c9734f9d8bffdac133", size = 83468, upload-time = "2023-10-09T10:37:43.128Z" } wheels = [ @@ -23251,20 +23254,20 @@ wheels = [ [package.optional-dependencies] default = [ - { name = "aiohttp", marker = "python_full_version < '3.15'" }, - { name = "aiohttp-cors", marker = "python_full_version < '3.15'" }, - { name = "colorful", marker = "python_full_version < '3.15'" }, - { name = "grpcio", marker = "python_full_version < '3.15'" }, - { name = "opencensus", marker = "python_full_version < '3.15'" }, - { name = "opentelemetry-exporter-prometheus", marker = "python_full_version < '3.15'" }, - { name = "opentelemetry-proto", marker = "python_full_version < '3.15'" }, - { name = "opentelemetry-sdk", marker = "python_full_version < '3.15'" }, - { name = "prometheus-client", marker = "python_full_version < '3.15'" }, - { name = "py-spy", marker = "python_full_version < '3.15'" }, - { name = "pydantic", marker = "python_full_version < '3.15'" }, - { name = "requests", marker = "python_full_version < '3.15'" }, - { name = "smart-open", marker = "python_full_version < '3.15'" }, - { name = "virtualenv", marker = "python_full_version < '3.15'" }, + { name = "aiohttp" }, + { name = "aiohttp-cors" }, + { name = "colorful" }, + { name = "grpcio" }, + { name = "opencensus" }, + { name = "opentelemetry-exporter-prometheus" }, + { name = "opentelemetry-proto" }, + { name = "opentelemetry-sdk" }, + { name = "prometheus-client" }, + { name = "py-spy" }, + { name = "pydantic" }, + { name = "requests" }, + { name = "smart-open" }, + { name = "virtualenv" }, ] [[package]] @@ -23975,7 +23978,7 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "numpy", marker = "python_full_version < '3.12'" }, + { name = "numpy" }, ] sdist = { url = "https://files.pythonhosted.org/packages/7a/97/5a3609c4f8d58b039179648e62dd220f89864f56f7357f5d4f45c29eb2cc/scipy-1.17.1.tar.gz", hash = "sha256:95d8e012d8cb8816c226aef832200b1d45109ed4464303e997c5b13122b297c0", size = 30573822, upload-time = "2026-02-23T00:26:24.851Z" } wheels = [ @@ -24062,7 +24065,7 @@ resolution-markers = [ "(python_full_version == '3.12.*' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "numpy", marker = "python_full_version >= '3.12'" }, + { name = "numpy" }, ] sdist = { url = "https://files.pythonhosted.org/packages/7e/74/66de6258867beb2ef08f35f9f2ac017a52cacd5081714d239ff1a442d458/scipy-1.18.1.tar.gz", hash = "sha256:52c4b7422442aba924d03ad4019852b08a92e64ea187b933135687bfe2747307", size = 30781235, upload-time = "2026-08-21T23:28:50.599Z" } wheels = [ @@ -24166,8 +24169,8 @@ name = "secretstorage" version = "3.5.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "cryptography", marker = "(python_full_version >= '3.14' and sys_platform == 'darwin') or (platform_machine != 'arm64' and sys_platform == 'darwin') or (sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')" }, - { name = "jeepney", marker = "(python_full_version >= '3.14' and sys_platform == 'darwin') or (platform_machine != 'arm64' and sys_platform == 'darwin') or (sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')" }, + { name = "cryptography" }, + { name = "jeepney" }, ] sdist = { url = "https://files.pythonhosted.org/packages/1c/03/e834bcd866f2f8a49a85eaff47340affa3bfa391ee9912a952a1faa68c7b/secretstorage-3.5.0.tar.gz", hash = "sha256:f04b8e4689cbce351744d5537bf6b1329c6fc68f91fa666f60a380edddcd11be", size = 19884, upload-time = "2025-11-23T19:02:53.191Z" } wheels = [ @@ -24376,7 +24379,7 @@ name = "smart-open" version = "9.0.2" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "wrapt", marker = "python_full_version < '3.15'" }, + { name = "wrapt" }, ] sdist = { url = "https://files.pythonhosted.org/packages/56/1d/5d401eeef68919274e1df4e90d1c24f18b2408ffc49a4d6e952afa548219/smart_open-9.0.2.tar.gz", hash = "sha256:adfe6413bfb39c2895cf9d066c8bea326aeb8b3b717306e6a10c9efa931ae796", size = 65083, upload-time = "2026-11-03T07:57:32.382Z" } wheels = [ @@ -24515,10 +24518,10 @@ resolution-markers = [ "python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'", ] dependencies = [ - { name = "cryptography", marker = "python_full_version >= '3.15'" }, - { name = "protobuf", marker = "python_full_version >= '3.15'" }, - { name = "pytz", marker = "python_full_version >= '3.15'" }, - { name = "tomlkit", marker = "python_full_version >= '3.15'" }, + { name = "cryptography" }, + { name = "protobuf" }, + { name = "pytz" }, + { name = "tomlkit" }, ] sdist = { url = "https://files.pythonhosted.org/packages/5f/89/198870b0bcf10bd5ae3cc7167350639dc1a07d0d0a854f0eef2390569e03/snowflake_connector_python-5.2.0.tar.gz", hash = "sha256:f358bf77d14e18f852cbaeabe31fcd41cb89bc39df43442f42647f675d984bb3", size = 2006186, upload-time = "2026-11-04T15:58:31.387Z" } wheels = [ @@ -24603,9 +24606,14 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ +<<<<<<< HEAD { name = "snowflake-connector-python", version = "4.8.1", source = { registry = "https://pypi.org/simple" } }, { name = "sqlalchemy", version = "2.0.57", source = { registry = "https://pypi.org/simple" } }, >>>>>>> fc119c7bdf (Add tests and Markdown redirect coverage for LLM docs) +======= + { name = "snowflake-connector-python", version = "4.8.0", source = { registry = "https://pypi.org/simple" } }, + { name = "sqlalchemy" }, +>>>>>>> 8c19ab81a5 (Improve LLM documentation build diagnostics and tests) ] sdist = { url = "https://files.pythonhosted.org/packages/f2/0d/94458e9231da61efe076ff8b9d808da9c8e3be39d99eaff8e6fe85f7295e/snowflake_sqlalchemy-1.11.1.tar.gz", hash = "sha256:942b203de0404b79550c4098ca851aee2b0b22f695426b073e58d71772e38d51", size = 252184, upload-time = "2026-09-04T06:51:26.892Z" } wheels = [ @@ -24709,23 +24717,23 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "alabaster", marker = "python_full_version < '3.12'" }, - { name = "babel", marker = "python_full_version < '3.12'" }, - { name = "colorama", marker = "python_full_version < '3.12' and sys_platform == 'win32'" }, - { name = "docutils", marker = "python_full_version < '3.12'" }, - { name = "imagesize", marker = "python_full_version < '3.12'" }, - { name = "jinja2", marker = "python_full_version < '3.12'" }, - { name = "packaging", marker = "python_full_version < '3.12'" }, - { name = "pygments", marker = "python_full_version < '3.12'" }, - { name = "requests", marker = "python_full_version < '3.12'" }, - { name = "roman-numerals", marker = "python_full_version < '3.12'" }, - { name = "snowballstemmer", marker = "python_full_version < '3.12'" }, - { name = "sphinxcontrib-applehelp", marker = "python_full_version < '3.12'" }, - { name = "sphinxcontrib-devhelp", marker = "python_full_version < '3.12'" }, - { name = "sphinxcontrib-htmlhelp", marker = "python_full_version < '3.12'" }, - { name = "sphinxcontrib-jsmath", marker = "python_full_version < '3.12'" }, - { name = "sphinxcontrib-qthelp", marker = "python_full_version < '3.12'" }, - { name = "sphinxcontrib-serializinghtml", marker = "python_full_version < '3.12'" }, + { name = "alabaster" }, + { name = "babel" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "docutils" }, + { name = "imagesize" }, + { name = "jinja2" }, + { name = "packaging" }, + { name = "pygments" }, + { name = "requests" }, + { name = "roman-numerals" }, + { name = "snowballstemmer" }, + { name = "sphinxcontrib-applehelp" }, + { name = "sphinxcontrib-devhelp" }, + { name = "sphinxcontrib-htmlhelp" }, + { name = "sphinxcontrib-jsmath" }, + { name = "sphinxcontrib-qthelp" }, + { name = "sphinxcontrib-serializinghtml" }, ] sdist = { url = "https://files.pythonhosted.org/packages/42/50/a8c6ccc36d5eacdfd7913ddccd15a9cee03ecafc5ee2bc40e1f168d85022/sphinx-9.0.4.tar.gz", hash = "sha256:594ef59d042972abbc581d8baa577404abe4e6c3b04ef61bd7fc2acbd51f3fa3", size = 8710502, upload-time = "2025-12-04T07:45:27.343Z" } wheels = [ @@ -24783,23 +24791,23 @@ resolution-markers = [ "(python_full_version == '3.13.*' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version == '3.13.*' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ - { name = "alabaster", marker = "python_full_version >= '3.12'" }, - { name = "babel", marker = "python_full_version >= '3.12'" }, - { name = "colorama", marker = "python_full_version >= '3.12' and sys_platform == 'win32'" }, - { name = "docutils", marker = "python_full_version >= '3.12'" }, - { name = "imagesize", marker = "python_full_version >= '3.12'" }, - { name = "jinja2", marker = "python_full_version >= '3.12'" }, - { name = "packaging", marker = "python_full_version >= '3.12'" }, - { name = "pygments", marker = "python_full_version >= '3.12'" }, - { name = "requests", marker = "python_full_version >= '3.12'" }, - { name = "roman-numerals", marker = "python_full_version >= '3.12'" }, - { name = "snowballstemmer", marker = "python_full_version >= '3.12'" }, - { name = "sphinxcontrib-applehelp", marker = "python_full_version >= '3.12'" }, - { name = "sphinxcontrib-devhelp", marker = "python_full_version >= '3.12'" }, - { name = "sphinxcontrib-htmlhelp", marker = "python_full_version >= '3.12'" }, - { name = "sphinxcontrib-jsmath", marker = "python_full_version >= '3.12'" }, - { name = "sphinxcontrib-qthelp", marker = "python_full_version >= '3.12'" }, - { name = "sphinxcontrib-serializinghtml", marker = "python_full_version >= '3.12'" }, + { name = "alabaster" }, + { name = "babel" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "docutils" }, + { name = "imagesize" }, + { name = "jinja2" }, + { name = "packaging" }, + { name = "pygments" }, + { name = "requests" }, + { name = "roman-numerals" }, + { name = "snowballstemmer" }, + { name = "sphinxcontrib-applehelp" }, + { name = "sphinxcontrib-devhelp" }, + { name = "sphinxcontrib-htmlhelp" }, + { name = "sphinxcontrib-jsmath" }, + { name = "sphinxcontrib-qthelp" }, + { name = "sphinxcontrib-serializinghtml" }, ] sdist = { url = "https://files.pythonhosted.org/packages/64/d4/413466f0be8b1cb0e3e43893a148b96d7462d0923d82b4166b21afc5f30c/sphinx-9.2.0.tar.gz", hash = "sha256:90470459f3cab15d9dfed146c71cf77694b0445df17b2e0e69059cb9f7fc9ee4", size = 8782438, upload-time = "2026-10-21T00:05:15.019Z" } wheels = [ @@ -27118,7 +27126,7 @@ name = "xmlsec" version = "1.3.18" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "lxml", marker = "python_full_version < '3.13'" }, + { name = "lxml" }, ] sdist = { url = "https://files.pythonhosted.org/packages/4a/f9/034d0a8aeec12e68599583b992b88bb9a734861fd883665a38efc23a8118/xmlsec-1.3.18.tar.gz", hash = "sha256:84e29528b98b623ca3cf0495e46a6973513c0e7a525d23ae642277d6f29890cb", size = 75224, upload-time = "2026-10-29T11:01:30.721Z" } wheels = [ From 80f1ca6c111113869789d2bf3dd6490f75bba60f Mon Sep 17 00:00:00 2001 From: Sameer Mesiah Date: Sat, 7 Nov 2026 16:12:29 +0000 Subject: [PATCH 4/6] Apply Markdown example links during doctree resolution Preserve example filenames before exampleinclude replaces its headers, then generate Markdown source links during doctree-resolved. Remove the separate Markdown doctree cache workaround and version the cached environment data. Update unit tests and add Sphinx build coverage for Markdown example links and preserved HTML headers. --- .../src/sphinx_exts/airflow_llms_txt.py | 53 +- devel-common/src/sphinx_exts/redirects.py | 8 +- .../unit/sphinx_exts/test_airflow_llms_txt.py | 117 ++- .../tests/unit/sphinx_exts/test_redirects.py | 18 +- providers/common/ai/docs/sandbox/backends.rst | 830 ------------------ uv.lock | 22 +- 6 files changed, 134 insertions(+), 914 deletions(-) delete mode 100644 providers/common/ai/docs/sandbox/backends.rst diff --git a/devel-common/src/sphinx_exts/airflow_llms_txt.py b/devel-common/src/sphinx_exts/airflow_llms_txt.py index 6712566582c8..1b2d27e21f40 100644 --- a/devel-common/src/sphinx_exts/airflow_llms_txt.py +++ b/devel-common/src/sphinx_exts/airflow_llms_txt.py @@ -54,7 +54,6 @@ if TYPE_CHECKING: from sphinx.application import Sphinx - from sphinx.config import Config from sphinx.domains.std import StandardDomain from sphinx.environment import BuildEnvironment @@ -226,42 +225,38 @@ def _xref_title(xref: addnodes.pending_xref, env: BuildEnvironment) -> str | Non return None -def _separate_markdown_doctrees(app: Sphinx, config: Config) -> None: - """Give the Markdown build its own doctree cache.""" - # In sequential mode, sphinx-llm shares the HTML build's cache, but - # extensions can transform doctrees differently for HTML and Markdown. - # This cache lives inside sphinx-llm's temporary Markdown output directory, - # which is deleted after the Markdown files are copied. - # Remove this workaround once Airflow uses the upstream cache-isolation fix. - # config-inited runs before Sphinx creates the environment. - - if app.tags.has("sphinx_llm_markdown"): - app.doctreedir = Path(app.outdir) / ".doctrees" - - def _is_markdown_build(app: Sphinx) -> bool: return app.builder is not None and app.builder.name == MARKDOWN_BUILDER -def _link_example_sources(app: Sphinx, doctree: nodes.document) -> None: - """ - Replace each ``exampleinclude`` header with a link to the whole example file. +def _remember_example_sources(app: Sphinx, doctree: nodes.document) -> None: + """Preserve example filenames before exampleinclude replaces its headers.""" + from exampleinclude import ExampleHeader - Runs before ``exampleinclude``'s own ``doctree-read`` handler, which would otherwise turn the - header into a bare module path plus a "View Source" button that has no Markdown equivalent. - """ + for header in doctree.findall(ExampleHeader): + header.parent["example_source_filename"] = header["filename"] + + +def _link_example_sources(app: Sphinx, doctree: nodes.document, docname: str) -> None: + """Replace rendered example headers with full-source links for Markdown.""" if not _is_markdown_build(app): return - # Imported by bare name, as conf.py loads it: another import path gives a different class. - from exampleinclude import ExampleHeader repo_root = Path(app.config.llms_txt_repo_root).resolve() source_url = app.config.llms_txt_source_url.rstrip("/") - for header in list(doctree.findall(ExampleHeader)): - path = Path(header["filename"]).resolve() + + for header in list(doctree.findall(nodes.paragraph)): + if ( + "example-header" not in header.get("classes", []) + or "example_source_filename" not in header.parent + ): + continue + + path = Path(header.parent["example_source_filename"]).resolve() if not source_url or not path.is_relative_to(repo_root): header.parent.remove(header) continue + repo_path = path.relative_to(repo_root).as_posix() paragraph = nodes.paragraph() paragraph += nodes.Text("Excerpt from ") @@ -544,8 +539,12 @@ def setup(app: Sphinx) -> dict[str, Any]: app.add_config_value("llms_txt_root_description", "", "env") app.add_config_value("llms_txt_optional_docs", [], "env") app.add_config_value("llms_txt_skip_docs", [], "env") - app.connect("config-inited", _separate_markdown_doctrees) - app.connect("doctree-read", _link_example_sources, priority=400) + app.connect("doctree-read", _remember_example_sources, priority=400) + app.connect("doctree-resolved", _link_example_sources) app.connect("doctree-resolved", _clean_markdown_doctree) app.connect("build-finished", _write_llms_txt, priority=102) - return {"parallel_read_safe": True, "parallel_write_safe": True} + return { + "env_version": 1, + "parallel_read_safe": True, + "parallel_write_safe": True, + } diff --git a/devel-common/src/sphinx_exts/redirects.py b/devel-common/src/sphinx_exts/redirects.py index 408549eb6684..709946802a88 100644 --- a/devel-common/src/sphinx_exts/redirects.py +++ b/devel-common/src/sphinx_exts/redirects.py @@ -90,8 +90,12 @@ def generate_redirects(app): if not isinstance(app.builder, builders.StandaloneHTMLBuilder): return - with open(redirected_filename, "w") as f: - f.write(build_redirect_page(to_path)) + for from_path, to_path in iter_redirects(app): + redirected_filename = os.path.join(app.builder.outdir, from_path) + os.makedirs(os.path.dirname(redirected_filename), exist_ok=True) + + with open(redirected_filename, "w", encoding="utf-8") as f: + f.write(build_redirect_page(to_path)) def setup(app): diff --git a/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py index 0906733c159c..ff85181bd6a9 100644 --- a/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py +++ b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py @@ -317,10 +317,7 @@ def test_indexes_follow_navigation_and_use_versioned_urls(tmp_path): pytest.param(True, "https://github.com/apache/airflow/blob/abc", "html", id="html-unchanged"), ], ) -def test_example_source_links(tmp_path, monkeypatch, inside_repo, source_url, builder): - monkeypatch.syspath_prepend(str(Path(airflow_llms_txt.__file__).parent)) - - from exampleinclude import ExampleHeader +def test_example_source_links(tmp_path, inside_repo, source_url, builder): repo = tmp_path / "repo" example = ( @@ -329,9 +326,11 @@ def test_example_source_links(tmp_path, monkeypatch, inside_repo, source_url, bu else tmp_path / "outside/example.py" ) tree = nodes.document("", "") - header = ExampleHeader() - header["filename"] = str(example) - tree += header + wrapper = nodes.container() + wrapper["example_source_filename"] = str(example) + header = nodes.paragraph("", "Original example header", classes=["example-header"]) + wrapper += header + tree += wrapper app = SimpleNamespace( builder=SimpleNamespace(name=builder), @@ -341,19 +340,46 @@ def test_example_source_links(tmp_path, monkeypatch, inside_repo, source_url, bu ), ) - airflow_llms_txt._link_example_sources(app, tree) + airflow_llms_txt._link_example_sources(app, tree, "index") if builder == "html": - assert tree.children == [header] + assert wrapper.children == [header] elif not inside_repo or not source_url: - assert not tree.children + assert not wrapper.children else: - assert not list(tree.findall(ExampleHeader)) - references = list(tree.findall(nodes.reference)) + references = list(wrapper.findall(nodes.reference)) assert len(references) == 1 assert references[0]["refuri"] == (source_url + "/providers/common/ai/tests/system/example.py") assert references[0].astext() == ("providers/common/ai/tests/system/example.py") - assert tree.astext() == ("Excerpt from providers/common/ai/tests/system/example.py:") + assert wrapper.astext() == ("Excerpt from providers/common/ai/tests/system/example.py:") + + +def test_example_source_links_in_built_docs(rendered_docs): + assert ( + "Excerpt from [`example.py`](https://github.com/apache/airflow/blob/test-ref/example.py):" + ) in rendered_docs.markdown + assert 'print("example survives cache reuse")' in rendered_docs.markdown + + assert 'class="example-header' in rendered_docs.html + assert "Excerpt from" not in rendered_docs.html + + +def test_remember_example_sources(tmp_path, monkeypatch): + monkeypatch.syspath_prepend(str(Path(airflow_llms_txt.__file__).parent)) + from exampleinclude import ExampleHeader + + filename = str(tmp_path / "example.py") + tree = nodes.document("", "") + wrapper = nodes.container() + header = ExampleHeader() + header["filename"] = filename + wrapper += header + tree += wrapper + + airflow_llms_txt._remember_example_sources(SimpleNamespace(builder=SimpleNamespace(name="html")), tree) + + assert wrapper["example_source_filename"] == filename + assert wrapper.children == [header] @pytest.mark.parametrize( @@ -512,23 +538,8 @@ def test_navigation_handles_nested_pages_duplicates_and_cycles(): assert airflow_llms_txt._toctree_docs(env, "guide", seen) == [] -@pytest.mark.parametrize("markdown_build", [True, False]) -def test_markdown_doctree_cache_is_separate(tmp_path, markdown_build): - original = tmp_path / "html-doctrees" - app = SimpleNamespace( - outdir=tmp_path / "markdown-output", - doctreedir=original, - tags=SimpleNamespace(has=lambda tag: markdown_build and tag == "sphinx_llm_markdown"), - ) - - airflow_llms_txt._separate_markdown_doctrees(app, SimpleNamespace()) - - expected = app.outdir / ".doctrees" if markdown_build else original - assert app.doctreedir == expected - - @pytest.fixture -def rendered_markdown(tmp_path, monkeypatch): +def rendered_docs(tmp_path): source = tmp_path / "source" output = tmp_path / "output" source.mkdir() @@ -543,6 +554,7 @@ def rendered_markdown(tmp_path, monkeypatch): f"sys.path.insert(0, {str(extension_dir)!r})\n" "extensions = [\n" ' "redirects",\n' + ' "exampleinclude",\n' ' "sphinx_exts.airflow_llms_txt",\n' ' "sphinxcontrib.mermaid",\n' "]\n" @@ -550,7 +562,10 @@ def rendered_markdown(tmp_path, monkeypatch): 'redirects_file = "redirects.txt"\n' "llms_txt_enabled = True\n" 'llms_txt_suffix_mode = "append"\n' - "llms_txt_build_parallel = False\n", + "llms_txt_build_parallel = False\n" + f"exampleinclude_sourceroot = {str(source)!r}\n" + f"llms_txt_repo_root = {str(source)!r}\n" + 'llms_txt_source_url = "https://github.com/apache/airflow/blob/test-ref/"\n', encoding="utf-8", ) (source / "redirects.txt").write_text("", encoding="utf-8") @@ -598,6 +613,11 @@ def rendered_markdown(tmp_path, monkeypatch): :caption: Further reading child + +Example +------- + +.. exampleinclude:: example.py """, encoding="utf-8", ) @@ -605,6 +625,10 @@ def rendered_markdown(tmp_path, monkeypatch): "Child page\n==========\n\nChild documentation.\n", encoding="utf-8", ) + (source / "example.py").write_text( + 'print("example survives cache reuse")\n', + encoding="utf-8", + ) warnings = io.StringIO() app = Sphinx( @@ -622,34 +646,47 @@ def rendered_markdown(tmp_path, monkeypatch): assert app.statuscode == 0, warnings.getvalue() pages = list(output.rglob("index*.md")) assert len(pages) == 1 - return pages[0].read_text(encoding="utf-8") + return SimpleNamespace( + markdown=pages[0].read_text(encoding="utf-8"), + html=(output / "index.html").read_text(encoding="utf-8"), + ) + +def test_rendered_mermaid(rendered_docs): + rendered_markdown = rendered_docs.markdown -def test_rendered_mermaid(rendered_markdown): assert "```mermaid\n" in rendered_markdown assert "graph TD\n" in rendered_markdown assert "A --> B" in rendered_markdown -def test_rendered_code_caption_and_sample(rendered_markdown): +def test_rendered_code_caption_and_sample(rendered_docs): + rendered_markdown = rendered_docs.markdown + assert "**Example code**" in rendered_markdown assert 'print("hello")' in rendered_markdown assert rendered_markdown.index("**Example code**") < (rendered_markdown.index('print("hello")')) -def test_rendered_keyword_only_marker(rendered_markdown): +def test_rendered_keyword_only_marker(rendered_docs): + rendered_markdown = rendered_docs.markdown + signature = next(line for line in rendered_markdown.splitlines() if "configure(" in line) assert "*" in signature assert "model_id" in signature -def test_rendered_toctree_caption(rendered_markdown): +def test_rendered_toctree_caption(rendered_docs): + rendered_markdown = rendered_docs.markdown + assert "**Further reading**" in rendered_markdown assert "[Child page]" in rendered_markdown assert "# Further reading" not in rendered_markdown -def test_rendered_admonition_has_clear_boundaries(rendered_markdown): +def test_rendered_admonition_has_clear_boundaries(rendered_docs): + rendered_markdown = rendered_docs.markdown + lines = rendered_markdown.splitlines() assert any(line.startswith(">") and "**Note:**" in line for line in lines) assert any(line.startswith(">") and "Important configuration advice." in line for line in lines) @@ -657,12 +694,16 @@ def test_rendered_admonition_has_clear_boundaries(rendered_markdown): assert not following.startswith(">") -def test_rendered_table_is_compact(rendered_markdown): +def test_rendered_table_is_compact(rendered_docs): + rendered_markdown = rendered_docs.markdown + table_lines = [line.strip() for line in rendered_markdown.splitlines() if line.strip().startswith("|")] assert "| Name | Value |" in table_lines assert "|---|---|" in table_lines assert "| Short | A much longer value |" in table_lines -def test_rendered_same_page_link(rendered_markdown): +def test_rendered_same_page_link(rendered_docs): + rendered_markdown = rendered_docs.markdown + assert "[Setup](#setup-section)" in rendered_markdown diff --git a/devel-common/tests/unit/sphinx_exts/test_redirects.py b/devel-common/tests/unit/sphinx_exts/test_redirects.py index 9606021adab4..b26e95364288 100644 --- a/devel-common/tests/unit/sphinx_exts/test_redirects.py +++ b/devel-common/tests/unit/sphinx_exts/test_redirects.py @@ -22,13 +22,8 @@ import pytest from sphinx.builders.html import StandaloneHTMLBuilder -from sphinx_exts import redirects -from sphinx_exts.redirects import build_redirect_page # noqa: E402 -SPHINX_EXTS_PATH = Path(__file__).parents[3] / "src" / "sphinx_exts" -if SPHINX_EXTS_PATH.as_posix() not in sys.path: - # The extensions are loaded by Sphinx from this directory and import each other by bare name. - sys.path.append(SPHINX_EXTS_PATH.as_posix()) +from sphinx_exts import redirects @pytest.fixture @@ -150,12 +145,10 @@ def test_generate_html_redirects(app): redirects.generate_redirects(app) - assert (output / "old.html").read_text(encoding="utf-8") == ( - '' - ) + assert (output / "old.html").read_text(encoding="utf-8") == (redirects.build_redirect_page("new.html")) destination = f"..{os.path.sep}concepts.html" assert (output / "hooks/index.html").read_text(encoding="utf-8") == ( - f'' + redirects.build_redirect_page(destination) ) @@ -176,6 +169,7 @@ def test_generate_redirects_without_redirect_file(app): assert not list(output.rglob("*")) + @pytest.mark.parametrize( "to_path", [ @@ -183,8 +177,8 @@ def test_generate_redirects_without_redirect_file(app): pytest.param("../security/index.html", id="without-anchor"), ], ) -def test_redirect_page_keeps_the_requested_anchor(to_path): - page = build_redirect_page(to_path) +def test_redirect_page_contains_anchor_preserving_script(to_path): + page = redirects.build_redirect_page(to_path) assert f'var target = "{to_path}";' in page assert 'target = target.split("#")[0] + window.location.hash;' in page diff --git a/providers/common/ai/docs/sandbox/backends.rst b/providers/common/ai/docs/sandbox/backends.rst deleted file mode 100644 index 99defefa9602..000000000000 --- a/providers/common/ai/docs/sandbox/backends.rst +++ /dev/null @@ -1,830 +0,0 @@ - .. Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - .. http://www.apache.org/licenses/LICENSE-2.0 - - .. Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -Sandbox backends -================ - -.. meta:: - :description: The sandbox backends that ship with the provider (Modal, OpenSandbox and sbx Docker Sandboxes), what each needs and isolates, which to use in production, and how to write your own. - -.. note:: - - Experimental: this can change or be removed in a minor release of this provider. - See :ref:`howto/stability`. - -.. _sandbox-backend-modal: - -Modal (hosted) --------------- - -:class:`~airflow.providers.common.ai.sandbox.modal.ModalSandboxBackend` runs each -sandbox in Modal, provisioned over the API. Of the backends that ship with the -provider, **this is the managed one to use in production**, and with -:ref:`OpenSandbox `, :ref:`OpenShell `, -:ref:`Boat ` and :ref:`Islo ` one of the five a -worker on Kubernetes can use: nothing has to be installed on the worker, model-written code never executes on the worker host, and Modal reclaims -a sandbox at its own lifetime whether or not the worker survives. It needs the -``modal`` extra and Modal credentials, from a ``modal`` connection or the worker -environment, as under :ref:`Quick start `. - -Constructor parameters: - -- ``modal_conn_id``: ``modal`` connection the token and, optionally, the Modal - ``environment`` come from. Default ``"modal_default"``; ``None`` uses the worker's - credentials without looking for a connection. How a missing or partial connection - resolves is on the :ref:`Modal connection page `. A credential - problem fails the task, except in the toolset's own teardown, which logs it so a - finished run is not failed. The connection type comes from the Modal provider, which - the ``modal`` extra installs and which needs Airflow 3. -- ``image``: Registry tag for the sandbox image, or a prepared ``modal.Image`` - carrying pre-installed packages. Default ``"python:3.12-slim"``. -- ``app_name``: Modal app the sandboxes are created under. Default - ``"airflow-sandbox"``. -- ``create_app_if_missing``: Create that app if it does not exist. Default ``True``. -- ``sandbox_timeout``: Maximum lifetime of a sandbox in seconds. Default ``3600``. - Modal's own default is 300, which is below a plausible agent run. -- ``idle_timeout``: Seconds of inactivity after which Modal reclaims the sandbox, - or ``None`` to rely on ``sandbox_timeout`` alone. Default ``None``; see - :ref:`sandbox-timeouts`. -- ``workdir``: Working directory for commands, created if the image lacks it. - Default ``"/workspace"``. It is a starting directory, not a jail: absolute paths - and ``..`` are passed through, and commands run as root, so the model can read - and write anywhere in the sandbox filesystem. The sandbox boundary is what - contains that. -- ``cpu``, ``memory``, ``gpu``, ``region``, ``cloud``: passed through to Modal. - ``None`` lets Modal choose. An unrecognized ``region`` or ``cloud`` fails the - task rather than falling back. -- ``tags``: Extra Modal tags on every sandbox, e.g. ``{"dag_id": "my_dag"}``. - The backend's own ``airflow_`` keys overwrite a tag of the same name. -- ``egress_enforcement``: ``"strict"`` (default) or ``"sni"``. See below. - -**A sandbox can be provisioned by one task and used by another.** Modal finds a -sandbox by id from any process, so this backend implements -:class:`~airflow.providers.common.ai.sandbox.AttachableSandboxBackend`: a -``@task`` calls ``create`` and later ``destroy``, and a ``SandboxToolset`` with -``attach_to`` uses the sandbox in between. The ownership rules ride on Modal tags, -``airflow_owner`` from ``SandboxSpec.owner``, ``airflow_holder`` while a run holds -the sandbox, ``airflow_expires_at`` so the attaching side knows the clock and -``airflow_network`` so it knows the policy, and ``Sandbox.list(tags=...)`` finds -them. Reading tags back needs ``modal>=1.5.2``, which is the extra's floor. How -to use it is on :ref:`Configuration `. - -**Network policy.** ``block_network=True`` maps exactly onto Modal's own -``block_network``, which drops all outbound traffic including DNS. A spec that -names ``allow_egress_to`` is **refused by default**, because Modal cannot combine -an allowlist with ``block_network`` at all, and its hostname allowlist is enforced -by matching the name in the TLS handshake, which means: - -- TLS on port 443 to a listed host connects; any other host is refused at once. -- **Non-TLS traffic is dropped, not refused.** A plain HTTP connection to a listed - host stalls until the client gives up, around two minutes of TCP retries for one - address, so with the 60 s default command budget the model reads - ``[timed out after 60s]`` and concludes its command was slow, never that the - network stopped it. -- **The destination address is not part of the decision.** A connection opened to - an unrelated address while presenting a listed name is routed to the listed host - and answered by it: connecting to ``8.8.8.8:443`` with ``pypi.org`` in the - handshake returns the certificate and content of ``pypi.org``. The allowlist is a - name-routed egress proxy, not a filter on where packets may go. -- **DNS resolution stays open for every hostname**, listed or not, against - authoritative servers outside Modal. A freshly generated label under a domain the - operator controls resolves and returns its answer, so this is a two-way channel. -- A host that shares a **TLS endpoint** with a listed one can be reached by - presenting the listed name in the handshake and the other in the request. With - ``pypi.org`` as the only allowed host, a TLS session opened to - ``files.pythonhosted.org`` while presenting ``pypi.org`` was allowed through and - answered. Other tenants of the same CDN returned ``421 Misdirected Request``; it is - co-tenancy of the same TLS endpoint that matters, which you cannot check from - outside and which can change without notice. - -So the allowlist says which name a TLS session may be routed to, and nothing else. -Pass ``ModalSandboxBackend(egress_enforcement="sni")`` to say you accept that and -have the allowlist applied: - -.. code-block:: python - - SandboxToolset( - ModalSandboxBackend(egress_enforcement="sni"), - spec=SandboxSpec(block_network=True, allow_egress_to=["pypi.org", "files.pythonhosted.org"]), - ) - -Entries must be bare hostnames or one leading ``*.`` label; a URL, a ``host:port``, -an address or a single-label name is refused, because Modal applies the list without -checking it and any of those would silently match nothing. - -**An address allowlist is enforced properly, and needs no opt-in.** -``allow_egress_to_cidrs`` maps onto Modal's ``outbound_cidr_allowlist``, which -decides on the destination address for any port and protocol. Measured on -2026-09-22 with ``["1.1.1.1/32"]``: the listed address connected on 443 and on 53, -an unlisted address timed out on both, and ``block_network`` with the list set was -refused at create, as with the hostname list. This is the right mode for one -service at a fixed public address, which is the case the hostname list serves -worst. It cannot serve a package registry behind a CDN, whose addresses rotate -faster than a sandbox lives. - -.. code-block:: python - - SandboxToolset( - ModalSandboxBackend(), - spec=SandboxSpec(block_network=True, allow_egress_to_cidrs=["203.0.113.0/24", "198.51.100.7/32"]), - ) - -Four things to know about it: - -- **The address has to be public, and IPv4.** Private ranges are unreachable from a - Modal sandbox whatever the allowlist says: measured, connections to ``10.20.0.1``, - ``172.16.0.1``, ``192.168.1.1`` and the cloud metadata address timed out both under - an open network and with those ranges on the allowlist, so a service on your own private - network cannot be reached this way; it needs a public address, or a way onto your - network that Modal provides and this backend does not configure. Modal's allowlist - also rejects IPv6 ranges outright, and the sandbox has no IPv6 route, so an IPv6 - entry is refused here with the reason. - -- **Hostnames still resolve.** Modal's own resolver inside the sandbox answers - every lookup, so ``pypi.org`` resolves to its addresses and a connection to them - then times out. The tool description tells the model this so a successful lookup - is not read as a reachable host. DNS is therefore still a channel out, as it is - under the hostname list; only ``block_network=True`` with no allowlist closes it. -- **Entries are canonical CIDR.** A bare address is written as ``/32``. A range with - host bits set, such as ``203.0.113.1/24``, is refused rather than widened to - ``203.0.113.0/24``, because that is not what was written. A hostname, a - URL or a ``host:port`` is refused, since Modal would accept it and match nothing. - ``0.0.0.0/0`` and ``::/0`` are refused too: an allowlist of every address is an - open network, and ``block_network=False`` is how to ask for one. -- **Combining the two lists weakens the address one.** Modal applies them - together, and traffic matching either passes. Measured, adding ``pypi.org`` to the - hostname list beside ``["1.1.1.1/32"]`` made a TCP connection to ``8.8.8.8:443`` - succeed, because port 443 is then routed by handshake name for every address. So - a combined spec has the address list's guarantee on every port except 443, and - the hostname list's caveats there. The hostname half keeps its - ``egress_enforcement="sni"`` opt-in when combined, and the backend logs a warning - at create naming the weakening. - -**What the image needs.** ``write_file`` and ``list_directory`` use Modal's own -filesystem API, served by a helper Modal injects into the sandbox, so they need -nothing from the image. ``read_file`` deliberately does not: Modal's read API takes -no length, so it cannot honor a read budget, and a single call on a file that -streams without end (``/dev/zero``, a FIFO, a procfs entry) would pull it into -worker memory unbounded. That tool runs the base class's shell implementation, -which caps the read inside the guest, and the image needs ``stat``, ``head`` and -``base64``. Any Debian or Ubuntu based image, including ``python:*-slim``, has -them. - -**Symlinks.** Because ``write_file`` goes through the native API, writing to a path -that is a symlink replaces the link with a regular file and leaves the original -target untouched, where a shell redirect would follow the link. - -.. _sandbox-backend-islo: - -Islo (hosted microVM) ---------------------- - -:class:`~airflow.providers.common.ai.sandbox.islo.IsloSandboxBackend` runs each -sandbox in an `islo.dev `__ microVM, provisioned over the API. -Like Modal and unlike ``sbx``, the worker only speaks HTTP: it needs no local -daemon and no host virtualization, so it runs from a containerized worker and on -Kubernetes. - -Install the SDK extra: - -.. code-block:: bash - - pip install "apache-airflow-providers-common-ai[islo]" - -.. code-block:: python - - from airflow.providers.common.ai.sandbox import IsloSandboxBackend - from airflow.providers.common.ai.toolsets import SandboxToolset - - SandboxToolset(IsloSandboxBackend()) - -Credentials are ambient. On first use the SDK reads ``ISLO_API_KEY``, and optionally -``ISLO_BASE_URL`` and ``ISLO_COMPUTE_URL``, from the worker environment. Modal's -``modal`` connection comes from the Modal provider; an ``islo`` connection type waits -for an Islo provider. - -Constructor parameters: - -- ``image``, ``vcpus``, ``memory_mb``: image and sizing. ``None`` (default) uses - the server default for each. The server default image is Debian based, and any - Debian or Ubuntu based image, including ``python:*-slim``, has the GNU ``find``, - ``stat`` and ``tail`` the file operations need; Alpine and other busybox images - do not. -- ``pause_after_idle``: Seconds without a command or file operation after which - the server pauses the microVM and stops charging for its compute. Default - ``600``; ``None`` disables it. -- ``auto_resume``: ``"on_activity"`` (default) resumes a paused sandbox on the - next tool call, so a long think between calls costs a resume rather than the - run; ``"never"`` leaves it paused, and the backend then treats a paused sandbox - as unusable. -- ``delete_after``: Seconds after **creation** at which the server deletes the - sandbox, whether or not it is in use. Default ``86400``; ``None`` disables it. - This is the backstop for a worker killed mid-run; it is not renewed while the - sandbox is busy, so keep it longer than the longest run you expect. - -``SandboxSpec.env`` becomes the process environment of every command, and -``block_network`` maps to the API's ``internet_enabled``. Four things Islo cannot -do are refused at ``create`` rather than silently dropped: ``allow_egress_to`` and -``allow_egress_to_cidrs`` (the API turns outbound access on or off, with no -per-host or per-address rule), a ``PATH`` entry in ``env`` (the runner sets -``PATH`` for every command itself), and ``owner`` (this backend keeps no -per-sandbox metadata, so it cannot be attached to from another task). - -File reads, writes and exports move file contents through Islo's native -streaming APIs. Everything else runs through a shell wrapper in the sandbox, so -the image needs ``sh``, ``mkdir`` and ``rm`` for the wrapper, ``tail`` to bound -command output, ``dirname`` to create a written file's parent directory, -``stat`` to size an over-budget read and to check a file before it is exported, -``realpath`` to resolve a relative export path (the download API takes absolute -paths only), and GNU ``find`` for directory listings. The compute API caps each output stream -at 1 MiB and keeps the tail. The backend captures each stream to a scratch file in -the sandbox and returns only its last ``max_output_bytes`` -- where a traceback -and the exit status live -- so the worker sees a window sized to the caller's -budget, a budget above the server cap is clamped to it, and total output is -bounded by the sandbox's own ephemeral disk rather than by worker memory. - -The backend enforces the command deadline itself, because the API's -``timeout_secs`` is accepted but not enforced, and times it from the API's answer -to the start request, so a slow start does not use it up. Polling rides out -transient API errors until the deadline. If the command is still running when -the deadline passes, the backend deletes the microVM and reports the command as -timed out with ``sandbox_terminated`` set, so the toolset provisions a fresh -sandbox for the next call. A deletion the API refused is logged rather than -failing the task, and ``delete_after`` reclaims the microVM later; with -``delete_after=None`` nothing does, and the warning says so. If the API was still -failing at the deadline, nothing is known about the command, so the task fails -instead and Airflow's retry takes over. - -A missing file, a directory passed as a file, a relative path, and a write onto a -directory or under a pseudo-filesystem such as ``/proc`` or ``/sys`` come back to -the model as a recoverable error it can correct, once the backend has confirmed -the sandbox itself is still usable. - -.. _sandbox-backend-opensandbox: - -OpenSandbox (self-hosted remote) --------------------------------- - -:class:`~airflow.providers.common.ai.sandbox.opensandbox.OpenSandboxBackend` -runs sandboxes through an `OpenSandbox `__ server. -The server may use Docker or Kubernetes; Airflow workers only use its HTTP API -and do not need access to the container runtime. - -Install the SDK extra: - -.. code-block:: bash - - pip install "apache-airflow-providers-common-ai[opensandbox]" - -Use a generic Airflow connection, resolved lazily on first use: - -.. code-block:: python - - from airflow.providers.common.ai.sandbox import OpenSandboxBackend - from airflow.providers.common.ai.toolsets import SandboxToolset - - SandboxToolset(OpenSandboxBackend(opensandbox_conn_id="opensandbox_default")) - -The connection ``host`` is required; ``port`` is optional, ``schema`` defaults to -``http``, and ``password`` carries the API key when required. Extras may set -``request_timeout`` (default 30 seconds) and ``use_server_proxy`` (default -``true``). Set ``opensandbox_conn_id=None`` to let the SDK read -``OPEN_SANDBOX_DOMAIN`` and ``OPEN_SANDBOX_API_KEY``. - -``SandboxSpec.env`` is sent at creation. A default spec sends a deny-all -network policy; ``allow_egress_to`` becomes explicit allow rules. With -``block_network=False``, the backend omits network policy entirely so a -deployment without the egress sidecar can still run an intentionally open -sandbox. Deny/allowlist policy requires the sidecar, so the backend reads the -enforced policy back after creation and destroys the sandbox if it does not -match the requested spec. ``allow_egress_to_cidrs`` is refused; this backend does -not translate address ranges into OpenSandbox rules. - -The read-back also checks the mode the sidecar enforces the policy in, set by -``[egress] mode`` in the server configuration. Only ``dns+nft`` drops connections at -the address layer. In ``dns`` mode, the server's default, the sidecar filters name -resolution and nothing else, so a deny-all sandbox could still connect to any -numeric address, including a DNS-over-HTTPS resolver that would look up any name for -it, and a sandbox with an allowlist could connect to addresses outside the list. The -backend destroys the sandbox and fails the task on any mode but ``dns+nft``, so set -``mode = "dns+nft"`` on a server that runs sandboxes with a deny-all policy or an -allowlist, or pass ``SandboxSpec(block_network=False)`` for a sandbox that may reach -the network. - -Every sandbox carries ``created-by: airflow`` metadata and an -``airflow-sandbox-*`` name for attribution and cleanup. The server enforces a -sandbox lifetime (default 3600 seconds). If the SDK event stream stalls, the -worker abandons the call after the command budget plus a grace period, destroys -the sandbox, and reports ``sandbox_terminated`` so the toolset provisions a fresh -one. Output is bounded per stream after the SDK yields it; a single newline-free -line is the SDK-level exception, because the SDK assembles that line before the -backend sees it. - -Constructor parameters: - -- ``image``: image used by the server. Default ``"python:3.12-slim"``. -- ``cpu`` and ``memory``: resource limits. Defaults ``"1"`` and ``"2Gi"``. -- ``sandbox_timeout``: server-side lifetime in seconds. Default ``3600``. -- ``ready_timeout``: provisioning/reconnect timeout. Default ``120``. -- ``use_server_proxy``: override the connection extra for file and command calls. - -The runtime remains a deployment choice. The default Docker runtime shares the -host kernel; choose a stronger runtime such as Kata when your threat model needs -a VM boundary. - -.. _sandbox-backend-openshell: - -OpenShell (self-hosted remote) ------------------------------- - -:class:`~airflow.providers.common.ai.sandbox.openshell.OpenShellSandboxBackend` -runs sandboxes through an `NVIDIA OpenShell `__ -gateway, which runs each one on Docker, Podman or Kubernetes. Inside the -container the workload is confined by Landlock and seccomp; on the Docker driver it -has only a loopback network interface, and a per-sandbox supervisor opens every -outbound connection on its behalf, against a policy the backend writes and reads back. Airflow workers -only need gRPC access to the gateway. - -Choose it over :ref:`OpenSandbox ` when you want the -sandbox runtime itself to enforce deny-all and the hostname allowlist, rather than -an egress sidecar that has to run in the right mode. It is Apache-2.0 and runs on a -single machine with no account, so it is also the self-hosted backend to try first -on a laptop. For a production gateway on Kubernetes, prefer OpenSandbox or Modal: -this backend has been verified on OpenShell's Docker driver only, which OpenShell -scopes to local development and single-machine gateways. - -Install the SDK extra: - -.. code-block:: bash - - pip install "apache-airflow-providers-common-ai[openshell]" - -**Credentials are ambient; there is no Airflow connection for this backend.** -The gateway's endpoint, mTLS material and OIDC token live in the gateway -registration that the ``openshell`` CLI keeps under -``$XDG_CONFIG_HOME/openshell/gateways//`` (``~/.config`` by default), and -the OpenShell SDK reads them from there itself: ``metadata.json`` with the -endpoint, and ``mtls/ca.crt``, ``mtls/tls.crt`` and ``mtls/tls.key`` for mTLS, -or the CLI's cached token for an OIDC gateway. The backend only names the -registration. A worker without the CLI needs the same files, provisioned by the -Deployment Manager: - -.. code-block:: json - - {"name": "prod", "gateway_endpoint": "https://openshell.example.com:17670", "auth_mode": "mtls"} - -.. code-block:: python - - from airflow.providers.common.ai.sandbox import OpenShellSandboxBackend - from airflow.providers.common.ai.toolsets import SandboxToolset - - SandboxToolset(OpenShellSandboxBackend(gateway="prod")) - -An OIDC registration must be writable and per worker. The SDK refreshes an -expiring OIDC token itself and writes the new one back into the registration, -so a registration mounted read-only, from a Kubernetes Secret or ConfigMap for -example, fails the task at the first refresh, and copies of one registration on -several workers share a refresh token that the first refresh can invalidate for -the others. mTLS is the supported setup for workers that mount the registration -read-only. - -Whoever holds that credential is inside the trust boundary. On a gateway -without OIDC, an mTLS client is a gateway-wide administrator: it can change the -policy and settings of every sandbox. ``openshell-gateway generate-certs`` issues -a single client identity whose certificate does not expire for practical -purposes, so use your own PKI, with expiry and rotation, for a worker credential. - -**Network policy.** A default ``SandboxSpec()`` sends a policy with no egress -rule, which OpenShell enforces as no egress: a connection fails with -``EACCES``, and a name lookup is answered by the supervisor with a synthetic -``198.18.0.0/15`` address rather than failing, so no query leaves the sandbox -although the tool description's "including DNS" wording reads stricter than the -lookup behaves. ``allow_egress_to`` becomes one rule admitting each listed host -on port 443 for any program in the sandbox; ports are part of every rule, so -plain HTTP and other ports stay closed. HTTPS to a listed host is terminated by -the supervisor, which injects its CA through ``SSL_CERT_FILE``, -``REQUESTS_CA_BUNDLE`` and similar variables; a client with its own trust store -(a JVM, a statically linked binary) has to be pointed at it. A leading ``*.`` -label is accepted on a name of three labels or more. - -The backend verifies the policy rather than trusting the request. After create -it reads the effective policy back and destroys the sandbox unless it admits -exactly the requested hosts, comes from the sandbox rather than a gateway-wide -policy, keeps Landlock at ``hard_requirement``, and has neither -``proposal_approval_mode=auto`` nor agent policy proposals enabled at any scope. -Auto-approval is refused because OpenShell turns a denied connection into a -proposed allow rule and, in that mode, approves it without review. The same -check runs before every command and file operation and after each one that -succeeds, because an administrator, an approved -draft or a gateway-wide policy can widen a running sandbox; a change destroys the -sandbox and fails the task. That detects a widening, it does not prevent one: a -command already running when the policy changes can use it. The check sees -OpenShell's policy, not the network under the gateway: on Kubernetes, a sandbox -pod is kept behind its supervisor by a NetworkPolicy, which only a CNI that -enforces NetworkPolicy upholds. Every denied connection also becomes a draft -proposal in the gateway's approval inbox, even in manual mode, so operators see -which destinations an agent tried. - -Refused at create: ``block_network=False`` (every OpenShell rule names a host and -its ports, so an open network cannot be expressed), ``allow_egress_to_cidrs`` -(address rules admit TCP on listed ports only), ``SandboxSpec.owner``, and -``SandboxSpec.env`` keys the supervisor owns: it removes ``HTTP_PROXY`` and the -other proxy variables from every command and replaces ``SSL_CERT_FILE``, -``REQUESTS_CA_BUNDLE``, ``CURL_CA_BUNDLE``, ``GIT_SSL_CAINFO``, -``NODE_EXTRA_CA_CERTS`` and ``DENO_CERT`` with its own, without an error, and -reserves ``OPENSHELL_*``. Keys starting with ``_airflow_`` are refused too, because the -command wrapper below names its own shell variables that way. Everything else in -``SandboxSpec.env``, ``PATH`` included, reaches commands as given, since they run -without a login shell. - -**Commands.** OpenShell's own exec timeout reports exit 124 and leaves the -command running, so the backend runs each command through a small shell wrapper -in the sandbox. The command arrives on stdin and runs in a session of its own, -with the command and its output spooled to ``/tmp``; one that cannot be written -there, because ``/tmp`` is full for example, is not run and is reported as an -error. When the budget runs out the wrapper kills the processes in that session, -scanning again until a pass finds none to kill, at most 50 times, and returns the -tail of each stream. A process the command left in the background keeps running -after a command that finishes in time, and one that started a session of its own -(``setsid``, a daemonizing server) escapes the kill on timeout, as can a command -that keeps forking faster than the sweep. If the gateway stops relaying the -command for longer than its budget plus 30 seconds, ``sandbox_terminated`` is -reported and the backend asks the gateway to delete the sandbox; if that call -fails too, it logs a warning and the sandbox is left for the reaper described -below. Nothing crosses the stream -until the command ends, so a proxy or load balancer in front of the gateway -needs an idle timeout longer than the longest command budget plus 30 seconds. A -command the gateway could not start, because its relay into the sandbox did not -open, is reported to the model as not run. A gateway restart stops every process -in its sandboxes. If the gateway brings the sandbox back, its files are kept and a -command in flight is reported to the model as having an unknown outcome rather -than retried; if it does not, the task fails. A dropped connection to a gateway -that stays up is reported the same way, but does not stop the command: it runs -until its budget runs out, and the model is told it may still be running. - -**Files.** ``write_file`` sends content on stdin in chunks of 768 KiB, since the -gateway limits one command argument to 32 KiB and one request to 1 MiB; a larger -write is not atomic, and it follows a symlink like a shell redirect. ``read_file`` -transfers raw bytes, capped inside the guest. Both refuse a named pipe, since -opening one waits for another process and nothing would end the wait in the -sandbox; ``run_command`` with a timeout can still read or write one. The image needs ``setsid`` (from -util-linux), GNU coreutils and findutils, and a ``/bin/sh`` that is dash or bash, -which ``python:*-slim`` and other Debian or Ubuntu based images have; an image -without ``setsid`` fails the task at its first command. BusyBox ``ash``, the -``/bin/sh`` of Alpine images, is not supported: the timeout sweep does not finish -under it, so a command that runs out of time is not killed, and after its budget -plus 30 seconds the backend asks the gateway to delete the sandbox instead. The gateway's own default image has no ``python3``, which is -why the backend defaults to ``python:3.12-slim``. - -**Cleanup.** OpenShell has no server-side sandbox lifetime. ``destroy`` deletes -the sandbox, but one whose worker died is kept until someone deletes it, even -after its main process has ended. Sandboxes are named ``airflow-`` plus 11 hex -characters, within OpenShell's 19-character limit, and labeled -``created-by=airflow`` and ``airflow-created-at=``, so a reaper can -delete by age: - -.. code-block:: python - - import time - - from openshell import SandboxClient - - client = SandboxClient.from_active_cluster(cluster="prod") - cutoff = time.time() - 6 * 3600 - for sandbox in client.list_all(workspace="default", label_selector="created-by=airflow"): - if int(sandbox.labels.get("airflow-created-at", "0")) < cutoff: - client.delete(sandbox.name, workspace="default", allow_missing=True) - -Constructor parameters: - -- ``gateway``: the CLI gateway registration to use. ``None`` (default) uses - ``$OPENSHELL_GATEWAY``, then the CLI's active gateway. -- ``workspace``: OpenShell workspace. Default ``"default"``. -- ``image``: image used by the gateway. Default ``"python:3.12-slim"``. -- ``cpu`` and ``memory``: resource limits as Kubernetes quantities. Defaults - ``"1"`` and ``"2Gi"``. ``nproc`` in the sandbox still reports the host's CPUs. -- ``ready_timeout``: seconds to wait for a new sandbox. Default ``120``; a first - pull of a large image can take longer, so pre-pull it on the gateway host. -- ``request_timeout``: seconds for each gateway call other than a command. - Default ``30``. - -The kernel the sandboxes run on needs Landlock ABI 3 or later (Linux 6.2+) and -seccomp user notification, and the gateway needs Docker 28 or later, Podman 5, or -a Kubernetes cluster with the Agent Sandbox controller. On macOS the gateway runs -against the Linux VM of a Docker runtime such as OrbStack or colima. OpenShell scopes its Docker driver to -local development and single-machine gateways. This backend has been verified with -the Docker driver only; on Kubernetes, egress enforcement also depends on the -cluster's CNI enforcing NetworkPolicy. The gateway sends anonymous -telemetry unless it runs with ``OPENSHELL_TELEMETRY_ENABLED=false``. - -.. _sandbox-backend-boat: - -Boat (hosted) -------------- - -:class:`~airflow.providers.common.ai.sandbox.boat.BoatSandboxBackend` runs each -sandbox on `Boat `__, the hosted cloud-computer -API formerly called Ascii Box. The Airflow worker needs only network access and -an API key: no local daemon, Docker socket, KVM or nested virtualization, so it -runs from a containerized worker and on Kubernetes. - -Install the SDK extra: - -.. code-block:: bash - - pip install "apache-airflow-providers-common-ai[boat]" - -.. code-block:: python - - from airflow.providers.common.ai.sandbox import BoatSandboxBackend, SandboxSpec - from airflow.providers.common.ai.toolsets import SandboxToolset - - SandboxToolset( - BoatSandboxBackend(), - spec=SandboxSpec(block_network=False), - ) - -Credentials can come from a generic Airflow connection, resolved lazily on first -use: - -.. code-block:: python - - SandboxToolset( - BoatSandboxBackend(boat_conn_id="boat_default"), - spec=SandboxSpec(block_network=False), - ) - -The connection ``password`` is the Boat API key and is required. ``host``, when -set, is the full API base URL, such as ``https://boat.dev/api/v1``, which is also -the default. It must start with ``https://`` or ``http://``: a bare domain such as -``boat.dev``, which is what Airflow's connection URI form leaves in ``host``, is -refused, since the API key would otherwise be sent to it over plain HTTP. With -``boat_conn_id=None``, the default, the backend reads ``BOAT_API_KEY`` (required) -and optional ``BOAT_BASE_URL`` from the worker environment instead, and -``BOAT_BASE_URL`` must carry the scheme too. - -Constructor parameters: - -- ``org``: the Boat wallet each sandbox is billed to, by organization id or name, - or ``"personal"``. Default ``"personal"``, which bills your own account whatever - its active wallet is. See the warning below before naming an organization. -- ``machine_type``: ``"small"``, ``"default"`` or ``"large"``. -- ``ttl_seconds``: server-side TTL after which Boat stops the sandbox, a whole - number of seconds up to ``2592000`` (30 days). Default ``3600``. -- ``ready_timeout``: provisioning deadline in seconds, from the create request - until the sandbox is ready. Default ``300``. -- ``request_timeout``: HTTP timeout in seconds for an API call that answers at - once, such as the create request, a status check or a delete, and the time - added to the operation's own for a call that waits on one: a command's - deadline, or 120 seconds for a file write. Default ``30``. - -A create request that times out, fails in transport, or gets a server error may -still have started a sandbox, so it is sent again with the same idempotency key, -and Boat answers with the sandbox the first request created rather than starting -a second one. While Boat is still creating that sandbox, it answers the resent -request with 409 ``idempotency_in_progress``, and the backend sends it again two -seconds after each such answer until ``ready_timeout`` runs out. Each resend gets -what is left of ``ready_timeout`` plus ``request_timeout``, so provisioning takes -at most their sum, and a sandbox a resend finds too late to become ready in time -is deleted rather than left running until its TTL. If a resend fails any other -way, or Boat is still creating the sandbox when ``ready_timeout`` runs out, the -backend never receives the sandbox's id, so any sandbox the first request started -keeps a server-assigned name and runs until Boat stops it at ``ttl_seconds``. - -Every sandbox is created with Boat's ``noEnv`` flag, so it gets none of your Boat -account's stored environment variables, secret files or credentials, and cannot -act on your account or your other sandboxes. - -.. warning:: - - Boat gives every member of an organization use of a ``noEnv`` sandbox billed - to that organization: they can open it and run commands in it, so they can - read and write anything in it, including the ``SandboxSpec.env`` values each - command receives. Pass ``org`` only when everyone in that organization may see - what the agent works on. - -``SandboxSpec.env`` is passed when the sandbox is created and also exported at -the start of every command, so each value is sent again with every command -request. **Boat cannot enforce a deny-all network policy, a per-domain egress -allowlist, or a CIDR egress allowlist**, so the backend refuses -``block_network=True``, ``allow_egress_to``, and ``allow_egress_to_cidrs`` -rather than silently provisioning something weaker than the spec asked for. -Since ``block_network`` defaults to ``True``, that includes a bare -``SandboxSpec()``: pass ``SandboxSpec(block_network=False)`` to state that open -egress is acceptable, or use Modal when it is not. - -Writes use Boat's native file API, which accepts only paths that resolve under -``/home/user`` (where relative paths land) or ``/tmp``. The parent directory is -created first with ``mkdir -p`` in the guest, so a ``write_file`` anywhere else -fails with ``mkdir``'s own error when the guest user cannot create the parent -directory, and with Boat's ``invalid_path`` error when that directory exists or -could be created. Either way the model gets it back as a tool error it can -retry. Reads deliberately keep the inherited bounded shell implementation, so -``max_bytes`` is enforced inside the guest before file contents reach worker -memory. - -That path rule binds only ``write_file``; it is not a jail. Commands run as the -guest user ``user``, which `Boat documents `__ as -having root through ``sudo`` with no password, so a command the model writes can -read and write anywhere in the sandbox filesystem. The sandbox also has a public -IPv4 or IPv6 address, and its firewall is inside the guest: Boat's -`hosting guide `__ opens a port to the internet -with ``ufw``, which a command can do too. The sandbox boundary is what contains -that. - -A command's deadline is enforced inside the sandbox by GNU coreutils -``timeout``, which sends ``SIGTERM`` and then ``SIGKILL`` five seconds later, so -a command that runs out of time returns the tail of what it printed, and the -sandbox and its files survive. Boat's own deadline is set 15 seconds past that -one, and Boat's API caps it at 600 seconds, so any command that asks for more -than 585 seconds gets 585, and the result reports that deadline to the model. -Only when Boat's own deadline ends the call, because the one in the guest did -not, is the sandbox torn down, as is a sandbox that never becomes ready. A file -read, listing, or write that Boat's deadline ends that way fails the task, since -there is no sandbox left for the model to retry against. If the worker dies -first, the server-side TTL stops the sandbox. Sandboxes are created without -snapshots, so stopping one erases its disk rather than keeping it for an -operator to remove, and with monitoring off, so Boat keeps no history of the -commands, their output, or the environment variables exported into them. - -.. _sandbox-backend-sbx: - -sbx (Docker Sandboxes, local) ------------------------------ - -:class:`~airflow.providers.common.ai.sandbox.SbxSandboxBackend` runs each sandbox -in a Docker Sandboxes microVM by driving the ``sbx`` CLI. Each sandbox is a real -microVM with its own kernel. - -.. warning:: - - **Use this backend for local development, not production.** Docker Sandboxes - is built for running coding agents against a checkout on your own machine, and - driving it from an Airflow worker is off-label use. A production worker would - need the ``sbx`` binary on the host, an authenticated Docker account - (``sbx login``), a one-time ``sbx policy init``, and on Linux, KVM or nested - virtualization, which a worker in an unprivileged container cannot provide. - - **Orphans are not reclaimed.** There is no server-side lifetime. If the worker is - killed outright, the microVM and its workspace directory survive; sandboxes are - named ``airflow-sandbox-*`` so an operator can find and remove them. - -Installing the CLI is a Deployment Manager prerequisite (``brew install -docker/tap/sbx`` or ``winget install Docker.sbx``); the backend needs no Python -dependency. The template image must provide GNU coreutils ``timeout``, ``base64``, -``stat``, ``head``, ``find``, ``mkdir`` and ``dirname``, which any Debian or Ubuntu -based image has. - -Constructor parameters: - -- ``image``: Container image for the sandbox. Default ``"python:3.12-slim"``. -- ``memory``: Memory limit in binary units. ``sbx`` enforces a 1 GiB minimum. - Default ``"2g"``. -- ``cpus``: CPUs to allocate. ``None`` (default) uses the ``sbx`` default, which - is every host CPU. -- ``sbx_path``: Path to the ``sbx`` binary. Default ``"sbx"``. -- ``create_timeout``: Seconds allowed for provisioning; a first-run microVM boot - plus an image pull can be slow. Default ``600``. -- ``host_network_policy``: What ``sbx policy`` is set to on this host. - ``"unknown"`` (default) makes ``create`` refuse any spec asking for a network - guarantee this backend cannot make, and since ``block_network`` defaults to - ``True`` that includes a bare ``SandboxSpec()``. Set ``"deny-all"`` after running - ``sbx policy init deny-all``, or ``"allow-all"`` to state that egress is open - and pass ``SandboxSpec(block_network=False)`` to match. - -The ``sbx`` CLI has no way to pass environment variables at creation, so the backend -writes ``SandboxSpec.env`` as ``export`` lines to ``/etc/profile`` inside the -sandbox. Anything in the sandbox can read that file for as long as the sandbox -exists. - -.. _sandbox-backend-differences: - -What differs between the backends ---------------------------------- - -Swapping the backend is one constructor argument, and tool names, spec and prompt -do not change. Four behaviours do, so read them before assuming the same Dag -behaves identically everywhere: - -- **CPU.** ``sbx`` gives a sandbox every host CPU; Modal defaults to a request of - 0.125 of one, so set ``cpu``; OpenSandbox and OpenShell take ``cpu`` as a limit the - server enforces; Boat sizes by ``machine_type``; Islo uses the server default unless - you set ``vcpus``. -- **Egress allowlists.** ``sbx`` enforces ``allow_egress_to`` at the host policy - layer; Modal matches TLS handshake names, which is weaker and has to be opted - into; OpenSandbox enforces it in an egress sidecar, and the backend reads the - enforced policy and the sidecar's mode back rather than trusting the create - request, refusing a sidecar that filters only name resolution (``dns``) rather - than connections (``dns+nft``); OpenShell enforces it in a per-sandbox supervisor - on port 443 only, and reads the effective policy back at create and around every - operation. ``allow_egress_to_cidrs`` is enforced at the address layer on Modal and - refused on ``sbx``, OpenSandbox, OpenShell and Islo; OpenShell's address rules admit - TCP on listed ports only, and it also refuses ``block_network=False``. Islo has no - per-host form and refuses the spec; Boat has no form of egress control at all and - refuses every network restriction. Both refuse rather than provision something - weaker. -- **Command timeouts.** A timeout destroys an ``sbx`` or Islo sandbox and its files; - Modal, Boat and a server-enforced OpenSandbox timeout preserve the sandbox and - files. OpenSandbox destroys it only if the command event stream itself stalls - past the client-side grace period, and Boat only if its own deadline, set past - the one in the guest, ends the call. OpenShell kills the command's session and - keeps the sandbox; if the gateway stops relaying the command, the backend asks it - to delete the sandbox, and only a delete that fails too leaves it for the reaper - described under :ref:`OpenShell `. -- **Symlinks.** ``write_file`` through a symlink follows the link on ``sbx``, Boat - and OpenShell, which write the target and leave the link in place, and replaces - the link with a regular file on Modal and OpenSandbox. -- **Attaching.** A Modal sandbox can be provisioned by one task and used by an - agent in another (:ref:`sandbox-attach`). An ``sbx`` microVM lives on the worker - that created it and cannot be reached from another task, OpenSandbox, Boat and - Islo have no per-sandbox metadata the ownership rules could be kept in, and - OpenShell does not implement attaching yet, so all five refuse ``SandboxSpec.owner`` - and the toolset refuses ``attach_to`` for them. - -.. _sandbox-byo: - -Bringing your own backend -------------------------- - -Any vendor that can create a sandbox, run a command in it and destroy it can plug -in. Subclass :class:`~airflow.providers.common.ai.sandbox.SandboxBackend` in your -own package and pass an instance to ``SandboxToolset``. - -**Three methods are required**: ``create``, ``run_command`` and ``destroy``. The -file operations ship as defaults implemented over ``run_command``, because -reading, writing, listing and exporting a file are all expressible as shell -commands. The default ``export_file``, behind ``SandboxToolset(exports=...)``, -copies a file in 4 MiB slices, one command each, and needs ``stat``, ``tail``, -``head`` and ``base64`` in the guest. It relies on ``run_command`` returning each -slice's output intact, or setting ``stdout_truncated`` when it could not. Override -it when the vendor can stream a download, as the ``sbx``, OpenSandbox and Islo -backends do. Override the others only when the vendor has a native file API: - -.. code-block:: python - - from airflow.providers.common.ai.sandbox import ( - SandboxBackend, - SandboxExecResult, - SandboxSpec, - ) - - - class AcmeSandboxBackend(SandboxBackend): - name = "acme" - - def create(self, *, spec: SandboxSpec | None = None) -> str: - return acme_sdk.create_sandbox().id - - def run_command(self, sandbox, command, *, timeout, max_output_bytes): - r = acme_sdk.exec(sandbox, command, timeout=timeout) - return SandboxExecResult(exit_code=r.exit_code, stdout=r.stdout, stderr=r.stderr) - - def destroy(self, sandbox) -> None: - acme_sdk.delete_sandbox(sandbox) - - # Optional: inherited from SandboxBackend unless the vendor has - # something better than shelling out. - def read_file(self, sandbox, path, *, max_bytes) -> bytes: - return acme_sdk.download(sandbox, path, limit=max_bytes) - -Four rules for an implementation: - -- Constructors run at Dag-parse time, so resolve credentials lazily, on first use. -- ``destroy`` must be idempotent; destroying an already-gone sandbox is not an error. -- Raise ``SandboxTerminalError`` when retrying cannot help and ``SandboxError`` - when it might. The first fails the task for Airflow to retry; the second - becomes a bounded prompt back to the model. -- If you cannot enforce something the ``SandboxSpec`` asks for, **raise**. Never - provision a weaker sandbox than the Dag author asked for. - -**If your sandboxes can be found again from another process**, subclass -:class:`~airflow.providers.common.ai.sandbox.AttachableSandboxBackend` instead, -and a ``@task`` can provision a sandbox for an agent task to attach to -(:ref:`sandbox-attach`). It adds two methods, ``read_tags`` and ``write_tags``, -over whatever key-value metadata the vendor keeps on a sandbox, and the ownership -rules are written once on the base class on top of them. Three things the base -class relies on: ``read_tags`` raises ``SandboxTerminalError`` for a sandbox that -does not exist or has ended; ``write_tags`` replaces the whole set, because -releasing a claim is a rewrite without the holder key; and ``create`` stamps -``SandboxSpec.owner`` under ``OWNER_TAG``, the sandbox's end time as Unix seconds -under ``EXPIRES_AT_TAG``, and the network policy under ``NETWORK_TAG`` using -``encode_network_policy(spec)``, all importable from -``airflow.providers.common.ai.sandbox.base``. If the vendor lets a caller of your -backend set metadata too, make your reserved keys overwrite theirs. Stamping the -working directory under ``WORKDIR_TAG`` is optional; without it the attaching -backend asks the sandbox. The toolset shortens ``run_command`` to the remaining -lifetime itself; a backend clamps only if its own file operations need it. diff --git a/uv.lock b/uv.lock index 90fb02ac582c..29a0c0096586 100644 --- a/uv.lock +++ b/uv.lock @@ -65,10 +65,14 @@ apache-airflow-providers-apache-drill = false apache-airflow-providers-apache-druid = false apache-airflow-providers-apache-flink = false <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 87c4d1f683 (Apply Markdown example links during doctree resolution) apache-airflow-providers-apache-hdfs = false apache-airflow-providers-apache-hive = false apache-airflow-providers-apache-iceberg = false apache-airflow-providers-apache-impala = false +<<<<<<< HEAD apache-airflow-providers-apache-kafka = false apache-airflow-providers-apache-kylin = false apache-airflow-providers-apache-livy = false @@ -141,6 +145,8 @@ apache-airflow-core = false apache-airflow-providers-hashicorp = false apache-airflow-providers-pagerduty = false apache-airflow-providers-datadog = false +======= +>>>>>>> 87c4d1f683 (Apply Markdown example links during doctree resolution) apache-airflow-providers-apache-kafka = false apache-airflow-providers-apache-kylin = false apache-airflow-providers-apache-livy = false @@ -182,6 +188,7 @@ apache-airflow-providers-google = false apache-airflow-providers-grpc = false apache-airflow-providers-hashicorp = false apache-airflow-providers-http = false +apache-airflow-providers-huggingface = false apache-airflow-providers-ibm-db2 = false apache-airflow-providers-ibm-mq = false apache-airflow-providers-imap = false @@ -252,7 +259,6 @@ apache-airflow-shared-template-rendering = false apache-airflow-shared-timezones = false apache-airflow-task-sdk = false apache-airflow-task-sdk-integration-tests = false -certifi = "2026-10-21T00:00:00Z" google-cloud-aiplatform = "2026-08-13T00:00:00Z" pip = false pypdf = "2026-10-29T00:00:00Z" @@ -23225,7 +23231,7 @@ version = "2.60.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "click" }, - { name = "filelock", version = "3.32.7", source = { registry = "https://pypi.org/simple" } }, + { name = "filelock" }, { name = "jsonschema" }, { name = "msgpack" }, { name = "packaging" }, @@ -24464,7 +24470,7 @@ dependencies = [ { name = "certifi" }, { name = "charset-normalizer" }, { name = "cryptography" }, - { name = "filelock", version = "3.32.7", source = { registry = "https://pypi.org/simple" } }, + { name = "filelock" }, { name = "idna" }, { name = "packaging" }, { name = "platformdirs" }, @@ -24606,12 +24612,16 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ +<<<<<<< HEAD <<<<<<< HEAD { name = "snowflake-connector-python", version = "4.8.1", source = { registry = "https://pypi.org/simple" } }, { name = "sqlalchemy", version = "2.0.57", source = { registry = "https://pypi.org/simple" } }, >>>>>>> fc119c7bdf (Add tests and Markdown redirect coverage for LLM docs) ======= { name = "snowflake-connector-python", version = "4.8.0", source = { registry = "https://pypi.org/simple" } }, +======= + { name = "snowflake-connector-python", version = "4.8.1", source = { registry = "https://pypi.org/simple" } }, +>>>>>>> 87c4d1f683 (Apply Markdown example links during doctree resolution) { name = "sqlalchemy" }, >>>>>>> 8c19ab81a5 (Improve LLM documentation build diagnostics and tests) ] @@ -24933,7 +24943,8 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "markdown-it-py" }, { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, - { name = "sphinx", version = "9.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, + { name = "sphinx", version = "9.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.12.*'" }, + { name = "sphinx", version = "9.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" }, { name = "sphinx-markdown-builder" }, ] sdist = { url = "https://files.pythonhosted.org/packages/9b/2b/2529cb0b1acb85489167904649387ea7b17e3172ac3286fc0c8af2887bc5/sphinx_llm-1.1.0.tar.gz", hash = "sha256:5f3b41c0d7888c75a6fe9f92b1a965c50ee233eaf38673c0ef3501072599c617", size = 408770, upload-time = "2026-09-21T10:15:26.81Z" } @@ -24948,7 +24959,8 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "docutils" }, { name = "sphinx", version = "9.0.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" }, - { name = "sphinx", version = "9.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" }, + { name = "sphinx", version = "9.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.12.*'" }, + { name = "sphinx", version = "9.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" }, { name = "tabulate" }, ] sdist = { url = "https://files.pythonhosted.org/packages/ad/13/102d7134743120db25e636ffb57a30818e95a416583dca83aadac9c5dd87/sphinx_markdown_builder-0.6.11.tar.gz", hash = "sha256:ba3bf33e0e42ff30ae686ac73957a95e6d045790dcfbaca012dd8ae01794e577", size = 24020, upload-time = "2026-08-16T06:51:38.158Z" } From 09ecf22dc62dad3c641f5312ce5c075d94573b38 Mon Sep 17 00:00:00 2001 From: Sameer Mesiah Date: Sat, 28 Nov 2026 19:09:18 +0000 Subject: [PATCH 5/6] Normalize Markdown typography when reusing HTML doctrees Convert smart punctuation in Markdown prose while preserving literals and code blocks. Add build coverage for typography with shared doctrees. Restrict spell checking to HTML builds and document why ExampleHeader must be imported by its bare module name. --- .../src/sphinx_exts/airflow_llms_txt.py | 14 +++ .../src/sphinx_exts/airflow_spelling.py | 2 +- .../unit/sphinx_exts/test_airflow_llms_txt.py | 18 ++++ uv.lock | 88 ------------------- 4 files changed, 33 insertions(+), 89 deletions(-) diff --git a/devel-common/src/sphinx_exts/airflow_llms_txt.py b/devel-common/src/sphinx_exts/airflow_llms_txt.py index 1b2d27e21f40..1d486de77775 100644 --- a/devel-common/src/sphinx_exts/airflow_llms_txt.py +++ b/devel-common/src/sphinx_exts/airflow_llms_txt.py @@ -231,6 +231,7 @@ def _is_markdown_build(app: Sphinx) -> bool: def _remember_example_sources(app: Sphinx, doctree: nodes.document) -> None: """Preserve example filenames before exampleinclude replaces its headers.""" + # Import by the bare name used by conf.py to preserve ExampleHeader's class identity. from exampleinclude import ExampleHeader for header in doctree.findall(ExampleHeader): @@ -272,6 +273,19 @@ def _clean_markdown_doctree(app: Sphinx, doctree: nodes.document, docname: str) if not _is_markdown_build(app): return + + # Shared HTML doctrees already contain smart quotes; normalize prose at output time. + for text in list(doctree.findall(nodes.Text)): + if any( + isinstance(ancestor, (nodes.literal, nodes.math, nodes.FixedTextElement)) + for ancestor in _ancestors(text) + ): + continue + + normalized = text.astext().translate(_TYPOGRAPHY) + if normalized != text.astext(): + text.parent.replace(text, nodes.Text(normalized)) + site_root = urljoin(app.config.llms_txt_site_url, "/") release_url = app.config.llms_txt_release_source_url source_url = app.config.llms_txt_source_url diff --git a/devel-common/src/sphinx_exts/airflow_spelling.py b/devel-common/src/sphinx_exts/airflow_spelling.py index 4a8360649045..aceafc097d54 100644 --- a/devel-common/src/sphinx_exts/airflow_spelling.py +++ b/devel-common/src/sphinx_exts/airflow_spelling.py @@ -175,7 +175,7 @@ def _describe(node: nodes.Text, text: str, word: str, offset: int) -> dict[str, def _start(app: Sphinx) -> None: - if app.config.airflow_spelling_output: + if app.builder.name == "html" and app.config.airflow_spelling_output: setattr(app, _RUN_ATTRIBUTE, _SpellingRun(app)) diff --git a/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py index ff85181bd6a9..bbe6bd12abe8 100644 --- a/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py +++ b/devel-common/tests/unit/sphinx_exts/test_airflow_llms_txt.py @@ -563,6 +563,7 @@ def rendered_docs(tmp_path): "llms_txt_enabled = True\n" 'llms_txt_suffix_mode = "append"\n' "llms_txt_build_parallel = False\n" + 'smartquotes_excludes = {"builders": ["man", "text", "spelling", "llms-markdown"]}\n' f"exampleinclude_sourceroot = {str(source)!r}\n" f"llms_txt_repo_root = {str(source)!r}\n" 'llms_txt_source_url = "https://github.com/apache/airflow/blob/test-ref/"\n', @@ -614,6 +615,14 @@ def rendered_docs(tmp_path): child +Don't "quote" this -- dash. + +Keep ``Don\u2019t \u201cchange\u201d this`` unchanged. + +.. code-block:: text + + Don\u2019t \u201cchange\u201d this \u2013 dash. + Example ------- @@ -707,3 +716,12 @@ def test_rendered_same_page_link(rendered_docs): rendered_markdown = rendered_docs.markdown assert "[Setup](#setup-section)" in rendered_markdown + + +def test_rendered_typography(rendered_docs): + """Normalize Markdown prose while preserving literal content and HTML typography.""" + assert 'Don\'t "quote" this - dash.' in rendered_docs.markdown + assert "Don\u2019t \u201cquote\u201d this \u2013 dash." in rendered_docs.html + + assert "`Don\u2019t \u201cchange\u201d this`" in rendered_docs.markdown + assert "Don\u2019t \u201cchange\u201d this \u2013 dash." in rendered_docs.markdown diff --git a/uv.lock b/uv.lock index 29a0c0096586..4324e7479a1b 100644 --- a/uv.lock +++ b/uv.lock @@ -64,15 +64,10 @@ apache-airflow-providers-apache-cassandra = false apache-airflow-providers-apache-drill = false apache-airflow-providers-apache-druid = false apache-airflow-providers-apache-flink = false -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> 87c4d1f683 (Apply Markdown example links during doctree resolution) apache-airflow-providers-apache-hdfs = false apache-airflow-providers-apache-hive = false apache-airflow-providers-apache-iceberg = false apache-airflow-providers-apache-impala = false -<<<<<<< HEAD apache-airflow-providers-apache-kafka = false apache-airflow-providers-apache-kylin = false apache-airflow-providers-apache-livy = false @@ -88,79 +83,6 @@ apache-airflow-providers-atlassian-jira = false apache-airflow-providers-celery = false apache-airflow-providers-clickhousedb = false apache-airflow-providers-cloudant = false -======= ->>>>>>> fc119c7bdf (Add tests and Markdown redirect coverage for LLM docs) -apache-airflow-providers-cncf-kubernetes = false -apache-airflow-providers-cohere = false -apache-airflow-providers-common-ai = false -apache-airflow-providers-common-compat = false -apache-airflow-providers-common-dataquality = false -apache-airflow-providers-common-io = false -apache-airflow-providers-common-messaging = false -apache-airflow-providers-common-sql = false -apache-airflow-providers-databricks = false -apache-airflow-providers-datadog = false -apache-airflow-providers-dbt-cloud = false -apache-airflow-providers-dingding = false -apache-airflow-providers-discord = false -apache-airflow-providers-docker = false -apache-airflow-providers-duckdb = false -apache-airflow-providers-edge3 = false -apache-airflow-providers-elasticsearch = false -apache-airflow-providers-exasol = false -apache-airflow-providers-fab = false -apache-airflow-providers-facebook = false -apache-airflow-providers-ftp = false -apache-airflow-providers-git = false -apache-airflow-providers-github = false -apache-airflow-providers-google = false -apache-airflow-providers-grpc = false -apache-airflow-providers-hashicorp = false -apache-airflow-providers-http = false -apache-airflow-providers-huggingface = false -apache-airflow-providers-ibm-db2 = false -apache-airflow-providers-ibm-mq = false -apache-airflow-providers-imap = false -apache-airflow-providers-influxdb = false -apache-airflow-providers-informatica = false -apache-airflow-providers-jdbc = false -apache-airflow-providers-jenkins = false -apache-airflow-providers-keycloak = false -apache-airflow-providers-microsoft-azure = false -apache-airflow-providers-microsoft-mssql = false -apache-airflow-providers-microsoft-psrp = false -apache-airflow-providers-microsoft-winrm = false -apache-airflow-providers-modal = false -apache-airflow-providers-mongo = false -apache-airflow-providers-mysql = false -apache-airflow-providers-neo4j = false -apache-airflow-providers-odbc = false -apache-airflow-providers-openai = false -apache-airflow-providers-openfaas = false -apache-airflow-providers-openlineage = false -apache-airflow-providers-opensearch = false -apache-airflow-providers-opsgenie = false -apache-airflow-providers-apache-livy = false -apache-airflow-core = false -apache-airflow-providers-hashicorp = false -apache-airflow-providers-pagerduty = false -apache-airflow-providers-datadog = false -======= ->>>>>>> 87c4d1f683 (Apply Markdown example links during doctree resolution) -apache-airflow-providers-apache-kafka = false -apache-airflow-providers-apache-kylin = false -apache-airflow-providers-apache-livy = false -apache-airflow-providers-apache-pig = false -apache-airflow-providers-apache-pinot = false -apache-airflow-providers-apache-spark = false -apache-airflow-providers-apache-tinkerpop = false -apache-airflow-providers-apprise = false -apache-airflow-providers-arangodb = false -apache-airflow-providers-asana = false -apache-airflow-providers-atlassian-jira = false -apache-airflow-providers-celery = false -apache-airflow-providers-clickhousedb = false -apache-airflow-providers-cloudant = false apache-airflow-providers-cncf-kubernetes = false apache-airflow-providers-cohere = false apache-airflow-providers-common-ai = false @@ -24612,18 +24534,8 @@ resolution-markers = [ "(python_full_version < '3.11.3' and platform_machine != 'arm64' and sys_platform == 'darwin') or (python_full_version < '3.11.3' and sys_platform != 'darwin' and sys_platform != 'emscripten' and sys_platform != 'win32')", ] dependencies = [ -<<<<<<< HEAD -<<<<<<< HEAD { name = "snowflake-connector-python", version = "4.8.1", source = { registry = "https://pypi.org/simple" } }, { name = "sqlalchemy", version = "2.0.57", source = { registry = "https://pypi.org/simple" } }, ->>>>>>> fc119c7bdf (Add tests and Markdown redirect coverage for LLM docs) -======= - { name = "snowflake-connector-python", version = "4.8.0", source = { registry = "https://pypi.org/simple" } }, -======= - { name = "snowflake-connector-python", version = "4.8.1", source = { registry = "https://pypi.org/simple" } }, ->>>>>>> 87c4d1f683 (Apply Markdown example links during doctree resolution) - { name = "sqlalchemy" }, ->>>>>>> 8c19ab81a5 (Improve LLM documentation build diagnostics and tests) ] sdist = { url = "https://files.pythonhosted.org/packages/f2/0d/94458e9231da61efe076ff8b9d808da9c8e3be39d99eaff8e6fe85f7295e/snowflake_sqlalchemy-1.11.1.tar.gz", hash = "sha256:942b203de0404b79550c4098ca851aee2b0b22f695426b073e58d71772e38d51", size = 252184, upload-time = "2026-09-04T06:51:26.892Z" } wheels = [ From 92372929d02b2379db9e431b106027a9c5019123 Mon Sep 17 00:00:00 2001 From: Sameer Mesiah Date: Tue, 1 Dec 2026 19:01:39 +0000 Subject: [PATCH 6/6] Add regression coverage for HTML-only spell checking Verify that Markdown builds do not initialize a spelling run even when a spelling output path is configured. Resolve leftover merge conflicts in the durable execution documentation and align its content with the current behaviour. --- .../unit/sphinx_exts/test_airflow_spelling.py | 14 ++++++++++++++ providers/common/ai/docs/durable_execution.rst | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/devel-common/tests/unit/sphinx_exts/test_airflow_spelling.py b/devel-common/tests/unit/sphinx_exts/test_airflow_spelling.py index 34f6644df866..d6cdca0b16c7 100644 --- a/devel-common/tests/unit/sphinx_exts/test_airflow_spelling.py +++ b/devel-common/tests/unit/sphinx_exts/test_airflow_spelling.py @@ -132,6 +132,20 @@ def test_undoing_smartquotes_gives_back_the_text_as_typed(typed): assert smartyPants(typed, "qDe", "en").translate(airflow_spelling._UNSMARTEN) == typed +def test_start_skips_markdown_builder(tmp_path, dictionary_factory): + """Do not start spell checking during the Markdown build.""" + app = SimpleNamespace( + builder=SimpleNamespace(name="llms-markdown"), + config=_config(airflow_spelling_output=str(tmp_path / "spelling.json")), + srcdir=tmp_path, + ) + + airflow_spelling._start(app) + + assert not hasattr(app, airflow_spelling._RUN_ATTRIBUTE) + dictionary_factory.assert_not_called() + + def _env(docname_path: str = "index.rst", good_words=None): env = mock.create_autospec(BuildEnvironment, instance=True) env.doc2path.return_value = Path(docname_path) diff --git a/providers/common/ai/docs/durable_execution.rst b/providers/common/ai/docs/durable_execution.rst index 5196236398d7..077987486707 100644 --- a/providers/common/ai/docs/durable_execution.rst +++ b/providers/common/ai/docs/durable_execution.rst @@ -27,7 +27,6 @@ twice. With durable execution, each step the agent completes is recorded in a jo kept for the task instance, and the retry replays the recorded steps instead of running them again. Only the steps the failed attempt never finished run live. -<<<<<<< HEAD On Airflow 3.3 and later, ``AgentOperator`` and ``@task.agent`` do this by default for every task that can retry. A task that cannot run again (no retries, and from Airflow 3.4 no ``retry_policy`` either) has nothing to replay, so it runs as before. To decide @@ -35,19 +34,6 @@ no ``retry_policy`` either) has nothing to replay, so it runs as before. To deci ``LLMBatchOperator`` re-attaches to its running batch instead (:ref:`llm-batch-reattach`). To resume a Strands Agents agent on a retry, see :ref:`howto/frameworks:strands-durable`; for an OpenAI Agents SDK agent, see :ref:`howto/frameworks:openai-agents-durable`. -======= -Durable execution only helps a task that has retries. To decide *whether* a failure is -worth retrying, see :doc:`retry_policies`; a retried ``LLMBatchOperator`` re-attaches to -its running batch instead (:ref:`llm-batch-reattach`). To resume a Strands Agents agent on a -retry, see :ref:`howto/frameworks:strands-durable`; for an OpenAI Agents SDK agent, see -:ref:`howto/frameworks:openai-agents-durable`. - -.. meta:: - :description: Set durable=True on an agent task so that a retry replays the model and tool calls that already finished instead of running and paying for them again. - -Turn it on ----------- ->>>>>>> 8c19ab81a5 (Improve LLM documentation build diagnostics and tests) When it is on -------------