Repository navigation
tools/site-compare: a monorepo site build against a series' own build, every difference classified - #129
Merged
Conversation
…, every difference classified QuantEcon/project-monorepo#26, re-cut on 2026-12-03 on the owner's decisions: the comparison a cutover is decided on, ported from the validations run by hand (#84, #99, #105 and others). - tools/site-compare: compares two HTML builds (the series' own; the monorepo's html-<key> artefact) by file inventory, prose, structure, links, the View Source path (the repository normalised away, so QuantEcon/quantecon-book-theme#452 shows), warnings and tracebacks in outputs, figure counts and bytes, output text, objects.inv labels, redirects and notebook cell sources. Every difference is classified: expected (an entry of an expected-difference list, with its reason), lag (a lecture changed since the reference's commit, --lag), defect, or reported (output values, figure bytes, new labels: never blocking, the owner's rule of 2026-12-03). An entry can cover a whole difference, only the lines a pattern finds (the rest go on), or set a pattern aside before comparing (normalise), counted in the report. Writes report.json and report.md; exits 1 on a defect. - sites/compare-expected.yml: the shared list, calibrated on intermediate (its release publish-2026nov30b against the monorepo's build at 9728988): the merged bibliography's anchors and entries, the status page, PDF links in _downloads/, the pool's _static/<slug>/ layout. - tools/affected-sites: a site's compare-expected.yml, and the shared list, reach no build (read after a build, by no build). - tests: 24 for the tool (one per planted defect, the classes, the list format), and the affected-sites cases. Calibration on intermediate: 2 defects, 8 expected, 6 lag (newton_method, changed since the release), 46 reported. The 2 defects are real: two notebooks link a PDF relatively, which a notebook opened in Colab cannot follow (#45, promote's rule 7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
Contributor
☁️ Cloudflare Preview Ready! (dp)Preview URL: https://pr-129.qe-preview-dp.pages.dev Commit: Build Info
|
Contributor
☁️ Cloudflare Preview Ready! (programming)Preview URL: https://pr-129.qe-preview-programming.pages.dev Commit: Build Info
|
Contributor
☁️ Cloudflare Preview Ready! (advanced)Preview URL: https://pr-129.qe-preview-advanced.pages.dev Commit: Build Info
|
Contributor
☁️ Cloudflare Preview Ready! (intro)Preview URL: https://pr-129.qe-preview-intro.pages.dev Commit: Build Info
|
Contributor
☁️ Cloudflare Preview Ready! (intermediate)Preview URL: https://pr-129.qe-preview-intermediate.pages.dev Commit: Build Info
|
Contributor
☁️ Cloudflare Preview Ready! (jax)Preview URL: https://pr-129.qe-preview-jax.pages.dev Commit: Build Info
|
From the review of #129, each finding demonstrated on real intermediate pages, each now a test: - pool-check: sites/compare-expected.yml and a site's own compare-expected.yml are allowed (CI was red on site-layout). - Prose and notebook text keep every date, decade and number: only build ids (UUIDs, long hashes, ?v=) are set aside there; dates and durations only in outputs. - A new code check compares code blocks line by line with indentation; notebooks compare code cells the same way, and their kernelspec. - Warnings are read per output block (so a SyntaxError split from its colon, a bare "Warning:" and a "WARNING:" line are found), and traceback and stderr output blocks are counted. - A figure file the page names but the candidate lacks is a figures defect, not a pixel difference. - A new targets check: a link or image newly broken in the candidate. - A redirect stub's target, and the toolbar's launch links (Colab, notebook, PDF), are compared; source-link reads only the toolbar's GitHub links, so a prose GitHub link is compared in full as a link. - --lag never covers a warning, a lost file or a lost target, and matches top-level pages and notebooks only; lag lines show in report.md. - The shared list's PDF entry sets aside only the folder, so a dropped or different PDF is still a defect. - A crash exits 3, not 1; the docstring names the shared list's path. Calibration on intermediate again: 2 defect (#45's relative PDF links), 6 expected, 5 lag, 48 reported. Tests: 48 for the tool; full suite 582 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
- warnings: each warning, error or traceback header is keyed by its class and the rest of its line (dates, durations and build ids set aside), so a different message of the same class is a change. - source-link: the header's page-history link (commits/main/<path>) is compared by path; on today's theme the per-page View Source link sits in an HTML comment and was never seen. - targets: root-absolute links and links at the site's own address (from the canonical link) are resolved in the build; a file a notebook names at the site's own address (a _static/ figure) must be in the candidate. - redirects: a stub's script target is compared with its meta refresh. - code: one marker between blocks, so a new block no longer counts against every block after it. - Source and launch links are taken wherever they are not prose links; the toolbar gate had no effect on real pages. - Exit 3, not 1, when pyyaml is missing. - 14 tests for the review's gaps, each checked against a mutation of the guard it pins (62 tool tests; suite 596 passed, 1 skipped). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
- A site served under a path (dp at quantecon.github.io/lecture-dp/): the site's address is its host and the path the canonical link gives less the page's own, so a self-site URL resolves from the build's root, not from a path that never exists. A lost figure a notebook names is caught, and a figure the pool's layout moved is no false defect. A self-site URL on a page in a folder resolves from the site's root too; http and https both. - With no canonical link in the candidate, the reference's is used, and each page's canonical link is compared under links, so losing it shows. - The notebook check reads the parsed cell sources, not the raw JSON. - A warning's message has its numbers, memory addresses, temporary paths and times of day set aside: those are values, which differ from run to run. - A script's `target = "..."` is a redirect target only in a script that redirects (location.replace, assign or href). - 13 tests, each checked against a mutation of its guard (all 12 mutations fail a test); 75 tool tests; the calibration on intermediate is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
mmcky
added a commit
that referenced
this pull request
Dec 3, 2026
…pellings, redirect scripts, warning numbers) (#131) The last review of #129 (Opus, at `3bb3e97`) found nothing blocking: "ready with nits". This pull request carries those nits, for QuantEcon/project-monorepo#26. **What changes in `tools/site-compare`:** - **`canonical` is its own check, and never lag.** A page's canonical link comes from the site's configuration, never from a lecture, so a change on a lag page is still a defect. It was a line of `links` in #129. - **The site's own address, in any spelling:** host case, a default port (`:443`), a protocol-relative URL (`//host/…`), and a double slash after the site's path, which resolved outside the build. A directory-style canonical (`…/sub/`) gives the site's address too. - **On a site served under a path** (dp at `quantecon.github.io/lecture-dp/`), a root-absolute path outside that path names no file of the build. Live, it would point at another site on the same host. - **Redirect stubs:** a script counts as a redirect stub's only if it redirects to the variable it sets (`location.replace(target)`, `location = target`). plotly's bundle sets `t.target="_blank"` and reads `location.href`, so an inlined plotly gave a false `redirects` defect. - **Warnings:** in a warning's message, a number is set aside only where one starts, and only whole. Digits inside a name (`float64`, `log10`, `utf-8`, `2D`) and a version (`1.10.0`) are part of the message, and a different one blocks. **After this PR's review (`3e64c1b`).** The review found one should-fix: the token boundary refused a number before a full stop, so a value ending a sentence (`error = 3.2e-05.`) blocked again, against the owner's rule. It also found guards no test pinned. - A number may again be followed by a full stop, or by a size or factor unit (`512MB`, `2.5x`), which goes with it. Then `b2c4eee`, after the delta review: a number is matched whole or not at all, so a version keeps every part (`1.10.0` against `1.20.0` blocks). Only listed units go with a number, so `2D` or `64bit` stays in the message, and so do the digits of a hyphenated name (`utf-8`). The value tests now differ in their last digit. - A figure at an absolute address is left to `targets`, which compares with the reference, so one missing from both builds is no difference. - Index pages are matched exactly, not `genindex.html`. - A port counts as a default only for its own scheme. - Root-absolute figures resolve under a site's path. **Tests:** 40 new, 115 in `tools/tests/test_site_compare.py`. Each pins a guard the reviews found untested, or one added here. Each was checked against a mutation of its guard. The last review (at `b2c4eee`, ready with nits) found six mutations of the number pattern that no test catches yet: dropping the `x` or bare `B` unit or the `i` of `GiB`, narrowing the size prefixes, dropping the sign, and a letters-only hyphen guard. They go, with its other nits, into the next change to the tool: an unguarded `urlsplit` on a malformed figure address, `0x` matching inside `1000x800`, and a few glued units not on the list (`kB`, `GHz`, `1.2h`, `μs`). The full suite gives 652 passed, 1 skipped. **Calibration:** the intermediate comparison of #129 is unchanged, item for item: 6 defect, 6 expected, 5 lag, 48 reported. 🤖 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.
The first piece of QuantEcon/project-monorepo#26, as re-cut on 2026-12-03 from the owner's decisions after a review of phase 4: the comparison a cutover is decided on. It is ported from the validations already run by hand on #84, #99, #105 and others.
Reworked in
0deb1f2after the first review, which found real defects the first version missed (each demonstrated on real intermediate pages, each now a test). Thena21757a, after the delta review:_static/figure) are resolved in the build;Then
3bb3e97, after a second delta review:quantecon.github.io/lecture-dp/, has its own address resolved (the canonical's path less the page's), so a lost figure a notebook names is caught there and a figure the pool's layout moved is no false defect;The table below is the tool as it now stands.
tools/site-comparecompares two HTML builds: a series' own build (its release, or its repository built at a commit) and the monorepo's build of the same site (thehtml-<key>artefactsite-build.ymlmakes, whichpublish.ymlreleases).What it compares:
?v=) set aside, every date, number and word kept_rediraffe_redirected.json…Warning:,…Error:,WARNING, traceback headers, each by its class and message (numbers, dates, times, addresses and temporary paths set aside); traceback and stderr blocks_images/figure's bytes, in orderobjects.inv: a lost label blocks, a new one is reportedClasses. Every difference is one of:
--lag), except a warning, a lost file or a lost target, which always block;The expected-difference lists. They are YAML: the shared
sites/compare-expected.yml(this PR) andsites/<key>/compare-expected.yml, changed only by reviewed pull request. An entry can cover:linespattern finds, with the rest classified on;normalisepattern, set aside before comparing, whose pages the report counts.tools/affected-sitesnow treats these lists as no build's input, so editing one rebuilds nothing. The tool writesreport.jsonandreport.md. It exits 1 on a defect, and 3 when the comparison itself fails (a crash, or pyyaml missing), which is not a finding.Calibration on intermediate. The reference is its release publish-2026nov30b (QuantEcon/lecture-python.myst at
3437219). The candidate is the monorepo'shtml-intermediatefrom site-build run 47031722447, at9728988. The run went in six steps:zreferences.html#idN), which the merged bibliography numbers differently._static/<slug>/layout.0deb1f2), whose checks are stricter: 2 defects, 6 expected, 5 lag, 48 reported. The same two defects remain; the shared list's PDF entry now sets aside only the folder.a21757a, which compares the page-history link: 6 defects, 6 expected, 5 lag, 48 reported.The lag items are newton_method, changed since the release by #125. The reported items are output values and figure bytes.
The six defects are real, and go on no list here:
linear_algebra.ipynbandlinear_models.ipynblink "these notes" (a PDF) relatively, as_static/<slug>/….pdf. A notebook opened in Colab can't follow such a link. The series' notebooks link the live site's absolute address. The cause is promote: rule 7 makes Colab-friendly links relative, and a notebook opened outside the site cannot follow them #45 (promote's rule 7, open).sites/intermediate/, show no page-history link and no list of recent commits; the series' pages do. The lectures' pages have theirs (QuantEcon/lectures/commits/main/lectures/<slug>.md). Whether site-build should give these pages a history, or the shared list should accept the difference, is a question for the calibration report on QuantEcon/project-monorepo#26. Either way they will need a list entry: a history link site-build gave them would rightly point atsites/intermediate/<page>.md, which still differs from the series'lectures/<page>.md.3bb3e97leaves the calibration unchanged: the same 6 defects, 6 expected, 5 lag and 48 reported.Tests:
tools/tests/test_site_compare.py, 75 tests:lectures/;_images/, a root-absolute link, a notebook's self-site_static/URL (and another site's address left alone), a redirect's script target, the history link's path and its absence, and a new code block's count.Left for a follow-up pull request (the last review's nits, none blocking): tests for guards still unpinned (root-absolute paths under the prefix, another path on the same host, the per-page canonical fallback, scheme and case); a script that reads
location.hrefbut doesn't redirect (plotly's bundle) still counts as a redirect script; a double slash after the prefix resolves outside the build; and the warnings key's number pattern also sets aside digits inside identifiers (float64,log10).Next for QuantEcon/project-monorepo#26: the PDF check by outline section, and the GPU-fallback check from the execution report. Then dp's comparison against dp's own build at its pin, once that reference is built. Changing
tools/affected-sites, a build input, makes this PR build every site, from the cache.🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG