Skip to content

ci: make Lychee validate repository links against the checkout - #3143

Merged
rwgk merged 6 commits into
mainfrom
rwgk/lychee-checkout-aware-links
Oct 20, 2026
Merged

rwgk merged 6 commits into
mainfrom
rwgk/lychee-checkout-aware-links

Conversation

@rwgk

@rwgk rwgk commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Highlights

Let Lychee validate public main source links against the proposed checkout, so a path and its documentation can land in the same PR.

  • Paths and links can land together: files and directories introduced or moved by a PR can pass link checks before they exist on public main.
  • Stable documentation URLs: source files and built documentation retain their intended public URLs. Only Lychee's validation targets change.
  • Immediate local feedback: authored checks cover uncommitted and unpushed paths without remote metadata or discovery requests. Missing targets fail even after an earlier successful check.
  • Retain rendered coverage: generated documentation pages and anchors remain fully checked; public GitHub source links retain their source-view fragment checks.

This builds on #3155 and provides the checkout-aware link handling needed by #3147.

How it works

The helper recognizes only these complete public URL prefixes:

https://github.com/NVIDIA/cuda-python/blob/main/
https://github.com/NVIDIA/cuda-python/tree/main/
Check Validation target Fragment coverage
Authored Markdown and reST Files and directories in the working tree Existing policy: fragments are not checked
Rendered HTML in the public repository GitHub's file or directory view at the actual checked-out commit Source-view fragments remain checked
Rendered HTML in other repositories Files and directories in the working tree Only the remapped source links omit fragments; generated HTML anchors remain fully checked

The public URL convention is explicit. There is no default-branch discovery, cached remote HEAD requirement, or additional public remote to configure.

Scope and tradeoffs

Version tags, explicit commits, maintenance branches, unrelated repositories, and URLs embedded inside other URLs retain their original targets. A future change to the public main URL convention would require an explicit matching-rule update.

Public rendered checks need the tested commit to be available on GitHub. Other checkouts validate source paths locally and defer GitHub-specific source fragments, whose behavior is not fully reproduced by local files. This limitation does not weaken anchor checks within the generated documentation.

For unpublished local commits, the documented fork-identity setting selects local source validation. Set it before the checking build and the rendered hook so generated example links use the same policy.

Rendered source links use the checked-out commit, so their URLs usually differ from those in the nightly cache and require a small number of fresh GitHub requests. Authored source links are checked locally, reducing requests there; established external links continue to benefit from the shared cache.

These rules model the proposed source tree. Maintenance branches need a deliberate policy when their links intentionally refer to a different tree.

Implementation details and suggested review order
  1. Repository-link guide: behavior, coverage boundaries, and local configuration.
  2. Source-link helper: anchored matching and validation targets. Authored checks need no Git metadata. Rendered checks use GITHUB_REPOSITORY in CI, or an explicit lychee.repository Git setting followed by the conventional upstream/origin remotes locally.
  3. Native Lychee wrapper: pass the remapping rules to the existing pinned executable.
  4. Checking build and documentation workflow: select the public checkout's commit, or main for local source validation, when generating example URLs. Explicit checking-build overrides and release-tag behavior remain intact.
  5. Shared link-check action: include the new helper in the cache policy fingerprint.

The wrapper supplies remapping rules to native Lychee without rewriting source files or generated HTML. Public rendered rules preserve paths, queries, and fragments. Local rendered rules omit fragments only for the matched repository source links.

The helper participates in the cache fingerprint, so caches produced under a different mapping policy are not reused. The three-day lifetime, separate authored/rendered caches, and cache publication policy remain unchanged.

Validation

Local validation of this revision:

  • All 259 CI-tool tests and 36 subtests pass, including checking-build cases for public and generic alternate repositories, explicit reference overrides, checkout paths containing spaces, and forwarding remap arguments in authored and rendered wrapper invocations.
  • pre-commit run --all-files passes, including the configured authored Lychee hook and workflow linting.
  • Native Lychee 0.24.2 probes verify encoded paths and queries, local files and directories, and rejection of missing targets despite a cached success for the original URL.
  • Native rendered probes verify that source fragments are omitted only in local-source mode, ordinary HTML anchors remain checked, and public commit remaps preserve fragments.

The current full CI run checks dd3100c23a6991756949142b7dc88c72ff8e84a9. Its first attempt passed 102 jobs, including both formerly queued Windows L4 jobs and the documentation build. Rendered Lychee passed on its first attempt with a cold cache: 13,524 unique links, six remaps, and no errors or timeouts. An unchanged CUDA graph timing test failed after 30 seconds, matching its callback timeout; a targeted retry of that job and the aggregate status check was requested without code changes.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@rwgk rwgk added this to the cuda.bindings next milestone Oct 17, 2026 — with ChatGPT Codex Connector
@copy-pr-bot

copy-pr-bot Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@rwgk rwgk added enhancement Any code-related improvements CI/CD CI/CD infrastructure labels Oct 17, 2026 — with ChatGPT Codex Connector
@rwgk rwgk self-assigned this Oct 17, 2026
@rwgk
rwgk added this pull request to stack #3144 October 17, 2026 00:03
@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch from 280c425 to 672e513 Compare October 17, 2026 00:14
@rwgk

rwgk commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 672e513

@github-actions

Copy link
Copy Markdown
Contributor

@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch from 672e513 to d24e19f Compare October 18, 2026 04:41
@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch from d24e19f to 983ac75 Compare October 18, 2026 05:18
@rwgk rwgk changed the title ci: validate default-branch repository links against the checkout ci: make Lychee validate repository links against the checkout Oct 18, 2026
@rwgk
rwgk marked this pull request as ready for review October 18, 2026 23:33
@rwgk rwgk added the PR review get-together Mark PRs you'd like the team to review at the weekly PR review get-together. label Oct 18, 2026
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuda-python/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 7dcdd7ff-ce94-4559-ab8b-cba484255c33
📥 Commits

Reviewing files that changed from the base of the PR and between 983ac75 and dd3100c.

📒 Files selected for processing: 9
  • .github/actions/lychee-links/action.yml
  • .github/workflows/build-docs.yml
  • ci/README.md
  • ci/tools/build_docs_for_link_check.sh
  • ci/tools/checkout_source_links.py
  • ci/tools/run_lychee.py
  • ci/tools/tests/test_build_docs_for_link_check.py
  • ci/tools/tests/test_checkout_source_links.py
  • ci/tools/tests/test_run_lychee.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Documentation source links now resolve correctly for the checked-out revision, public repository, forks, and other repository copies.
    • Link validation now handles rendered documentation links and URL fragments more reliably.
    • Documentation builds use the appropriate source reference instead of always using the current commit.
  • Documentation

    • Added guidance explaining repository link behavior, source mapping, commit references, fragments, and configuration.
    • Improved cache invalidation so link-check results reflect source-link configuration changes.

The change adds repository-aware source-link remapping for documentation link checks. Lychee uses remapping rules for native and rendered inputs. Documentation build scripts use a resolved source reference when no explicit reference is set, while release builds retain their existing reference behavior.

Changes: Repository Source Link Checks

Layer / File(s) Summary
Resolve source references and remapping rules
ci/tools/checkout_source_links.py, ci/tools/tests/test_checkout_source_links.py
The utility identifies a repository, selects a source reference, and generates remapping rules for authored and rendered links. Tests cover URL matching, repository detection, and validation.
Apply remaps during Lychee checks
ci/tools/run_lychee.py, ci/tools/tests/test_run_lychee.py, .github/actions/lychee-links/action.yml, ci/README.md
Lychee receives remapping arguments for native and rendered inputs. Tests verify the arguments and rendered mode. Cache invalidation and link-check guidance include the source-link utility.
Use resolved references in documentation builds
.github/workflows/build-docs.yml, ci/tools/build_docs_for_link_check.sh, ci/tools/tests/test_build_docs_for_link_check.py, ci/README.md
When no explicit reference is set, non-release documentation builds use the utility’s resolved source reference. Tests cover explicit references and repository-specific defaults. The README describes repository link mapping and reference behavior.

Suggested reviewers: kkraus14

Priority: ⬇️ Low

Change: Feature

Merge Risk: ⚪ Minimal · up to dd310

The previous nightly link-check failure path has been removed. No remaining issue identified here requires a change before merging.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1

🧹 Nitpick comments: 1
ci/tools/run_lychee.py: 1

66-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Exercise nonempty remaps at the subprocess boundary.

The run_lychee.main() tests replace repo_link_remaps with [], so they do not detect a regression that drops remap options before subprocess.run. The helper tests cover remap construction separately, but not this caller wiring. Add nonempty remaps to both authored and rendered tests and assert their exact position in the Lychee command.

Suggested fix
-            patch("run_lychee.repo_link_remaps", return_value=[]),
+            patch("run_lychee.repo_link_remaps", return_value=["--remap", "source=target"]),
...
-        assert command[1:4] == ["--format", "json", "--output"]
-        report = Path(command[4])
+        assert command[1:3] == ["--remap", "source=target"]
+        assert command[3:6] == ["--format", "json", "--output"]
+        report = Path(command[5])
...
-        patch("run_lychee.repo_link_remaps", return_value=[]),
+        patch("run_lychee.repo_link_remaps", return_value=["--remap", "source=target"]),
...
         [
             str(tmp_path / "lychee"),
+            "--remap",
+            "source=target",
             "--files-from",

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuda-python/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 13a83dd1-9c60-4b9d-84a2-a179372b52cb
📥 Commits

Reviewing files that changed from the base of the PR and between d7d7bd8 and 983ac75.

📒 Files selected for processing: 9
  • .github/workflows/build-docs.yml
  • .github/workflows/lychee.yml
  • .github/workflows/pre-commit.yml
  • ci/README.md
  • ci/tools/checkout_link_defaults.py
  • ci/tools/lychee_cache.py
  • ci/tools/run_lychee.py
  • ci/tools/tests/test_checkout_link_defaults.py
  • ci/tools/tests/test_run_lychee.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

Comment thread .github/workflows/lychee.yml Outdated
# BEGIN SYNCED LYCHEE REPOSITORY METADATA
env:
LYCHEE_REPOSITORY: ${{ github.repository }}
LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
fd -e yml -e yaml . .github/workflows --exec sh -c 'echo "== $1"; sed -n "1,45p" "$1" | rg -n "on:|schedule|cron|workflow_call|workflow_dispatch|push|pull_request|uses: ./.github/workflows/(lychee|pre-commit)" ' _ {}

Repository: NVIDIA/cuda-python

Length of output: 6774


🏁 Script executed:

set -e
printf '%s\n' '== workflow triggers and caller references =='
for f in .github/workflows/lychee.yml .github/workflows/pre-commit.yml .github/workflows/ci-nightly.yml .github/workflows/ci.yml .github/workflows/build-docs.yml; do
  echo "== $f"
  nl -ba "$f" | sed -n '1,180p'
done
printf '%s\n' '== relevant helper and prepare_ci references =='
rg -n -F --glob '*.py' -e 'def _branch' -e 'LYCHEE_DEFAULT_BRANCH' -e 'prepare_ci' ci

Repository: NVIDIA/cuda-python

Length of output: 41037


🏁 Script executed:

set -e
nl -ba ci/tools/checkout_link_defaults.py | sed -n '35,205p'

Repository: NVIDIA/cuda-python

Length of output: 8299


🌐 Web query:

GitHub Actions schedule event payload empty github.event.repository default_branch reusable workflow github context caller

💡 Result:

Yes—**a `schedule` event has no webhook payload**, so `github.event.repository.default_branch` is not available. GitHub’s event reference lists the schedule payload as “Not applicable”; the event object isn’t a repository object. ([github.com](https://github.com/github/docs/blob/main/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md?utm_source=openai))

In a reusable workflow called by that scheduled workflow, **`github` still refers to the caller’s context**. So `github.event.repository.default_branch` remains unavailable there; calling a reusable workflow doesn’t add the missing payload fields. ([docs.github.com](https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations?utm_source=openai))

Use the caller’s `github.repository` to identify the repo and, if you need its default branch, query repository metadata (for example, with the GitHub API). The event’s `github.ref` is the default branch ref for a scheduled run, but it is not itself the `default_branch` property. ([github.com](https://github.com/github/docs/blob/main/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md?utm_source=openai))

Citations:

- 1: https://github.com/github/docs/blob/main/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md?utm_source=openai
- 2: https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations?utm_source=openai
- 3: https://github.com/github/docs/blob/main/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md?utm_source=openai

🏁 Script executed:

set -e
printf '%s\n' '== workflow references =='
rg -n -F --glob '*.yml' --glob '*.yaml' -e './.github/workflows/lychee.yml' -e './.github/workflows/pre-commit.yml' -e './.github/workflows/build-docs.yml' .github/workflows
printf '%s\n' '== metadata blocks =='
for f in .github/workflows/lychee.yml .github/workflows/pre-commit.yml .github/workflows/build-docs.yml; do
  echo "== $f"
  rg -n -C 8 -F 'LYCHEE_DEFAULT_BRANCH:' "$f"
done

Repository: NVIDIA/cuda-python

Length of output: 3010


important: Add a schedule fallback for the default branch.

ci-nightly.yml runs on schedule and calls lychee.yml. Scheduled events do not provide github.event.repository.default_branch, so the helper receives an empty branch and fails before the nightly link checks run.

pre-commit.yml is not scheduled, and build-docs.yml guards this step to pull-request refs. Apply the same fallback to all synced blocks:

Suggested fix
--- a/.github/workflows/lychee.yml
+++ b/.github/workflows/lychee.yml
@@
-          LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
+          LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch || (github.event_name == 'schedule' && github.ref_name) || '' }}
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@
-          LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
+          LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch || (github.event_name == 'schedule' && github.ref_name) || '' }}
--- a/.github/workflows/build-docs.yml
+++ b/.github/workflows/build-docs.yml
@@
-          LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
+          LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch || (github.event_name == 'schedule' && github.ref_name) || '' }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
LYCHEE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch || (github.event_name == 'schedule' && github.ref_name) || '' }}

Source: Path instructions

@rwgk
rwgk requested a review from juenglin October 19, 2026 17:10
@rwgk
rwgk marked this pull request as draft October 19, 2026 19:15
@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch from 983ac75 to 1e5ecd1 Compare October 19, 2026 19:20
@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch from 1e5ecd1 to 6be5142 Compare October 19, 2026 21:01
@rwgk
rwgk removed this pull request from stack #3144 October 19, 2026 21:01
@rwgk
rwgk changed the base branch from rwgk/lychee-pre-commit-ci to rwgk/lychee-maintainer-429-override October 19, 2026 21:01
@rwgk
rwgk added this pull request to stack #3158 October 19, 2026 21:01
@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch from 6be5142 to b361255 Compare October 19, 2026 21:36
@juenglin

Copy link
Copy Markdown
Contributor

Thanks for the stack. Two issues to fix before merge:

1. Nightly will fail at "Discover repository link targets". This is the open CodeRabbit thread on lychee.yml: scheduled events have no github.event.repository, so the default branch is empty and _branch("") raises. Please apply its fallback (or skip remapping on that path) and verify with a run that has no github.event.repository. The earlier nightly validation used workflow_dispatch, which would not catch it.

2. The local hook hard-fails when the remote HEAD is not cached. run_lychee.py computes the remaps unconditionally, so editing any Markdown or reST file, even one with no repository links, fails until the contributor runs git remote set-head upstream --auto. Could this skip the remaps with a clear warning when metadata cannot be resolved, and only error when a link would actually be remapped? If the strict behavior is deliberate, please say so in the PR description and ci/README.md.

@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch 2 times, most recently from 5010c1e to a7d8e47 Compare October 19, 2026 22:26
@rwgk

rwgk commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@juenglin

  1. The local hook hard-fails when the remote HEAD is not cached.

Great observation. It took me a few minutes to unpack this finding. The issue escaped my attention before (I naively assumed it is easy to determine the default branch). I'm taking a step back now to look at this carefully.

@rwgk

rwgk commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@juenglin

  1. The local hook hard-fails when the remote HEAD is not cached.

Great observation. It took me a few minutes to unpack this finding. The issue escaped my attention before (I naively assumed it is easy to determine the default branch). I'm taking a step back now to look at this carefully.

codex GPT-6.1-Sol ultra:

Commit 911747a simplifies the checkout-aware link handling.

The key observation is that our public blob/main/ and tree/main/ URLs express the intended publication destination. We can validate their targets against the proposed checkout without discovering any repository’s default branch.

The resulting policy is:

  • Authored documentation: check files and directories locally, including uncommitted additions. No repository metadata or discovery requests are needed.
  • Rendered documentation in the public repository: check GitHub’s source view at the actual tested commit, retaining fragment validation.
  • Rendered documentation in other checkouts: check source paths locally, omitting fragments only on those remapped source links. Generated documentation pages and their anchors remain fully checked.

This removes the three CI discovery steps and the local cached remote-HEAD requirement. Checking builds also select an appropriate reference for generated example links. Tags, explicit commits, other branches, and unrelated repository links retain their original targets.

Validation passes: 259 CI-tool tests, 36 subtests, and all-files pre-commit. Native Lychee probes also confirm that missing local targets fail despite an earlier cached success, and that ordinary HTML anchor failures remain detectable.


  1. Nightly will fail at "Discover repository link targets".

This is moot now, too: commit 911747a removes “Discover repository link targets” from all three workflows, including nightly.

Base automatically changed from rwgk/lychee-maintainer-429-override to main October 20, 2026 00:01
rwgk added 3 commits October 19, 2026 17:01
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
@rwgk
rwgk force-pushed the rwgk/lychee-checkout-aware-links branch from 911747a to 1d24145 Compare October 20, 2026 00:01
@rwgk

rwgk commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1d24145

@rwgk

rwgk commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Independent review by Claude Code (Claude Fable 5.1), requested by the author after the post-approval simplification. Covers the branch at 74fc792 (commits 1d24145 and 74fc792) against main at b1e2788.

Verdict: no blocking issues. Mergeable once the draft is marked ready, optionally after picking up the one CodeRabbit nit that still applies.

Findings (all low severity)

  1. Test wiring gap: test_run_lychee.py#L27, and likewise lines 61 and 88. All three main() tests patch repo_link_remaps to return an empty list, so the insertion of the remap arguments at run_lychee.py#L88 is untested. This is CodeRabbit's nitpick and it still applies. Its suggested patch has an off-by-one: after inserting two items, the report path is command[6], not command[5].

  2. Local rendered runs in a public-remote clone: checkout_source_links.py#L74. With upstream pointing at NVIDIA/cuda-python, a local lychee-rendered run checks blob/main/ links at the local HEAD on GitHub, so every such link 404s until the commit is pushed (reproduced with a non-existent SHA: 4 of 4 links failed). ci/README.md#L124 documents the constraint but not the escape hatch. Either document git config lychee.repository <fork> as the local-file fallback, or treat only a set GITHUB_REPOSITORY as public and let all local runs validate files; the second option would also remove the remote-parsing code. Design choice, not a defect.

  3. Rendered cache economics. Lychee keys its cache by the remapped URI, and public mode rewrites blob/main/ to blob/<sha>/, so these links never hit the nightly baseline. Each full-CI rendered check now makes up to 13 fresh GitHub page requests (the unique blob|tree/main URLs across the sources; the rendered docs contain a subset). The generated example links at blob/<sha>/ were already uncached and the 429 override exists, so this is a modest increase rather than a new job or build.

Nits: a required store_true flag at checkout_source_links.py#L98 and the regex string surgery at line 92 both work but read oddly.

CodeRabbit findings

  • Major on .github/workflows/lychee.yml:83 (schedule fallback for LYCHEE_DEFAULT_BRANCH): obsolete. The simplification removed all three discovery steps and lychee.yml is no longer in the diff. The thread shows as outdated but unresolved; the "Merge Risk: Moderate" summary is stale for the same reason (last reviewed at 983ac).
  • Nitpick on the run_lychee.py tests: still valid, see finding 1.

What was verified

  • Tests: 47 passed in the three touched test files; the full CI-tools suite passed with 259 tests and 36 subtests.
  • CI: Pre-commit Linux and Windows are green on 74fc792. Full CI run 39345233394 is green on pull-request/3143 at 1d24145, including "Docs / Build docs", where the rendered check runs in public mode.
  • Lychee 0.24.2 probes (standalone binary, same pin as the hook): remaps are regex replace_all with $1 groups; a missing local file fails; nothing is cached for file targets, and deleting a file between two --cache runs fails the second run; query-plus-fragment URLs work; the local rendered pattern drops fragments only on source links while ordinary HTML anchors still fail; public remaps at the real main SHA pass for a file and a directory, 404 for a missing path, and fragment checks on blob pages at a SHA behave exactly like at main.
  • Lychee source: lychee-bin/src/cache.rs confirms the cache key is the remapped URI and file:// results are never cached.
  • Repo links: the 13 unique blob|tree/main URLs in the repo resolve against the working tree through the helper's actual remap (offline run, zero errors).
  • The two review requests: both addressed. No discovery step remains, and the authored path makes no git or subprocess call (asserted by a test). The rendered manual hook still needs a repository identity but fails with an actionable message.

Runner work versus main: PR push adds no jobs and makes fewer GitHub requests (authored source links become file checks). Full CI adds no jobs or builds, only the extra requests from finding 3. Nightly and main push are unchanged apart from one Python call.

Probe commands (lychee-bin 0.24.2)
ROOT_URI=$(python -c 'from pathlib import Path; print(Path(".").resolve().as_uri() + "/")')

# Authored mode, as emitted by repo_link_remaps(ROOT). Run twice with a linked
# file deleted in between: the second run fails; .lycheecache stays empty for file targets.
lychee --offline -vv --cache --remap "^https://github[.]com/NVIDIA/cuda-python/(blob|tree)/main/ ${ROOT_URI}" authored.md

# Local rendered mode: fragments dropped only on the remapped source links.
lychee --offline -vv --include-fragments=full \
  --remap "^https://github[.]com/NVIDIA/cuda-python/(?:blob|tree)/main/([^#]*)(?:#.*)?$ ${ROOT_URI}\$1" index.html

# Public rendered mode at a real commit; fragments checked on GitHub's blob pages.
lychee -vv --include-fragments=full \
  --remap "^https://github[.]com/NVIDIA/cuda-python/(blob|tree)/main/ https://github.com/NVIDIA/cuda-python/\$1/$(git rev-parse upstream/main)/" pub.html

The -vv output prints Remapping <original> --> <target> for every rewritten link.

rwgk added 2 commits October 19, 2026 19:43
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
@rwgk

rwgk commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

codex GPT-6.1-Sol ultra:

Thanks for the detailed Fable review. The two actionable findings are addressed in separate commits:

  • 9b28ebc0148 strengthens the existing wrapper tests with nonempty remap arguments. They now verify that the arguments reach native Lychee and that authored/rendered checks select the correct mode. The missing-build case also verifies that remapping is never invoked. The suggested report-path index is corrected to command[6].
  • dd3100c23a6 documents local rendered checks for unpublished commits: select the actual fork identity before both the checking build and the rendered hook, and rebuild output that already contains unpublished SHA links. This uses the existing local-file mode; generated HTML anchors remain checked, while GitHub-specific source-view fragments are omitted.

Local validation passes: all 259 CI-tool tests and 36 subtests, plus pre-commit run --all-files, including authored Lychee and workflow linting. The dependent rename branch is restacked with its own changes preserved.

@rwgk

rwgk commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

codex GPT-6.1-Sol ultra:

Regarding the Fable review's cache observation: rendered source links are checked at the proposed commit, so their URLs usually differ from the URLs for the default-branch commit in the nightly baseline. A small number of fresh GitHub requests is an accepted cost of validating the proposed source tree, including its GitHub source-view fragments. A success for a different commit would not establish that the proposed target is valid.

This does not add a job or documentation build. Authored source links become local file checks, reducing requests there, and established external links continue to use the shared cache. Matching SHA URLs can still reuse cached successes, including during retries; the review's “never” is therefore slightly stronger than the actual behavior. The current link inventory is useful context rather than an exact request-count guarantee.

@rwgk

rwgk commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

codex GPT-6.1-Sol ultra:

For completeness, the remaining review observations do not require implementation changes:

  • CodeRabbit's earlier scheduled-workflow/default-branch finding refers to the removed discovery steps. Those steps no longer exist, and .github/workflows/lychee.yml is no longer changed by this PR, so that finding and the associated risk summary are outdated.
  • The required --github-ref flag and the shared-regex construction are functional. The former makes the requested CLI operation explicit; the latter keeps the canonical source-URL prefix in one place. I suggest retaining both for this PR.

The wrapper-test concern from the same CodeRabbit review is addressed by the new test commit described above.

@rwgk

rwgk commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dd3100c

@rwgk
rwgk marked this pull request as ready for review October 20, 2026 04:02
@rwgk
rwgk merged commit 4ce6efe into main Oct 20, 2026
220 of 222 checks passed
@rwgk
rwgk deleted the rwgk/lychee-checkout-aware-links branch October 20, 2026 04:31
@rwgk rwgk removed the PR review get-together Mark PRs you'd like the team to review at the weekly PR review get-together. label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD CI/CD infrastructure enhancement Any code-related improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants