Skip to content
QuantEconPublic

About

QuantEcon lectures monorepo — a shared pool of lectures with per-product manifests, mirrored read-only from the six live series (under construction)

Resources

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

196 Commits

Folders and files

Repository files navigation

QuantEcon Lectures — monorepo

Status: being prepared — nothing here is published yet. The QuantEcon lectures still live at their individual series sites, linked below: read and cite those. This repository holds a shared pool of lectures mirrored from those series, and the tooling that keeps the pool faithful to them, while the move into this repository is prepared one series at a time.

This repository is the future single source of truth for the QuantEcon lecture series. The goal is to hold every canonical lecture exactly once in a shared pool, and to build each published series or course from a thin configuration that selects and orders pool lectures — never from a copy.

It sits downstream of six live lecture repositories until each one deliberately cuts over. What exists today:

  • The pool: 338 lectures in lectures/, promoted from the series together with the figures and files they use, each with its provenance recorded in sync/ledger.yml.
  • The mirror: every series' lectures, reconstructed on demand from commits pinned in sync/state.yml, which a daily job keeps current.
  • The drift-check: run after every sync, it proves each pool lecture still equals its source, opens a pull request to refresh the pool when a source moves, and opens an issue when another series' copy diverges.
  • The promote tool: it brings lectures into the pool and refuses a lecture name that two series use for different lectures.
  • The merged bibliography: one lectures/_static/quant-econ.bib, generated from the series' own files and the rulings in sync/bib.yml, and refreshed with the pool.
  • The assets report: after every sync, an audit of the files beside the lectures, in every series and in the pool, and a generated index of who uses each shared file, lectures/_static/_shared/README.md.
  • The sites: one folder per published site in sites/, each holding its series' _config.yml and _toc.yml verbatim with the few additions a build from the pool needs, its own pages and branding, and the fields the build workflow reads.

See The plan for what comes next.

Where the lectures actually live (for now)

Until each series is deliberately cut over, the live sites below remain authoritative. Read and cite those, not this repository.

Key Live site Source series
intro https://intro.quantecon.org QuantEcon/lecture-python-intro
programming https://python-programming.quantecon.org QuantEcon/lecture-python-programming
intermediate https://python.quantecon.org QuantEcon/lecture-python.myst
advanced https://python-advanced.quantecon.org QuantEcon/lecture-python-advanced.myst
dp https://quantecon.github.io/lecture-dp/ (a custom address to be discussed: QuantEcon/lecture-dp#2) QuantEcon/lecture-dp
jax https://jax.quantecon.org QuantEcon/lecture-jax

The four posture rules

These rules govern how this repository relates to the six live series until each one cuts over.

  1. Read-only, with stated exceptions. This repository only reads from the live series. Changes in the series themselves are limited to ordinary lecture maintenance, the renames that make every lecture name unique across the published sites (each with a redirect from the old address), and two merges that reconcile lectures two series share. Each is its own reviewed pull request in that series. A series receives the workflow that publishes it from here at its cutover and not before, and no engine or layout change is made in a live series before its own cutover.
  2. The live repos remain the source of truth. Each live series stays authoritative until a deliberate, per-series cutover moves it here. Nothing is migrated implicitly.
  3. After its cutover, a series is edited here. Until then, its lectures are edited in the series repository and reach the pool by sync. At its cutover, the pool becomes its source of truth.
  4. Shadow build, then cut over. Before a series moves, this repository builds it from the pool and compares the result with the series' own published build, with nothing going live. Each cutover is decided once the builds match.

The mirror → pool → sites model

The repository is organised around three layers.

Layer What it is State today
mirror/<key>/ A machine-reconstructed, verbatim copy of each live series' allowlisted paths, pinned to an exact commit. Never hand-edited, never committed. Reconstructed on demand; gitignored.
lectures/ The curated pool — every canonical lecture, held exactly once. 338 lectures and their assets, each recorded in sync/ledger.yml.
sites/ One folder per published site, each a thin configuration that selects and orders lectures from the pool. One per series, six in all, with the rules in sites/README.md; site-build.yml builds all six from them.

Why we commit only SHAs, not the mirror

mirror/<key>/ is a pure function of three inputs: the source repo, a pinned commit SHA, and the allowlist of paths to take from it (lectures/ and environment.yml). Because the mirror is fully determined by those inputs, we commit only the pinned SHAs (in sync/state.yml) and rebuild the mirror on demand. The repository therefore carries no heavy verbatim history, and the mirror can always be reconstructed byte-for-byte.

  • Human intent — which repos feed the mirror — lives in sync/manifest.yml.
  • Machine state — the exact SHA each series is pinned to — lives in sync/state.yml, written by the sync tool.

Directory layout

.
├── _base/            # what every site shares: update/environment.yml, the one pinned environment
│                     #   the sites are to build in (see _base/README.md)
├── lectures/         # the pool: every canonical lecture once
│   └── _static/      #   their assets: _static/<slug>/ per lecture, _static/_shared/ for shared files
│                     #   (with README.md, its generated index of users), and quant-econ.bib, the
│                     #   merged bibliography (bib-merge-written)
├── sites/            # one folder per published site: its _config.yml, _toc.yml, site.yml,
│                     #   own pages and branding (see sites/README.md)
├── mirror/           # reconstructed, verbatim, GITIGNORED — never committed
├── docs/tech/        # the technology register (see below)
├── CONTRIBUTING.md   # what runs on a pull request, and its previews
├── sync/
│   ├── manifest.yml  # human intent: which repos feed the mirror, each series' class, and its cutover mark
│   ├── canonical.yml # human intent: the winning series for a same-name collision
│   ├── bib.yml       # human intent: the rulings that settle the bibliographies' conflicts
│   ├── state.yml     # machine state: pinned SHAs (sync-written)
│   ├── ledger.yml    # machine state: provenance of every pool lecture and asset (promote-written)
│   └── toc.yml       # machine state: the watched _toc.yml baselines (drift-check-written)
├── tools/
│   ├── sync          # reconstructs the mirror from pinned SHAs
│   ├── promote       # promotes lectures + their asset closure into the pool; writes the ledger
│   ├── drift-check   # proves the pool still equals its sources; issues, refresh PR
│   ├── bib-merge     # merges the series' bibliographies into the pool's one file; checks it
│   ├── pool-check    # checks the pool keeps its layout conventions, and the environment lists what it installs
│   ├── assets-report # audits the files beside the lectures; writes and checks the _shared/ index
│   ├── affected-sites # which sites a change reaches: what a pull request or a push to main builds
│   ├── stage-site    # copies one site's pages, files, _config.yml and _toc.yml into lectures/ for a build, and out again
│   ├── site-matrix   # reads each built site's site.yml into the build workflow's matrix
│   ├── execution-report # after a build: what it executed or took from the cache, page by page
│   ├── stable-notebooks # after a build: each notebook's cell ids from its content, no build date
│   ├── notebook-links # after a build: a notebook's links to the site's own files at its address
│   ├── site-compare  # a monorepo site build against a series' own build, every difference classified
│   ├── consumer-expected # a consumer site's (dp's) expected differences, generated from its sources for site-compare
│   ├── shadow        # a shadow build's reference (the release, or the series' own build), lag, archives, environment delta and summary
│   └── tests/        # pytest suite for the tools above (scratch repos)
└── .github/workflows/
    ├── sync.yml         # daily job that refreshes the pinned SHAs (pin-only)
    ├── drift-check.yml  # runs after sync: drift issues, refresh PR (pool and bibliography), red on a pool edit or a refused refresh; the assets report
    ├── pool-check.yml   # runs tools/pool-check and the _shared/ index check on pull requests that touch the pool or the sites
    ├── publish.yml      # by hand: builds one site with site-build.yml and releases it in its target repository with the App's token (a test double until the site's cutover)
    ├── site-build.yml   # builds the sites it names (all six) from the pool, strict: HTML, notebooks and, for five, the PDF; keeps them and the execution report; previews each site a pull request reaches and builds (CONTRIBUTING.md says which pull requests); publishes nothing itself (publish.yml calls it)
    ├── shadow.yml       # by hand: builds one series' site with site-build.yml, stages it on Cloudflare Pages (dispatch-shadow) and compares it with the series' release, or its pages with the series' own build; writes nothing to a series or a live site
    └── tests.yml        # runs tools/tests on pull requests

Running the sync

tools/sync reconstructs the mirror and refreshes the pinned SHAs. It is a self-contained script run via uv — its dependencies are declared inline (PEP 723), so there is nothing to install first. Invoke it either directly (./tools/sync …, once the executable bit is set) or through uv (uv run --script tools/sync …), which needs no executable bit.

The tool never commits anything; committing a refreshed sync/state.yml is CI's job.

Command What it does
tools/sync Reconstruct every series into mirror/<key>/ at its already-pinned SHA.
tools/sync dp Reconstruct only the dp series. Any subset of keys works.
tools/sync --update Re-resolve each series' HEAD, re-pin the SHA (with a UTC timestamp) into sync/state.yml when it has moved, then reconstruct.
tools/sync --update --pin-only Re-resolve and re-pin SHAs but skip reconstruction — no downloads. This is what CI runs.
tools/sync --update dp jax Re-pin and reconstruct just dp and jax.
tools/sync --boundary dp Print a cut-over series' page-history boundary: its mark's pin, and the commit that added the mark.
tools/sync -h Full help.

A series' pin (and its timestamp) is only rewritten when the upstream HEAD has actually moved, so a re-pin run over unchanged series leaves sync/state.yml untouched. If a series has no pinned SHA yet, a plain tools/sync reports a clear error and suggests running --update first. Failures are per-series: the tool logs each and carries on, then prints a PASS/FAIL summary and exits non-zero if any series failed.

Each mirror records the commit it was taken at, in mirror/<key>/.pin (beside its lectures/, so no reader of the mirror sees it), written only once the checkout succeeds. tools/promote and tools/drift-check refuse a mirror whose .pin is not its pin in sync/state.yml, so nothing is promoted or checked against a mirror that lags its pin: after updating to this version, run tools/sync once to rebuild the mirrors with it.

A series that has cut over keeps its stanza in sync/manifest.yml, marked cutover: {date, pin} by tools/promote --switch (below): the UTC date of the switch and the commit the pool was taken at. The sync never re-pins it (--update and --pin-only say so and leave its pin as it is), and rebuilds its mirror only when its key is named, at its frozen pin: a run that names no keys, as CI's do, leaves it alone. Only a re-run of tools/promote --switch reads that mirror (run tools/sync <key> first); no other tool does. The mark's pin never changes; if a later pin is accepted (the merge-window case under tools/promote --switch), it is added as accepted: {pin, date}. The name pool is reserved, and no series may take it.

The page-history boundary of a cut-over series (QuantEcon/quantecon-book-theme#488) comes from these records, one per side. The series side is the mark's pin: a page's history in the series repository runs up to and including it. The monorepo side is the commit on main that added the series' cutover: line, the cutover pull request's merge commit: a page's history here runs from it. tools/sync --boundary SERIES finds that commit in sync/manifest.yml's history: the most recent commit on the first-parent line at which the series' own cutover.pin, read by parsing the manifest there and at its first parent, became the mark's pin. So a later accepted field, a comment quoting the pin or another series' mark never moves it, and a mark merged from a branch is found at the merge commit, not the branch's. It prints both sides with the commit's date in UTC, and exits 2 on a shallow clone, which lacks the history, or when git cannot read that history (a partial clone offline, say).

Promoting lectures

tools/promote copies lectures from the mirror into the pool together with their asset closure — the figures, includes and data files a lecture actually references — and records where each came from in sync/ledger.yml. Asset references are rewritten to the pool's _static/ layout, and every rewrite is recorded, so the pool copy can always be reproduced from its source. Like the other tools it is a self-contained uv script, and it never commits anything or touches the mirror.

Command What it does
tools/promote SLUG … Promote the named lectures, each from the highest-priority series that holds it.
tools/promote --toc SERIES Promote every lecture in a series' _toc.yml. For a consumer series (dp), each lecture comes from its home series.
tools/promote --refresh Re-promote every entry whose canonical series has moved since it was promoted. CI adds --exclude $PROMOTE_EXCLUDE when that list names a series; it is empty now that every series is promoted.
tools/promote --retire SLUG … Take the named lectures out of the pool: the pool file and its ledger entry, with the assets no other pool lecture uses. A lecture the pool owns is retired this way once no site's _toc.yml lists it.
tools/promote --switch dp Cut a consumer series over: mark its stanza cutover:, and remove its superseded copies, their pins and its toc watch. No lecture changes.
tools/promote … --exclude SERIES … Leave the named series out of this run.
tools/promote … --dry-run Print the full plan without writing anything.

tools/promote refuses a lecture name held by two canonical-eligible series with different text, naming the lecture and every series involved. It does not pick a winner by run order. A rename or merge upstream fixes it; until then, sync/canonical.yml can name the winning series, and the entry is recorded as interim. A copy that is merely stale (a recorded source still at a version the pool already took, while the canonical copy moved on) is not a collision: it stays a source, and the refresh goes through. A sync/canonical.yml line that names such a stale copy is refused, though, since following it would take the pool back to the lagging text, so delete a line as soon as promote reports that it settles nothing.

A lecture renamed or removed upstream

A pool lecture whose canonical copy is gone upstream is reported by the drift-check as canonical-removed. The daily refresh skips it and refreshes the rest; it never removes a lecture. The lecture leaves the pool by being retired:

  • tools/promote --toc SERIES retires, on its own, each entry canonical in SERIES whose lecture has left that series' _toc.yml, whose canonical copy is gone, and whose name no series in the manifest still holds. A renamed lecture is retired under its old name and promoted under its new one by the same run. At most five lectures are retired this way in one run: more than that retires none and fails, naming them, since a toc or folder lost upstream by mistake must not empty the pool.
  • tools/promote --retire SLUG … retires by name, for anything the rule above leaves alone, such as a lecture a consumer series still holds. It refuses a lecture its canonical series' toc still lists, and a lecture the pool owns while a site's sites/<key>/_toc.yml lists it.

Afterwards re-accept the toc with tools/drift-check --accept-toc SERIES. --toc only ever retires an entry canonical in the series whose toc it reads, so it never touches a lecture the pool owns (canonical: pool, below); --retire takes one by name. Git history and the run's summary are the record of a retirement.

Cutting a consumer over

tools/promote --switch SERIES is the tooling step of a series' cutover (QuantEcon/project-monorepo#104). For a consumer (dp), which owns no lecture, it writes the mark, one line at the end of the series' stanza in sync/manifest.yml with every comment kept (cutover: {date: 'YYYY-MM-DD', pin: <its pin in sync/state.yml>}, the date in UTC), removes every superseded copy and promoted_at pin the ledger records for it and its watch in sync/toc.yml, and changes no lecture: dp: 49 superseded copies and 49 pins removed, toc watch removed, cut over at afb26eabaf2d668a9b0a0476ef84119e5acefe12 (…); no lecture changed. --dry-run prints that and writes nothing. If the stanza is not in the plain layout it edits (a stanza on one line, a mark over several lines), it writes nothing and prints the line to add by hand; its next run checks it. The switch for a series that owns lectures, which makes the pool their source of truth, comes in a later release of the tool, and until then it is refused.

From then on a cut-over series is in no run: promote never reads or records its copies, and --toc or --exclude naming it is a usage error. Before it plans anything, every run checks that the records agree with the marks: a marked series holds no ledger row (a copy, a pin, an asset's record), is no sync/toc.yml key and is named by no sync/canonical.yml line, and every switched lecture's switched_at names a marked series (a file's need not: below). Anything else stops the run, naming each record, and tools/promote --switch SERIES brings it into step. It also completes a mark written by hand, provided the mark names the series' pin in sync/state.yml (or its accepted pin): while the series' records remain, a mark naming any other pin is refused as most likely mistyped, and nothing is written, since a re-run would accept the real pin beside the typo and make the typo the page-history boundary for good. The refusal names both full SHAs and each remedy, among them the one for a mark that is right, switched before its pin moved, whose records a pull request from before the cutover brought back: once tools/sync --boundary SERIES shows the mark was already on main and git log -p -- sync/ledger.yml sync/toc.yml shows the records removed and back, remove those records by hand (the drift-check lists each) and re-run the switch, which accepts the new pin.

The switch can be run again. While the series' pin in sync/state.yml is the mark's, a re-run changes nothing. If the pin moved after the switch, which can happen only if the nightly sync ran between the cutover pull request's last regeneration and its merge, the drift-check reports cutover-pin, and a re-run (after tools/sync SERIES) records the new pin as accepted: {pin, date} beside the mark, whose pin never changes. To regenerate the cutover pull request on the day: git checkout origin/main -- sync/ lectures/, tools/sync, then tools/promote --switch SERIES; the pull request carries sync/manifest.yml, sync/ledger.yml and sync/toc.yml and nothing else.

Lectures the pool owns

Once a series that owns lectures cuts over, its lectures are the pool's: their ledger entries say canonical: pool, with switched_at: {series, pin, date, digest, pool} (the series, its pin, the UTC date, its copy at the pin and the pool file then). A lecture written in the pool after its series' cutover is recorded the same way with added_at: {date}. People edit these by pull request to lectures/, and promote never writes their text (the switch that creates them for a series that owns lectures comes in a later release of the tool; QuantEcon/project-monorepo#104).

  • Never promoted over. --refresh never refreshes a pool lecture, never pulls one into a batch and does not count it. Promoting one by name is refused (lectures/mccall.md is canonical in the pool (switched from intermediate on …): promotion would overwrite it). --toc of a consumer skips it; --toc of a series that owns lectures skips a copy that is the same lecture (its recorded copy, the text the pool was made from, or the pool's text once the entry's rewrites are applied or its asset paths normalised) and refuses a different lecture under the name as a same-name collision, which a rename upstream settles.
  • Read from its text. Wherever promote counts a file's users, a pool lecture's are what its text uses, not what its record lists. It counts towards whether a file is shared, so a file it shares with a lecture from a series stays in _shared/; it sees the new version when that series changes the file; a file it uses is never pruned; and a run that would move a file it uses is refused, naming it (pool-check's asset-owner rule asks a pool lecture for a copy of its own instead of another lecture's file).
  • Files follow their users. A file is guarded (its record names a series, and the drift-check compares it) while any lecture from a series uses it, and the pool's (canonical: pool) once only pool lectures do, with switched_at naming the series whose version the pool kept, which need not have cut over. A file a pull request adds for a pool lecture is the pool's from the start, before the refresh records it. A lecture from a series never joins a file the pool owns: one that brings the same bytes gets its own copy at its own pool path (#16), and one whose copy would take the pool's path is refused, to be renamed upstream. Promote never writes the bytes of a file the pool owns, and removes one only with a pool lecture --retire takes.
  • Records follow the pool. Whenever promote writes the ledger, a pool lecture's assets become what its text uses, each file's regime follows its users, a file the pool owns that no lecture uses and whose file is gone loses its record, a file a pool lecture uses that has no record is recorded as the pool's (added_at), and a lectures/<slug>.md with no entry that a cut-over series' sites/<key>/_toc.yml lists is recorded as a pool lecture. The nightly refresh writes these even when no pin moved, so a pull request that edits a pool lecture needs no new command: the drift-check reports the stale record as pool-record, and the next refresh pull request carries it.
  • Retired by name. tools/promote --retire SLUG takes a pool lecture once no site's _toc.yml lists it, with the files the pool owns that no other lecture uses. --toc never retires one.

A file that lectures share

The pool keeps one copy of an asset, used by every pool lecture that refers to it, while the series those lectures come from each carry their own. Today that is the _admonition/gpu.md include (55 lectures from three series), duopoly_mpe.py (a lecture from intermediate and one from advanced) and the four arellano figures (advanced and jax). An asset's ledger record lists as sources its copies in the series its user lectures come from, and only those: a series that merely has a file of the same name is not watched.

  • One series changes the file first. When a series whose copy was the pool's version changes it, the refresh takes the new version for every lecture that uses the file, whether or not those lectures are in the refresh. The other series' copies are recorded on the asset as stale, each with its own digest and a stale_since time. The drift-check reports a stale copy as information for seven days and as drift, with an issue, after that; the copy is current again at the first refresh after its series makes the same change (the drift-check asks for that refresh, as asset-caught-up, so the record never goes on calling a copy stale that has caught up).
  • A different file under the same name. A copy that was never the pool's version, because it already differs when it is first seen, is not a lagging copy. It is recorded on the asset with differs: true, reported as information (differing-copy), and never followed; a lecture that comes only from that series and uses the name gets its own series' file, at its own pool path.
  • Only copies behind a lecture count. A series' copy is followed while its copy of a user lecture is still the lecture the pool recorded. If that lecture copy is edited to differ, the drift-check reports the lecture, and the series' copy of the file is not followed until the lecture is settled.
  • What is refused. Two series that change the file differently; a stale copy that changes to anything but the pool's version (a copy that is behind may only catch up); a copy in a series not yet recorded that differs; and overwriting or moving a shared pool file that was edited by hand (a lecture's own file, with nothing else changing, is restored by re-promoting that lecture).
  • Lectures that share a file stay together. A shared file is never split across two pool paths: a lecture outside the batch counts as a user of the version the batch brings. When a file's pool path must change, because a second lecture starts to use it, promote pulls the lectures that already use it into the batch and re-promotes them with it; if one of them cannot be re-promoted, the lecture that needed the move is refused too, with the reason.
  • Two lectures that bring different bytes to one new pool path are both refused, naming both, whatever order they were given in.

One consequence of keeping a single file: a lecture whose own refresh is refused keeps its old text while a file it shares moves on with the lectures that did refresh. For a .py file a lecture loads, that pairs text and code no series published together, until the refused lecture is settled.

Running the drift-check

tools/drift-check proves the pre-cutover invariant: every pool lecture equals its canonical mirror copy modulo the rewrites recorded in sync/ledger.yml, and every other series' copy is where the ledger last saw it. Like tools/sync it is a self-contained uv script. It never writes to the pool or the mirror: the only repository file it writes is sync/toc.yml, under --accept-toc; --json writes its report wherever you point it, and under GitHub Actions it appends step outputs.

Command What it does
tools/drift-check Report against the existing mirror/. Exit 0 clean, 1 findings, 2 a pool file was edited directly.
tools/drift-check --reconstruct Rebuild mirror/ first, for every series the check reads: every canonical-eligible series, and a consumer whose toc is watched.
tools/drift-check --print-issues Show the issues --issues would open, without touching GitHub.
tools/drift-check --issues Open, update and close drift issues to match the findings (CI).
tools/drift-check --accept-toc dp Record a series' _toc.yml at its current pin as the watched baseline. It refuses a cut-over series.

Four outcomes: refresh (the canonical copy moved upstream; CI runs promote --refresh and opens a pull request; an entry the refresh refuses is listed with promote's reason, in that pull request when one is opened and always in the red run's refresh step; the usual reason is a same-name copy edited to differ, which sync/canonical.yml or upstream settles; while the entry's canonical copy differs from its ledger record the run stays red every night until it is settled, and a settlement applies the next night), drift (a non-canonical copy diverged from its canonical home, a copy was removed, a watched toc changed or lists a lecture the pool does not hold, or two published sites hold different lectures under one name, or a site's copy of its series' files no longer matches them, site-stale, described in sites/README.md; each becomes an issue that closes itself when the finding clears), violation (the pool itself was edited; the job goes red), and info (a copy is merely stale, or a divergence converged). drift-check.yml runs it after every sync.

Every mirror the check reads must be at its pin (mirror/<key>/.pin); otherwise it stops with an error, and --reconstruct rebuilds them. A cut-over series (marked cutover: in sync/manifest.yml) is no longer compared with anything: its mirror is not needed, and its toc, its lecture names and its site folder are not read. Two checks take their place, neither reading a mirror: a record that disagrees with the marks (as tools/promote checks them) is a violation, cutover-record, naming the record and tools/promote --switch SERIES; and a cut-over series whose pin in sync/state.yml is no longer the mark's is drift, cutover-pin, whose issue asks for tools/sync SERIES and tools/promote --switch SERIES.

A lecture the pool owns (canonical: pool) is edited here, so no series' copy is its reference, and a file the pool owns is not compared with its record. Instead: its file must be there (pool-missing, a violation, whose remedy is to restore it from git or tools/promote --retire SLUG); its record must list what its text uses, each file recorded, a file only pool lectures use must be recorded as the pool's, and a file the pool owns that is gone and unused must have no record (pool-record, a refresh finding the nightly refresh clears); a file the pool owns must be there while a lecture uses it (asset-missing, a violation: restore it from git, or take the reference out); and no lecture from a series may list a file the pool owns (regime, a violation). A lectures/<slug>.md with no ledger entry is pool-unrecorded: a refresh finding when a cut-over series' sites/<key>/_toc.yml lists it, which the refresh records, and otherwise a violation, since no record or check would cover it; a site page (intro, status and the rest of promote's SITE_PAGES) is always a violation, since a site keeps its pages in sites/<key>/. The record findings print under their own heading, REFRESH (RECORDS), since no series moved. Other series' copies of a pool lecture are compared in a later release (QuantEcon/project-monorepo#104).

One kind of copy is never watched. A consumer series (class: consumer in sync/manifest.yml, today dp) only republishes other series' lectures, so its copies are recorded as superseded and are expected to go stale. Its _toc.yml is watched, though: the pool's dp selection is promoted from it, so a change there means re-running that promotion with the refresh's exclusions (PROMOTE_EXCLUDE in drift-check.yml; today empty, so tools/promote --toc dp), then --accept-toc dp. Accepting alone clears that issue but leaves a newly listed lecture out of the pool, which the check then reports as toc-unpromoted.

Lecture names are unique across the published sites, not only in the pool: a link that leaves a site resolves by name, so two sites that publish different lectures under one name send readers to the wrong one. The check reads every canonical-eligible series' _toc.yml, whether its lectures are in the pool yet or not, and a name two of them list must be one lecture in both, by promote's rule (name-shared). A consumer's toc is not read for this: it only republishes.

Checking the pool's layout

tools/pool-check checks that the pool keeps the layout tools/promote writes, whoever edits it next. lectures/ holds lectures (<slug>.md, no name starting with _, no two names that differ only in case) and _static/. Every folder at the top of _static/ is a lecture's own (_static/<slug>/, beside <slug>.md) or _shared/, and the merged bibliography is the one file there. A file in _static/<slug>/ is used by <slug>.md alone, so an asset two lectures use goes in _shared/. Every asset reference is file-relative (_static/<slug>/fig.png, never /_static/...) and stays inside lectures/. Every {doc} link resolves: a plain target names a pool lecture or a site page, and a prefixed one (intro:cobweb) has a series key from sync/manifest.yml as its prefix and, after it, a site page or a pool lecture that series holds by the ledger (for a cut-over series, which the ledger no longer records, a lecture its sites/<key>/_toc.yml lists). Three older prefixes (dynam, pyprog, tools) are accepted until the cross-reference policy settles what a link that leaves the site is written as. So a refresh that brings in a link to a lecture the pool does not hold yet fails this check until that lecture is promoted. It finds asset references with promote's own parser and {doc} links with its own pattern (text in code cells, literal blocks, inline literals and comments is not read as a link), reads lectures/, the series keys in sync/manifest.yml and the ledger's record of which series hold a lecture, and needs no mirror. Every reference of a kind promote's closure must resolve (a figure, an image, an include, a :load:, a download, a raw HTML link) names a file in the pool (ref-missing); the kinds found by pattern alone (a markdown link, a quoted string in code, a published address) are not read as a file unless one is there. So a refresh that would prune a file a pool lecture uses fails here, and so does a pull request that renames a figure but not its reference. When the lecture that uses another lecture's _static/<slug>/ file is one the pool owns, asset-owner asks it to take a copy of its own in its own folder, since promote, not a person, moves a guarded file. A {ref} link that leaves its site has one target: a label that two of the pool's sites a site maps both define is reported (ref-target), since intersphinx would send the link to whichever name sorts last (QuantEcon/project-monorepo#22). Exit 0 clean, 1 a rule broken, 2 an error.

It also counts the labels that more than one pool lecture defines, targets ((name)=, :name:) and equation labels (:label:, $$ … $$ (name)) apart, and tools/pool-check --labels lists them. That is information, never a failure: labels must be unique within a site, which is checked where a site is built.

It checks the sites too, so each folder in sites/ stays true to the pool: every entry in a site's _toc.yml is a pool lecture or a page of the site; a site page never has a pool lecture's name, and no file under a site's _static/ is a pool file, since staging would overwrite it; the branding a site's _config.yml names is in the site; the site sets only_build_toc_files: true, its own execution cache (_build/jupyter_cache/<key>) and intersphinx_disabled_reftypes: [], maps no consumer series and, unless it is one, maps itself; and site.yml has the fields the build reads, each with a valid value. The rules and the fields are in sites/README.md. pool-check.yml runs it on every pull request that touches the pool or the sites. Run it with no site staged: a staged site's pages in lectures/ read as pool lectures.

And it keeps the one environment the sites are to build in, _base/update/environment.yml, whole: every package a pool lecture's code cells install (!pip install, %pip install, !conda install, and the other forms its docstring lists) is listed there, pinned to one version that a pip install line's own version limit allows, and every entry is pinned to one version, once. So a refresh that brings in a lecture installing a new package turns this check red (a red check, since main has no branch protection) until a person pins it there, in a pull request of its own to main. It also counts, as information, the installs in executed cells that would replace a pin during a build (--upgrade, -U, a conda install), and tools/pool-check --installs lists them. Why the list is pinned, where each pin comes from, and how to add one, is in _base/README.md.

The assets report

tools/assets-report is the audit of static assets, regenerated after every sync rather than written once. drift-check.yml runs it on the mirror the drift-check rebuilds and puts the report in the run's summary and in an assets-report artefact (Markdown and JSON). It is information and never fails that run. It reports:

  • Per series (every series but a cut-over one, whose mirror is no longer rebuilt), every file under the series' lectures/ that is not a lecture or its _config.yml or _toc.yml: used by a lecture (by promote's parser, including through an include), linked by address (a lecture links to it in the series' own repository on GitHub), used by the configuration (named in _config.yml, branding, or the bibliography), or orphaned. Orphaned figure sources are counted apart: a .tex, .gv or .dot file, a file named like an image a lecture uses in the same folder, less the extension, or a notebook in a folder that holds such an image.
  • Collisions: one path in two or more series with different bytes.
  • The largest files, the candidates for trimming a dataset.
  • The pool: every file under lectures/_static/, the lectures that use it (by its text, or by the asset list in its ledger entry), the orphans and the _shared/ files one lecture alone uses. Files under a name starting with ., such as .DS_Store, are not the pool's and are skipped.
  • Files on GitHub, by address: every link in a pool lecture to a file on GitHub, by repository and the ref it names. Most are data the lectures read from QuantEcon/data-lectures on its default branch; a link into a series' own repository breaks if the series moves the file at its cutover.

It also writes lectures/_static/_shared/README.md: for each shared file, the pool lectures that use it and the sites that publish them, by each site's sites/<key>/_toc.yml (what is published, so a series' cutover, which drops its copies from the ledger, changes nothing there). GitHub shows it under the folder, so whoever changes a shared file sees what it reaches. It is generated, never edited by hand: pool-check.yml regenerates it and fails a pull request whose copy differs, and fails on an orphan, a file under _static/ that no pool lecture uses. Its path is reserved: if the ledger records an asset there, the tool stops with an error. A _shared/ file that one lecture alone uses is listed, not failed: promote places a family folder's files and the _admonition/ includes there whatever their count. The nightly refresh regenerates the index with the pool; after promoting by hand, run tools/assets-report --write-index and commit the result.

Command What it does
tools/assets-report Print the report as Markdown. It needs the mirror.
tools/assets-report --out report.md --json report.json Write the report to files.
tools/assets-report --reconstruct Rebuild mirror/ first.
tools/assets-report --write-index Regenerate lectures/_static/_shared/README.md. It reads the pool, the ledger and the sites' tocs only.
tools/assets-report --check-index Exit 1 if the index is stale or missing, or the pool holds an orphan; 0 clean, 2 an error.

The sites

Each published site is a folder in sites/: its series' _config.yml and _toc.yml, verbatim but for the additions recorded there, its own pages (intro, status and the like, which are never pool lectures), its branding, and site.yml, the fields the build workflow reads (type, runner class, cell_timeout, the per-cell execution limit, what it publishes, its address). A site is built from the pool after tools/stage-site copies its own pages and files, its _config.yml and its _toc.yml into lectures/, since Sphinx reads only inside its source folder:

Command What it does
tools/stage-site dp Copy dp's pages, _static/ files, _config.yml and _toc.yml into lectures/, recording what it copied in _build/stage-site.json. It refuses, copying nothing, if any destination already exists, or if a site is staged already.
tools/stage-site --local-links dp The same, and, for a consumer site, rewrite its links to lectures it carries into links within it, keeping each rewritten lecture's original under _build/stage-site-originals/ (sites/README.md).
tools/stage-site --clean dp Remove them again: only the files the record lists, each while its bytes are still the ones copied, then the record; and put back each lecture --local-links rewrote, while its bytes are still the ones staging wrote.

site-build.yml builds the sites it names, today all six, on every push to main and pull request that touches the pool, the sites, the tools a build runs or the environment list in _base/, on demand and twice a week. A pull request or a push builds only the sites its change reaches (tools/affected-sites), and the schedule and a manual run build all six. A push is compared with the last build on main that succeeded, so a run that was cancelled or failed leaves nothing unbuilt. Each site is a leg of one matrix whose runner, container and time limit tools/site-matrix reads from site.yml. A leg builds in the site's environment: dp in its series' own image, with the site's extra_packages (jax) installed; intro and advanced in the full image with the one package list, _base/update/environment.yml, applied; programming, intermediate and jax on a RunsOn GPU machine with the same base and list, and jax[cuda13] (see _base/README.md). It stages the site, builds its HTML strictly (-n -W --keep-going) with QuantEcon/actions' build-lectures, restoring and, on main, saving the site's own execution cache; builds the notebooks and the PDF the site publishes, strictly too, reusing the HTML build's Sphinx environment, so they execute nothing; and keeps the HTML, with those in it, and the execution report as artefacts. On a pull request, a third job deploys each site whose build succeeded as a preview on Cloudflare Pages, at https://pr-<number>.qe-preview-<key>.pages.dev, with one comment per site; the preview leaves the PDF out, and a pull request from a fork gets none (CONTRIBUTING.md). It publishes nothing. A pull request only restores the cache, so until main has saved one, every build executes every page.

shadow.yml runs a shadow build (QuantEcon/project-monorepo#80), by hand from main, for one of the five series that own lectures, never dp: it builds the site with site-build.yml as publish.yml does, stages it at https://dispatch-shadow.qe-preview-<key>.pages.dev, and compares it with the series' release (a tag, or its newest with a manifest), or, given a run of the series' own cache.yml (the owner's choice of 2026-12-04), its pages with that build and its notebooks and PDF with the release, each with its own lag. A defect is a result, not a failure: the run's summary and its shadow-<key> artefact, kept 90 days, hold the report, the lag and the environment delta. It refuses a consumer, a series marked cutover: and a release the monorepo published, and writes nothing to a series or a live site.

Command What it does
git diff --no-renames --name-only -z BASE HEAD | tools/affected-sites -z --base BASE dp intro Print the sites, of those named, that the changed paths reach. --no-renames lists a renamed file by its old name as well as its new one, and -z keeps a name git would quote. A lecture or its own _static/<slug>/ reaches the sites whose _toc.yml lists it, and a _shared/ asset the sites of the lectures the ledger says use it or whose text names it (a pool lecture's record can lag its text until the nightly refresh). A site's own file reaches that site. tools/sync and sync/state.yml reach the sites in the series environment (today dp), the only ones that run tools/sync; a change to sync/manifest.yml that only adds, changes or removes cutover: marks reaches the marked series' own sites (with --base); and any other build input (the bibliography, a build tool, _base/, any other change to sync/manifest.yml, the workflow) every site. Anything else reaches none. With --base, a lecture a change drops still reaches the sites that listed it, and a shared asset its old users' sites.
tools/site-matrix dp Print the matrix entry for each site named, as JSON. It refuses a site whose runner class or type has no leg yet.
python tools/execution-report --since "$since" --site dp After jb build, write _build/execution_status.json: one row per page the build executed or took from the cache, with its status, seconds, kernel and which of the two. Run it with the Python that ran the build: it reads Sphinx's environment.
python tools/notebook-links --site dp _build/html/_notebooks After the notebooks build, and before stable-notebooks, write each notebook's relative links to the site's own files (_static/<slug>/…, which promote's rule 7 makes relative) at the site's address, site.yml's url, so they work in a notebook opened in Colab or downloaded (#45). Code cells and other links are left alone.
python tools/stable-notebooks _build/html/_notebooks After the notebooks build, give each cell an id from a hash of its type and source (a repeated cell gets -2, -3, …) and drop metadata.date, so an unchanged lecture gives a byte-identical notebook every build and a release changes only the notebooks whose lectures changed (QuantEcon/project-monorepo#149).
python tools/site-compare REF CAND --site intermediate --expected sites/compare-expected.yml --lag newton_method Compare a series' own build (REF) with the monorepo's build of the same site (CAND, the html-<key> artefact) and classify every difference as expected (an entry of sites/compare-expected.yml or sites/<key>/compare-expected.yml, with its reason), lag (a lecture changed since the reference's commit), defect or reported-only (output values, figure pixels). It also compares the PDF book section by section, and with --gpu (a GPU site) blocks a page that fell back to the CPU. Writes report.json and report.md; exits 1 on a defect (QuantEcon/project-monorepo#26).
python tools/consumer-expected --site dp --out dp-generated.yml For a consumer site (dp), write the expected-difference list its comparison needs, from the sources: each lecture whose dp copy lags the pool's (after setting aside the pool's asset layout and cross-references' series prefixes), on the checks its change can reach (never warnings, files, link targets or launch links); a link whose series prefix differs, to a lecture the site carries, at its two addresses; the labels the monorepo's build loses; a lecture the site adds (mccall_risk), the root page's contents and the chapter numbers it moves, each mapped from the series' number to the site's (site-compare's renumber), so a number left behind in a page's text or notebook still blocks (one in a cell's output is only reported, and a lagging lecture's page is covered by its lag entry); the general index's terms that differ. Run tools/sync dp first; pass the file to site-compare with the shared list and sites/dp/compare-expected.yml. Not kept: regenerate it for each comparison.
uv run --script tools/shadow release --site programming --shadowed "$SHADOWED" --tag publish-2026oct12 --run 46345650663 --meta meta.json, then lag, extract, extract-build, merge, env and summary What shadow.yml runs around the build and the comparison: release refuses a run that is never shadowed and records the release's commit, the series' pin and, with --run, the series' build; lag lists the lectures changed between each reference's commit and the pin (site-compare's --lag), the series' other changes, and the pool lectures promoted at an older commit; extract and extract-build check an archive against its checksum or GitHub's digest and unpack it with nothing outside its folder; merge joins the two comparisons, each difference judged once; env and summary write the environment delta and the run's summary. release, lag and env read GitHub (gh api, and git for the series' trees).

sites/README.md has the jb build command, the build in CI and its cache, the execution report's fields, every deviation from the series' files and why, and the cross-reference rules.

Running the bibliography merge

tools/bib-merge builds the pool's one bibliography, lectures/_static/quant-econ.bib, from the quant-econ.bib of each series listed in sync/bib.yml. A consumer series such as dp is never a source, and the tool refuses one that is listed: its lectures are copies of other series' lectures, and its bibliography is a copy too. Each series' copy of an entry is normalised to the house style's mechanical rules (Writing a bibliography entry): page ranges with --, no month, a bare DOI, no fields a reader never sees, one field per line. Nothing else in a value changes. Copies that then agree are merged into one entry. Copies that still differ are a conflict, and sync/bib.yml must rule on it: which series' copy to take, any fields to set or drop, why, and a seal recording each copy as it was. If a series later edits a sealed copy, the copy the ruling takes included, the ruling reopens; the change is never folded in silently. The file is generated, never edited by hand: its header records digests of the series' entries, of sync/bib.yml and of its own entries, so the check tells a series that moved (a refresh) from a hand edit or a ruling that was not regenerated (a violation).

Command What it does
tools/bib-merge Regenerate in memory and check. Exit 0 clean, 1 the series' files moved (run --write), 2 a refused key, a failed check, or a committed file that differs from what the same inputs generate.
tools/bib-merge --write Write lectures/_static/quant-econ.bib.
tools/bib-merge --report Print every conflict side by side, with its ruling or why it was refused.
tools/bib-merge --propose Print a sync/bib.yml stub, sealed against the current copies, for every refused key.
tools/bib-merge --reconstruct Rebuild mirror/ for every series but a cut-over one first.

Its checks: every key a pool lecture cites resolves (in the nightly check, --refresh-follows makes one exception: a key cited only by lectures whose canonical copies have dropped the citation upstream is information, because the refresh that follows removes it and the write after it checks again); the entries keep the house-style rules the normalising cannot apply (the fields each entry type needs, names joined by and, keys unique when case is ignored); and pybtex, the reader Jupyter Book 1 uses, reads every merged entry as it reads the series copy it came from. It reads the series' files exactly or refuses them: a syntax error, a duplicate key or field, @string, a # concatenation, or a file in which bibtexparser and pybtex find different keys stops the run, and nothing is written that does not read back as the same entries. drift-check.yml runs it after every sync and refreshes the file into the same pull request as the pool; anything it fails on turns that workflow's bibliography job red, which never holds back the pool's refresh.

The technology register

docs/tech/ is a standing record of technology options for improving the lectures: what was looked at, the named files where it would apply, and what was decided and why. An entry is not ready until it names the files it would change; its README sets out the format and the states an entry moves through.

The plan

The move is planned in ten stages: reorganise first on today's toolchain (Jupyter Book 1), then switch the engine once, later. Since 2026-11-27, stages 1 to 8 move every series onto this repository on Jupyter Book 1, which makes validation against the live sites easier. Stages 9 and 10 are a second phase: an upgrade of the live sites to mystmd, once this repository publishes them.

  1. Set up access and tracking.
  2. Sources in. Bring every lecture of every series into the pool, reconciling differences in the series repositories.
  3. One publishing workflow that builds any site on Jupyter Book 1, rehearsed end to end, including a rollback, on a sandbox series. The engine input comes with mystmd, in the second phase.
  4. Shadow builds. Build each series here from the pool and compare it with its own published build, with nothing going live.
  5. Cutovers, one series at a time. Each series is published through a release in its own repository, so every earlier release is a rollback.
  6. The order of cutovers: dp (a publishing-only move, since it owns no lectures), programming, a go/no-go review, then intro, intermediate, advanced and JAX.
  7. A relay that keeps the translated editions fed from here.
  8. Page history, carried across at each cutover.
  9. mystmd, after the cutovers: every site built on mystmd, publishing nothing, as the second phase's first step (2026-11-27; it was "mystmd builds alongside", from stage 3).
  10. One engine switch for all series and editions together, after full testing: the end of the second phase.

As of 2026-12-03, stage 3, the publishing pathway, is complete. Every site builds from the pool in CI on Jupyter Book 1, with its notebooks and, for the five that publish one, its PDF, and a pull request previews each site it reaches and builds, except a fork's or Dependabot's (CONTRIBUTING.md, "Previews"). publish.yml publishes a site through a release in its target repository, rehearsed with a rollback on the test double. Stage 4, the shadow builds, is under way: a site built here is compared with the series' own build, every difference classified (QuantEcon/project-monorepo#26), and shadow.yml runs that comparison by hand for a series (QuantEcon/project-monorepo#80).

Licence

To be confirmed; the mirrored content remains under the licences of its respective source series until cutover.

About

QuantEcon lectures monorepo — a shared pool of lectures with per-product manifests, mirrored read-only from the six live series (under construction)

Resources

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages