Skip to content

feat(fetch-docs): add an opt-in renderer fallback and an expect marker - #18346

Merged
kyle-sexton merged 5 commits into
mainfrom
feat/fetch-docs-render-fallback
Nov 23, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
feat/fetch-docs-render-fallback

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

No related issue: Phase 6 of the owner-approved vendor-routing plan (PR-B of four).

Summary

The shared docs fetcher (lib/fetch-docs.sh, copied into 14 plugins) gains two opt-in flags for
its generic profile. With neither flag, behavior is unchanged.

  • --expect <marker>: a fetched page without the marker is recorded unread with reason
    no-content. This catches pages that need a browser to render.
  • --render-fallback: renders a page left unread for fetch-failed, http-403, http-429,
    unexpected-content-type or no-content through the Firecrawl CLI, and stores the result in
    the shared cache as format rendered (text/markdown). The next run inside the window is
    served from the cache with no new render. It runs only when the docs-cache renderer master
    setting is firecrawl; the shipped default is none.

Fix

Security, because the renderer fetches untrusted URLs through a third party:

  • A 404, a 410 or an off-site landing is never rendered.
  • The renderer's reported final URL passes the same landed check as a plain fetch, and a render
    that reports no final URL is refused.
  • --public-only pins the host before rendering.
  • The URL is passed as an argument, never a shell string. The CLI runs from a temporary working
    directory that is removed afterwards.
  • Under --render-fallback, a 403 or 429 with a cached copy serves that copy stale when
    rendering also fails.

Each of the 14 plugins with a scripts/fetch-docs.sh copy declares firecrawl as an optional
prerequisite with a degrade line. The copies are regenerated by scripts/sync-shared-copies.sh.

Size: fetch-docs.sh crossed the repository's 1000-line reference (981 to 1147 non-blank lines).
The generic profile (generic_slug through get_generic, renderer included) moves into
lib/fetch-docs-generic.sh, which fetch-docs.sh sources from beside itself, the way it already
sources docs-cache.sh. fetch-docs.sh is now 844 lines. The new file's 14 plugin copies are
registered in scripts/shared-copies.txt and scripts/cross-plugin-source-registry.txt. It is
also added to collect-base-activity's copy list, which copies the fetcher's siblings by name.
That action and the files it copies both come from the base, so this PR's own run is unaffected.

Verification

  • bash lib/fetch-docs.test.sh: all 281 assertions passed. A stub renderer on PATH covers:
    • without the flag, a 403 stays unread;
    • with the flag, a 403 renders, and a second run is served from the cache;
    • a JS shell without the marker is no-content;
    • 404, 410 and off-site redirects are never rendered;
    • an off-site, off-path or missing final URL from the renderer stays unread;
    • the public-only host check runs before rendering;
    • the stale fallback.
  • bash lib/docs-cache.test.sh: all 290 assertions passed (the renderer setting).
  • bash scripts/sync-shared-copies.sh --check: all 1051 registered copies match.

Related

  • Built by Antigravity from the Phase 6 brief, then reviewed line by line, tested and committed by
    Claude.
  • Consumers: /multi-agent:route vendors (PR-C1
    #18345) and the registry
    recheck in PR-C2 pass --render-fallback. No other caller does.

🤖 Generated with Claude Code

https://claude.ai/code/session_015XWwmfo1FXD2G3F4XBaDn3

kyle-sexton and others added 3 commits November 22, 2026 23:46
The shared fetcher gains two generic-profile flags. `--expect <marker>`
records a page without the marker as unread `no-content`, which catches
pages that need a browser to render. `--render-fallback` renders a page
left unread for fetch-failed, http-403, http-429, unexpected-content-type
or no-content through the Firecrawl CLI, and stores it in the shared cache
as format `rendered`. It runs only when the docs-cache `renderer` master
setting is `firecrawl` (default `none`). A 404, a 410 or an off-site landing
is never rendered. The renderer's final URL passes the same landed check
as a plain fetch, and --public-only pins the host first.

Regenerates the 14 plugins' copies and declares firecrawl as an optional
prerequisite in each.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmfo1FXD2G3F4XBaDn3
…c.sh

fetch-docs.sh crossed the repository's 1000-line size reference (981 to
1147 non-blank lines). The generic profile (generic_slug through
get_generic, renderer fallback included) moves unchanged into
lib/fetch-docs-generic.sh, which fetch-docs.sh sources from beside itself
as it sources docs-cache.sh. Registers its 14 plugin copies and adds it
to the collect-base-activity copy list, which copies the fetcher's
siblings by name.

Function-header comments in the moved block are dropped under the
repository comment lint. Reasons they held: resolve_python takes the first
of python3 and python whose probe prints 3, because a Windows Store stub or
a Python 2 fails it; login_wall treats an x.com or twitter.com page that
links to redirect_after_login and holds fewer than 200 words outside its
links as the logged-out shell; and in generic_read the page's own request
decides identity, so a failure or a landing elsewhere ends the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmfo1FXD2G3F4XBaDn3
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 23, 2026 06:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T06:40:00.911699Z 396149c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed a240cb774c9ee290bb55b41068703f8a240d171b: read 16 of 16 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #18346, incremental (50db1a0..a240cb7)

I found no security issues in this push. This lane already reviewed an earlier head, so this review reports blocking findings only.

Scope. I read every hunk of the 16 files in .claude-lane/incremental.diff:

  • lib/fetch-docs-generic.sh and its 14 plugin copies under plugins/*/scripts/, which all carry the same one-line hunk;
  • lib/fetch-docs.test.sh.

None of these files matches a trusted-path glob. The push touches no trust control, plugin manifest or instruction text.

What changed and why it is safe

  • render_fallback now takes the final URL only from Firecrawl's metadata.url. It no longer falls back to metadata.sourceURL (lib/fetch-docs-generic.sh#L146).
    • This makes the fetcher stricter. sourceURL is the URL the fetcher asked for, not the page it ended up on. Under the old fallback, a render with no final URL compared the requested URL against itself, so landed always answered same and the off-origin and off-path redirect checks never caught anything.
    • When the render reports no url, r_url is now empty and the function fails closed: it removes the render directory and returns 1 (lib/fetch-docs-generic.sh#L158-L161).
    • The control-character filter on the URL and the landed checks are unchanged.
  • The test edit runs nothing new. fetch-docs.test.sh splits the 429 render case in two: one render with a wrapped JSON body, and one that reports only sourceURL, which must now stay unread. It only touches fixture files in the test's own temporary directory.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed a240cb774c9ee290bb55b41068703f8a240d171b: read 16 of 16 changed file(s); 0 finding(s), 0 as inline comments.

Code review (incremental, blocking only): 50db1a0 → a240cb7

No blocking findings in this push. This lane already reviewed an earlier head (blocking only: yes), so I looked only for blocking findings.

What changed

  • In render_fallback, the final-URL field now reads only metadata.url and no longer falls back to metadata.sourceURL. The same one-line change is at lib/fetch-docs-generic.sh:146 and at line 148 in each of the 14 plugin copies.
  • sourceURL is the URL that was requested, not where the page landed. Falling back to it let the landed origin/path check compare the request URL with itself, so a redirected render could pass that check. With the fallback gone, a render that reports no url leaves r_url empty, and the existing [[ -z "$r_url" ]] guard at lib/fetch-docs-generic.sh:158 refuses it before landed runs.
  • This matches the PR description: "a render that reports no final URL is refused" and "an off-site, off-path or missing final URL from the renderer stays unread".
  • lib/fetch-docs.test.sh:1279-1283 adds a render case where the firecrawl shim emits only sourceURL (the shim at lines 1195-1197). It asserts unread. Under the old code that case would have come back read, so the test fails if the fallback is put back. The existing 429 case no longer touches page.sourceurl, so it now runs the shim's default {url, sourceURL} metadata.
  • No other file in the repository mentions sourceURL outside the test shim, so no docs went stale.

Context

  • Closing issue: none, so no acceptance criteria were checked.
  • Security is out of scope: this repository runs a separate security lane.
  • Loosened checks: none in this push. The test adds a case and relaxes no assertion. Loosened checks would be marked: fail (no settings line in prompt; default); patterns: 0. No loosened_check_decision_record: line was given, so the citation requirement was not checked.
  • Spend: none added by this push.
  • Nothing was run: I traced the change by reading the code, and the test results are not independently confirmed.

Verifier dropped 0 of 0 candidates.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 396149ccf9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/fetch-docs-generic.sh Resolved
…ction test

A stale cached copy served after a failed fetch skipped --expect, so a
cached JS shell came back read. get_generic now runs the marker check
after every generic read, stale serves included; new test case.

collect-base-activity.test.mjs builds a fixture base with the fetcher's
siblings; it now includes fetch-docs-generic.sh, which the action copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmfo1FXD2G3F4XBaDn3
@github-actions

Copy link
Copy Markdown
Contributor

The pr-verify verifier failed head 50db1a0c8e004bd4fbb9f8a5998b3212981453c8. What it wrote, as data:

What it wrote (96 lines)
Summary: Chunk 2 of 2, fail: Spec: PR #18346's own title and body (spec_kind pull-request, no linked
  issue). Chunk 2 covers the generated copies, and they match the canonical
  lib/fetch-docs-generic.sh, which I read from chunk-1/part-002 because these copies say they are
  generated from it. One stated security guarantee is not met, so this chunk fails.

What chunk 2 delivers in full:
- The regenerated fetch-docs.sh copy for knowledge, and the fetch-docs.sh, docs-cache.sh and new
  fetch-docs-generic.sh copies for multi-agent, performance, planning, playbooks, plugin-quality and
  session-flow.
- In fetch-docs.sh: argument parsing for `--expect` and `--render-fallback`, both refused on indexed
  profiles, and fetch-docs-generic.sh is sourced from beside the script.
- The docs-cache `renderer` key: validated as none or firecrawl, default none.
- settle_unread serves a 403 or 429 stale only when `--render-fallback` is passed and the renderer
  is firecrawl, so behavior without the flags is unchanged.
- An optional `firecrawl` prerequisite with a `degrade` line in each of those six plugins'
  prerequisites.json.
- All 14 copies of fetch-docs-generic.sh registered in scripts/shared-copies.txt, plus the canonical
  and the copy cluster in scripts/cross-plugin-source-registry.txt.

Delivered in part:
- The renderer security list. A 404 or 410 is never rendered, an off-origin or off-path final URL is
  refused, the `--public-only` host pin runs before rendering, the URL is passed as an argument, and
  the CLI runs in a temporary directory that is removed afterwards. But "a render that reports no
  final URL is refused" does not hold: when the renderer's output has no `metadata.url`, the code
  falls back to `metadata.sourceURL` (the URL that was asked for), so the landed check passes on
  nothing.

Not in chunk 2 (in chunk 1):
- The canonical lib files, the tests, the collect-base-activity change, and the other seven plugins'
  copies and prerequisites.

CI on the head is all green: every Test Bash job, Lin
Chunk 1 of 2, pass-notes: The spec is PR #18346's own body (source `pull-request`; no linked issue,
  no person checks, no credited siblings). I read all 20 parts of chunk 1 whole, plus the manifest.
  Nothing in my parts blocks.

Items my parts deliver in full:
- **`--expect <marker>`:** `check_expect` in `lib/fetch-docs-generic.sh` makes a page without the
  marker unread `no-content`. It runs on fresh-cache, fixture, 304, stale and fetched paths. The
  flag is fatal with an empty value and on indexed profiles.
- **`--render-fallback`:** renders only for fetch-failed, http-403, http-429,
  unexpected-content-type and no-content. It runs only when `renderer` is `firecrawl`, and the
  shipped default is `none`: `lib/docs-cache.sh` adds the `renderer` key, validated against
  `^(none|firecrawl)$`, with tests in `lib/docs-cache.test.sh`. The result is stored as format
  `rendered` with content type `text/markdown`, and the next run inside the window is served from
  the cache.
- **Security items:**
  - 404, 410 and off-origin or off-path landings are never rendered, whether the plain fetch or the
  renderer reports them.
  - A renderer final URL that is off-site, off-path or missing is refused.
  - `--public-only` pins the host before rendering.
  - The URL is passed as an argument, and the CLI runs in a temporary directory under `$WORK` that
  is removed afterwards.
  - The 403/429 stale fallback in `settle_unread` applies only with the flag and `firecrawl`.
- **Size split:** the generic profile moves into `lib/fetch-docs-generic.sh`, which
  `lib/fetch-docs.sh` sources from beside itself and dies if it is missing.
- **collect-base-activity:** its copy list and its test now include `fetch-docs-generic.sh`.
- **Tests:** `lib/fetch-docs.test.sh` covers every bullet in the body's Verification list using a
  stub CLI, including the stale-copy-without-marker case added after review.

Items my parts deliver only in part:
- **Plugin copies:** the regenerated `docs-cache.sh`, `fetch-docs-generic.sh`
- lib/fetch-docs-generic.sh:146 (and the generated copies, e.g.
  plugins/multi-agent/scripts/fetch-docs-generic.sh:148,
  plugins/performance/scripts/fetch-docs-generic.sh:148,
  plugins/planning/scripts/fetch-docs-generic.sh:148,
  plugins/playbooks/scripts/fetch-docs-generic.sh:148,
  plugins/plugin-quality/scripts/fetch-docs-generic.sh:148,
  plugins/session-flow/scripts/fetch-docs-generic.sh:148): render_fallback takes `$m.sourceURL` as
  the landed URL when `$m.url` is missing. sourceURL is the URL that was asked for, not where the
  page ended up, so `landed` always returns `same`, and an off-site redirect followed by the
  renderer would be cached under this URL. That breaks the stated rule that a render reporting no
  final URL is refused. Use only `metadata.url` (refuse when it is absent), add a fetch-docs.test.sh
  case where the stub reports only sourceURL and the result stays unread, then rerun
  scripts/sync-shared-copies.sh.
- lib/docs-cache.sh (copies such as plugins/multi-agent/scripts/docs-cache.sh:~115): the PR deletes
  the comment describing each config key's validation (cache_dir non-empty, cache_enabled boolean,
  max_page_bytes positive, leading zeros refused) when adding `renderer`. Restore it and add that
  renderer is none or firecrawl, rather than dropping documentation of rules that are still
  enforced. Likewise restore the settle_unread doc comment in lib/fetch-docs.sh and the per-function
  header comments that were dropped when the generic profile moved into lib/fetch-docs-generic.sh,
  updated for the 403/429 and render behavior.
- lib/fetch-docs-generic.sh: the move dropped the doc comments on every relocated function
  (generic_slug, resolve_python, html_title, bundle_link, markdown_channel, convert, generic_read,
  login_wall, get_generic), and the new check_expect and render_fallback have none. Worth restoring
  short headers.
- lib/fetch-docs.sh:504: the settle_unread header comment was deleted in the same change that
  widened its stale serving to http-403/http-429 (only under --render-fallback with renderer
  firecrawl). The function now has no description of when it serves stale or quarantines.
- lib/docs-cache.sh:113: three lines describing each config key's value type and the leading-zero
  refusal were removed. The header's config table was not given a row for the new renderer key or
  DOCS_CACHE_RENDERER. Same change in every plugin copy.
- lib/fetch-docs-generic.sh:202: the real `firecrawl scrape <url> --format markdown --json -o
  out.json` call and the JSON shape parsed afterwards are tested only against a stub CLI. Once a
  user opts in with renderer=firecrawl, page URLs go to a third-party service. A person should check
  both against the real CLI before the PR-C consumers depend on it.

This pull request leaves the merge queue, and ci-status holds it out while it carries pr-verify-failed. A pr-verify pass removes the label, at a new commit or at this same head: once a trusted person edits the body, and only trusted people have edited it since the fail, this head is judged again, so a fail on the body or the issues it links needs only the body fixed, no new commit.

@github-actions github-actions Bot added the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 23, 2026
render_fallback fell back to the renderer's metadata.sourceURL when
metadata.url was missing. sourceURL is the URL that was asked for, so the
landed check passed on nothing and an off-site redirect could be cached
under the requested URL. Only metadata.url counts now; with none, the page
stays unread. New test case: a render reporting only sourceURL stays
unread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmfo1FXD2G3F4XBaDn3
@github-actions github-actions Bot removed the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 23, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit a6e52a9 Nov 23, 2026
56 checks passed
@kyle-sexton
kyle-sexton deleted the feat/fetch-docs-render-fallback branch November 23, 2026 08:34
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant