Repository navigation
pool-check: a {ref} link that leaves its site has one target (ref-target) - #101
Merged
Merged
Conversation
…get)
A label a site's pages don't define must be defined by at most one of
the pool's sites the site maps. Intersphinx merges the mapped sites'
inventories in sorted name order, the last winning, so a label two
mapped sites define sends the link to whichever name sorts last. On
the pool today that is dp's perm_income_cons, {ref}`lln_mr`, which
intro and intermediate both define, so dp's link lands on intro's
lecture; QuantEcon/lecture-python-intro#882 renames intro's label.
A prefixed link names its site and is not counted; a mapped site
outside the pool is not read.
- tools/pool-check: check_ref_targets, the ref-target rule, and its
description in the module's docstring.
- tools/tests/test_sites.py: the reported case and four clean ones (one
mapped site defines it, a prefix, the site's own label in any case,
an inline literal).
- sites/README.md: rule 8, and a note that hard-coded addresses are
outside the rules; README.md: one sentence.
For QuantEcon/project-monorepo#22, on Matt's "Rule + two intro PRs".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
There was a problem hiding this comment.
🟡 Changes recommended
Active findings identify uncaught invalid-UTF-8 errors and incorrect reference-target and site-mapping handling that can suppress findings, miss ambiguities, or report false ambiguities.
3 open issues
What changed in this PR
Adds a ref-target rule to pool-check to detect ambiguous cross-site {ref} links among mapped pool sites. The draft intentionally reports the existing lln_mr collision until the upstream label rename reaches the pool.
Changes:
- Collects site labels and reports unprefixed references with multiple external targets.
- Adds tests for ambiguous links and four accepted cases.
- Documents the rule and its exclusions.
| File | Description |
|---|---|
tools/tests/test_sites.py |
Adds fixtures and tests for cross-site reference checking. |
tools/pool-check |
Implements and runs the ref-target rule. |
sites/README.md |
Documents rule 8 and excludes hard-coded URLs. |
README.md |
Adds the new rule to the pool-check overview. |
Review effort: Balanced (adaptive)
- Only a label a {ref} reaches counts: targets ((name)=, :name:) and an
exercise's or solution's 🏷️ (sphinx-exercise's). A {math} block's
🏷️ is an equation's and a {prf:...} directive's sphinx-proof's, and
{ref} reaches neither (QuantEcon/lecture-python-intro#883), so a site's
own equation no longer hides an ambiguity, and two mapped sites' proofs no
longer make one.
- A mapped name is read as the pool site at its address, by site.yml's url
(intro's pyprog is programming), keeping the name for the prefix and for
intersphinx's order.
- A site's YAML or page that is not UTF-8 text is left to the site rules,
which report it, instead of an internal error that hid every finding.
On the pool the output is unchanged: the one finding is still dp's
{ref}`lln_mr`. Each fix has a test that fails on e453d18.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
a33164a skipped a site's own page that is not UTF-8 text with no finding, and no other rule reads those pages, so the check passed (exit 0) where e453d18 stopped with an internal error. It is now a site-layout finding, reported with the rest (exit 1). A pool lecture never gets this far: its references are read first, and stop the check. The docstring and rule 8 no longer read as a complete list of the labels a {ref} reaches: a directive's YAML option block (none in the pool) and a code cell's mystnb figure name (over 700, none named by a {ref}) are not read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
…l-check/ref-labels
mmcky
marked this pull request as ready for review
November 27, 2026 11:30
mmcky
added a commit
that referenced
this pull request
Nov 28, 2026
## Why The last open part of QuantEcon/project-monorepo#77. Its acceptance criteria: - "A pull request that touches one shared lecture rebuilds every product that lists it and no other"; - "A planted broken lecture fails every product that holds it and no other product's build". Today every pull request and push to `main` that touches a build input builds all six sites. A fix to one intro lecture also rebuilds intermediate, programming and jax on the GPU machines. For pushes to `main` the owner chose the same narrowing on 2026-11-27, in the project-monorepo session: "Affected only (Recommended)". The schedule and a manual run still build every site. ## What it adds - **`tools/affected-sites`** reads the changed paths and prints the sites, of those named, that they reach: - a lecture, or its own `_static/<slug>/` files: the sites whose `_toc.yml` lists it, at any depth of parts, chapters and sections; - a `_static/_shared/` asset: the sites of the lectures the ledger records as using it, or every site when it records none; - a `_static/<dir>/` that is no pool lecture's folder: every site; - a site's own file: that site (`sites/README.md` reaches none); - `tools/sync` and `sync/state.yml`: the sites in the `series` environment, here or at the base, since only those run `tools/sync` (today dp). `sync.yml`'s near-daily pin refresh starts no run, but the next push takes it in, and it builds dp alone; - any other build input: every site. That covers the bibliography, any other pool file, a build tool, `_base/`, `sync/manifest.yml` (which `tools/stage-site` reads for every site) and the workflow. These are the workflow's path filter outside the pool and the sites, and a test keeps the two lists in step; - anything else (documentation, the tests, another workflow, the other sync records): none. With `--base`, the contents lists and the ledger are read at the base too. So a lecture a change drops still builds the sites that listed it, and a shared asset its old users' sites. Paths come NUL-separated with `-z`. The tool refuses a `--base` that is no commit, and a contents list or ledger it can't parse, with exit 2. Links between sites don't widen the set: intersphinx resolves them against the other site's published inventory, not this build. - **`site-build.yml`**'s first job chooses the sites: - **A pull request** is compared with its base. - **A push** is compared with the head of the last build on `main` that succeeded, not the commit before it. That build may be a push, scheduled or manual one, but never a pull request's. A run cancelled while it waits (the concurrency group keeps one waiting), cancelled by hand, or failed then leaves nothing unbuilt: the next push takes its change in. A step of its own reads that run through the API, with `actions: read`. It runs only on a push, and is the only step that holds the token. - **While a site stays red on `main`,** no build succeeds, so each push builds all that has changed since the last green build. The header says to mend a red site first. It also says to re-run an older push build's failed jobs, not all its jobs. - **The schedule and a manual run** take every site, and so does a base that can't be found or fetched. - The diff is `git diff --no-renames --name-only -z`. A renamed or moved file counts by its old path as well as its new one, and a name git would quote keeps its bytes. Only the base commit is fetched: a diff of two trees needs no history. - **A change to the rule itself** (the tool or this workflow) builds every site without asking the tool, so a broken tool can't skip its own build. - The job writes "Sites built: … " and the reason to the run summary. When a change reaches no site, the build job is skipped, since GitHub refuses an empty matrix. - **The header:** who builds what, and how a push is compared. "What it does not do" now puts mystmd and the shared cache in the second phase, after the cutovers, which takes in the note deferred from #110. - **Docs:** README's build paragraph and tools table, and `sites/README.md`'s "Building a site in CI". ## Checked - **Tests:** 501 passed and 1 skipped. They cover: - every rule (24 cases), including a section nested in a part and the series inputs; - a site moved out of the series environment, read at the base, and a site with no `site.yml`; - over a real git history: a dropped lecture, the ledger read at the base, a renamed lecture, an asset moved between two lectures' folders, and a name git would quote; - a key with no site, a base that is no commit, and a contents list that can't be parsed; - the workflow, read for its path filter (both events), its diff flags, the rule check, the push base's query step, and that only that step holds the token. Six of the new tests fail on the first version of the tool, and dropping the ledger's base reading fails one. actionlint and pool-check are clean. - **On the real pool,** with the workflow's own diff command: - `git mv lectures/os_stochastic.md lectures/os_stochastic_v2.md` builds dp and intermediate; - moving an `about_py` figure into `os_stochastic`'s folder builds dp, programming and intermediate; - a new `_static/lecture_specific/…` builds all six; - `about_py/café.png` builds programming; - the pin refresh `fc2ea1f` builds dp alone. - **On tonight's merges** (each squash commit against its parent): | Merge | Sites it would build | |---|---| | the refresh #107 (two intro lectures) | intro alone, instead of all six | | #101 (pool-check, its tests, `sites/README.md`) | none; it built all six | | #110 (the README) | none | | #106 (`site-build.yml`) | all six | | #109 (`tools/stage-site`) | all six | - **Real runs, each from a throwaway draft against this branch, now closed:** - #112 planted a failing cell in a lecture that dp and intermediate list. Only those two legs ran, and both failed in the strict build on the planted error. - #113 changed only `sites/README.md`. The matrix job reported no site, and the build job was skipped. The evidence comments below have the details. - **This PR's own build** changes the workflow, so it builds all six: the "rule itself" path. - **The push path** can't run before the merge. Its query, run now against this repository, returns 31f29fc (#101), the last build on `main` that succeeded. The first push after the merge carries this workflow, so it builds all six. The "Sites built" summaries of the first two push builds on `main` are to be read after the merge. The first should say it touches the rule, against 31f29fc. The second should be compared with the merge commit, if the first went green. The validation rule: this changes which sites build, not how. The legs that run are unchanged steps, so a full output comparison isn't needed. The planted test is the evidence. Copilot: not requested (Matt, 2026-11-22). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

A draft until QuantEcon/lecture-python-intro#882 reaches the pool. This rule's own check is red on this branch, as it should be: it reports the one case the pool has today.
What it adds
A new pool-check rule,
ref-target, for QuantEcon/project-monorepo#22, on Matt's "Rule + two intro PRs" (2026-11-26, relayed by the organiser session): a{ref}link that leaves its site has one target. A label the site's pages don't define must be defined by at most one of the pool's sites the site maps.Why. Sphinx 7.4.7's intersphinx merges the mapped sites' inventories in sorted name order, each overwriting the last (
sphinx/ext/intersphinx/_load.py,load_mappings). So a label that two mapped sites define sends the link to whichever name sorts last, whatever the lecture meant. Rule 3 keeps lecture names unique for{doc}links; this does the same for the labels a link leaves its site for.What it doesn't count. A prefixed link (
{ref}`intermediate:lln_mr`) names its site. A mapped site outside the pool, such as a retired one that intro still maps, is not read. Labels are targets ((name)=,:name:) and a directive's:label:(a proof's or an exercise's), compared without case, as Sphinx does. Text in code cells and literals is not read, as fordoc-target.The one case today
sites/dp: lectures/perm_income_cons.md links to {ref}lln_mr``. intro'slln_clt_introand intermediate's `lln_clt` both define `lln_mr`, and `intro` sorts last, so dp's live page links to intro's lecture rather than intermediate's, which dp's copy follows. QuantEcon/lecture-python-intro#882 renames intro's label to `lln_mr_intro`. Once it merges and the nightly refresh brings it into the pool, this check is clean, and this pull request can leave draft.The other ambiguous link QuantEcon/project-monorepo#22's check found, intro's
markov_chains_II, isn't one this rule can see: its second target was the retired tools-techniques site. QuantEcon/lecture-python-intro#883 points it back at intro's own example.Changes
tools/pool-check:check_ref_targets, the rule, and its entry in the docstring.tools/tests/test_sites.py: the reported case, and four clean ones: one mapped site defines the label, a prefix names the site, the site defines the label itself (in any case), and an inline literal that isn't a link.sites/README.md: rule 8, and a note that a hard-coded address is outside the rules, since Sphinx never resolves it and only the link checker sees it.README.md: one sentence.Locally: the tests pass (335, and 1 skipped), and pool-check reports exactly the case above. Copilot: not requested (Matt, 2026-11-22).
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG