Skip to content

tools/site-compare: a monorepo site build against a series' own build, every difference classified - #129

Merged
mmcky merged 4 commits into
mainfrom
site-compare
Dec 3, 2026
Merged

mmcky merged 4 commits into
mainfrom
site-compare

Conversation

@mmcky

@mmcky mmcky commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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 0deb1f2 after the first review, which found real defects the first version missed (each demonstrated on real intermediate pages, each now a test). Then a21757a, after the delta review:

  • a different message of the same warning class now blocks;
  • the header's page-history link is compared, since the per-page View Source link sits in an HTML comment on today's theme;
  • root-absolute links, links at the site's own address, and files a notebook names at that address (a _static/ figure) are resolved in the build;
  • a redirect stub's script target is compared;
  • one new code block no longer counts against every block after it.

Then 3bb3e97, after a second delta review:

  • a site served under a path, as dp is at 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;
  • with no canonical in the candidate, the reference's is used, and each page's canonical is compared under links;
  • a warning's numbers, memory addresses, temporary paths and times are set aside, as values;
  • a script's target counts only in a script that redirects.

The table below is the tool as it now stands.

tools/site-compare compares 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 (the html-<key> artefact site-build.yml makes, which publish.yml releases).

What it compares:

Check What it compares Blocks?
inventory files only in one build yes
text each page's prose; only build ids (UUIDs, long hashes, ?v=) set aside, every date, number and word kept yes
code code blocks line by line, indentation kept yes
structure counts of exercises, proofs, maths, tables, admonitions yes
links a page's links as one list, and its canonical link; hashed asset paths set aside yes
targets a link or image newly broken in the candidate: relative, root-absolute or at the site's own address (from its canonical link); and a file a notebook names at that address yes
launch-links Colab, notebook and PDF links that aren't prose links (the toolbar's) yes
source-link GitHub links that aren't prose links (the header's page-history link), by path within the repository (QuantEcon/quantecon-book-theme#452) yes
redirects a redirect stub's meta refresh and script target; _rediraffe_redirected.json yes
warnings per output block: …Warning:, …Error:, WARNING, traceback headers, each by its class and message (numbers, dates, times, addresses and temporary paths set aside); traceback and stderr blocks yes
figures the images on a page, and an image file the candidate names but lacks yes
figure-bytes each _images/ figure's bytes, in order reported
outputs output text, dates and durations set aside reported
labels objects.inv: a lost label blocks, a new one is reported lost: yes
notebooks kernel; markdown by text, code line by line with indentation; ids and other metadata set aside yes

Classes. Every difference is one of:

  • expected: an entry of an expected-difference list covers it, with its reason;
  • lag: it is in a lecture changed since the reference's commit (--lag), except a warning, a lost file or a lost target, which always block;
  • defect;
  • reported: it never blocks, under the owner's rule of 2026-12-03 (values, timings, pixels).

The expected-difference lists. They are YAML: the shared sites/compare-expected.yml (this PR) and sites/<key>/compare-expected.yml, changed only by reviewed pull request. An entry can cover:

  • a whole difference;
  • only the lines a lines pattern finds, with the rest classified on;
  • a normalise pattern, set aside before comparing, whose pages the report counts.

tools/affected-sites now treats these lists as no build's input, so editing one rebuilds nothing. The tool writes report.json and report.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's html-intermediate from site-build run 47031722447, at 9728988. The run went in six steps:

  1. With no list: 280 defects, almost all citation anchors (zreferences.html#idN), which the merged bibliography numbers differently.
  2. With the shared list's bibliography, status-page and PDF-link entries: 15 defects, all notebook image links that differ only in the pool's _static/<slug>/ layout.
  3. With that layout entry: 7.
  4. With equation UUIDs set aside in notebooks, and the status and bibliography entries covering their notebooks: 2 defects, 8 expected, 6 lag, 46 reported.
  5. With the reworked tool (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.
  6. With 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:

  • Two notebooks' PDF links. linear_algebra.ipynb and linear_models.ipynb link "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).
  • Four site pages without a page history. The monorepo's intro, status, troubleshooting and zreferences pages, which come from 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 at sites/intermediate/<page>.md, which still differs from the series' lectures/<page>.md.

3bb3e97 leaves the calibration unchanged: the same 6 defects, 6 expected, 5 lag and 48 reported.

Tests:

  • tools/tests/test_site_compare.py, 75 tests:
    • one per planted defect: a removed paragraph, a missing figure, a broken link, a dropped notebook, a lost label, a new warning, a lost redirect, an edited notebook cell, a View Source link without lectures/;
    • identical builds, and notebook ids or metadata alone, give nothing;
    • values and pixels are reported, and a new label is reported;
    • entries with reasons, partial lines and normalising;
    • lag;
    • bad lists, and the Markdown report.
  • One test for each false negative the first review demonstrated: dates and decades in prose, indentation, notebook code and kernel, SyntaxError and bare-warning outputs, a missing figure file, a broken target, a redirect stub, a launch link, a prose GitHub link, external links, structure, lag not covering warnings or lost files, a normalise entry's scope, and the shared PDF entry.
  • One test for each gap the delta review found, each checked against a mutation of the guard it pins: a same-class warning with a new message, a traceback header alone, a lost target on a lag page, a kernel change alone, an image outside _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.
  • One test for each point of the second delta review, which also found guards no test pinned (the host check, the subtraction of what the reference already lacks, the site address in a page's targets, the exit code without pyyaml); all 12 mutations of the new guards now fail a test: a site under a path (a lost figure; a moved one), a page in a folder, http and https, a candidate without a canonical, a URL broken in both builds, a URL inside an HTML attribute, a warning's values, a script that doesn't redirect, and pyyaml missing.
  • The affected-sites cases for the lists, and pool-check now allowing them.
  • Full suite: 609 passed, 1 skipped.

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.href but 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

…, 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
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Ready! (dp)

Preview URL: https://pr-129.qe-preview-dp.pages.dev

Commit: 3bb3e97


Build Info

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Ready! (programming)

Preview URL: https://pr-129.qe-preview-programming.pages.dev

Commit: 3bb3e97


Build Info

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Ready! (advanced)

Preview URL: https://pr-129.qe-preview-advanced.pages.dev

Commit: 3bb3e97


Build Info

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Ready! (intro)

Preview URL: https://pr-129.qe-preview-intro.pages.dev

Commit: 3bb3e97


Build Info

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Ready! (intermediate)

Preview URL: https://pr-129.qe-preview-intermediate.pages.dev

Commit: 3bb3e97


Build Info

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Ready! (jax)

Preview URL: https://pr-129.qe-preview-jax.pages.dev

Commit: 3bb3e97


Build Info

mmcky and others added 3 commits December 3, 2026 16:46
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
mmcky merged commit 6b6dee0 into main Dec 3, 2026
24 checks passed
@mmcky
mmcky deleted the site-compare branch December 3, 2026 07:09
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant