Skip to content

Stale-asset republication: default templates to cache-type execution, or prune html inside restore-jupyter-cache #160

Closed

Description

@mmcky

The bug class the templates would carry into the migration

Restoring a full _build and building over it republishes files that have been deleted from source. Sphinx copies html_static_path assets into _build/html/_static but never removes ones that no longer exist in source, so a dataset or asset deleted on Tuesday keeps being served by every preview and publish that restores Monday's cache — until a clean cache rebuild happens to intervene. This is not hypothetical: it made deletion verification unreliable across the Track C dataset migration, and QuantEcon/workspace-lectures#41 is currently rolling a consumer-side jb clean . --html step across 9 lecture repos as the fix for the dawidd6-artifact world (validated live in QuantEcon/lecture-python-advanced.myst#374 — a restored cache that physically contained three deleted files produced a preview that 404'd all three while serving controls at 200).

The migration surface here inherits the same bug: templates/ci.yml pins cache-type: 'build' (full _build, html included), and neither restore-jupyter-cache, build-lectures, nor the docs prune or mention stale assets. A repo cutting over by template today lands back in the pre-fix state, and the per-repo workflow prune steps from the rollout would be removed at exactly that moment.

The structural fix is already half-built

restore-jupyter-cache supports cache-type: 'execution' (.jupyter_cache only). Run that way, every consumer rebuilds _build/html from its own checkout: the stale-asset class cannot exist, no prune is needed anywhere, and the guarantee is immune to which vintage of cache gets matched (relevant because prefix-matching means an old entry can be restored silently). The restored html contributes nothing to build speed anyway — a fresh checkout's mtimes force Sphinx to rewrite every page — so the real cost of execution-only mode is redoing the pdflatex/jupyter render passes, not notebook execution.

Proposal

  1. Flip the site-publishing templates (ci.yml, publish.yml) to cache-type: 'execution' as the default, with a short note in the template explaining why (deletions must take effect at the next build, not the next weekly cache).
  2. For any repo that measurably needs build mode (render passes too slow), add a prune-html input to restore-jupyter-cache — default true — that runs the equivalent of jb clean . --html after restore, so the safeguard lives in one composite action rather than N workflow files. (jb clean needs no _config.yml at the restore path; verified with jupyter-book 1.0.4.post1 that it removes exactly <path>/html — in _build terms: html only, .jupyter_cache/latex/jupyter untouched.)
  3. Note in the migration guide that repos carrying the interim workflow-level prune step from the rollout should drop it at cutover — the action supersedes it.

Filed from the discussion on QuantEcon/lecture-python-programming#616 (repo 2 of the rollout), where the interim prune is landing now; the rollout continues as the bridge until cutover.

Activity

  1. mmcky commented on Nov 6, 2026

    @mmcky
    ContributorAuthor

    Checked against main at 9644f17 (2026-11-06), and decided by the maintainer on 2026-11-07. The problem stands. lecture-dp restores the whole build cache in both ci.yml and publish.yml, templates/ci.yml:157 pins cache-type: 'build', and templates/publish.yml:89 takes that default. A local build with jupyter-book 1.0.4.post1 and Sphinx 7.4.7 confirmed the premise: a deleted page and a deleted _static file both survive a build over a restored _build. A fresh checkout makes Sphinx re-read and rewrite every page, so the restored HTML saves no work.

    The issue's first option, as written, has a flaw. The execution cache's key hashes only the lectures and falls back to any execution cache, while the build cache never falls back across an environment change. So a pull request that changes the environment would restore old outputs and pass without re-executing. Both reviews of this issue found that.

    The decision is two steps. Step 1, now (wave 4, v0.16.0): after a matched build-cache restore, restore-jupyter-cache removes <path>/html, unconditionally. The prune came from the independent review of this issue. A build always rewrites html, so nothing a build needs is lost, and the stale pages and files every measured case involved go with it, together with the _pdf/ and _notebooks/ copies the cache build staged there. lecture-dp gets it through @v0 with no edit, and no cache key changes.

    Step 1 does not prune _build/jupyter or _build/latex. html-copy-notebooks and html-copy-pdf document a restored build cache as their source, so pruning them would silently drop a site's downloads. It also has no opt-out input. Step 1 also takes in:

    • a harness check that a build restore leaves no _build/html while .jupyter_cache survives;
    • the input description and the chapter, including its troubleshooting entry for a removed lecture's pages;
    • ARCHITECTURE's "Two caches" section, which wrongly says Sphinx rebuilds incrementally;
    • the comment in templates/ci.yml;
    • a line in Getting started's migration steps: drop any interim prune of the restored _build/html at cutover, the step QuantEcon/workspace-lectures#41 rolled out to the lecture repositories, whose cutover waits on this issue.

    Step 2, #270: the templates restore cache-type: execution, and the execution cache's key gains the environment hashes, so an environment change still misses. Together with review M3's question of whether build-jupyter-cache keeps saving the full _build, this removes the jupyter and latex leftovers step 1 leaves, and stops each cache build from storing the execution cache twice.

    Claude Code (on behalf of mmcky)

  2. added a commit that references this issue on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions