Clear the restored Sphinx environment before the publish build - #272
Merged
Conversation
publish.yml unpacks the cache.yml artifact into _build whole — including the .doctrees Sphinx environment from the run that produced it — and never clears it. That environment holds cross-document state: the resolved toctree and the section numbering derived from it. Reusing it makes every page render its navigation from the table of contents as it stood when the artifact was built, however current the sources are. publish-2026aug24 shipped that. Its build rewrote all 145 documents from the tagged sources, but against an environment restored from 2026-08-17, which predates mccall_risk entering _toc.yml. The published output has mccall_risk missing from the navigation of every other page, and the section numbering one behind from mccall_persist_trans onward, so mccall_risk and mccall_persist_trans both publish as chapter 57. Drop .doctrees and html from the restored tree, keeping .jupyter_cache — the expensive notebook execution and the only part the artifact is for. ci.yml has carried the same step since it was added; publish.yml had it only as a commented-out line. Closes #270 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for astonishing-narwhal-a8fc64 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Updates the publish workflow to avoid reusing a cached Sphinx environment restored from the build-cache artifact, ensuring the published site’s navigation and section numbering are generated from the current _toc.yml and sources.
Changes:
- Add a “Clear stale Sphinx environment” step to delete
_build/.doctreesand_build/htmlafter downloading the cache artifact (preserving the notebook execution cache). - Replace the outdated commented guidance near the HTML build with an explanation that the environment is cleared earlier.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Name `_build/.doctrees` and `_build/.jupyter_cache` in full, matching the paths the step's own `run:` line uses, so a reader debugging the step does not have to carry the `_build` prefix down from an earlier sentence. Comment text only; no change in behaviour. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 24, 2026
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.
Closes #270.
What was wrong
publish.ymlunpacks thecache.ymlartifact into_buildwhole — including_build/.doctrees, the Sphinx environment from the run that produced the artifact — and never clears it. That environment is not per-page state; it holds cross-document state, principally the resolved toctree and the section numbering derived from it. Reusing it means every page renders its navigation from the table of contents as it stood when the artifact was built, however current the sources are.Important correction to the issue as filed. #270 says publish deployed stale HTML for pages it did not rebuild. That is not what happened, and I have corrected the issue. The build rewrote all 145 documents from the tagged sources — the run log's HTML phase shows
writing outputfor 145 docnames includingcareer,mccall_persist_transandmccall_risk. The pages are fresh; the global state they were rendered against is stale. The reader-visible symptoms in #270 are all real, the fix is the same, but the mechanism is different and worth stating correctly.Evidence
The artifact in use was from 2026-08-17, because the three
cache.ymlruns since then had failed.mccall_riskentered_toc.ymlon 2026-08-21 with #264, so the restored environment had never seen it. In the release asset forpublish-2026aug24— the build's own output, so this is not a deploy or CDN artefact — the Search section ofcareer.html's navigation reads:mccall_model,mccall_model_with_separation,mccall_model_with_sep_markov,mccall_fitted_vfi,mccall_persist_trans,jv,odu.mccall_riskis absent, though it sits betweenmccall_fitted_vfiandmccall_persist_transin_toc.ymlat the published commit and its own page was built and deployed. The same omission appears onmccall_persist_trans.html.Numbering follows from the same stale toctree, one behind from
mccall_persist_transonward, which is why two lectures publish under the same chapter number:<title>as published_toc.ymlmccall_risk.htmlmccall_persist_trans.htmlcareer.htmlThere were no toctree warnings in the build, and
_toc.ymlat37d8e85is correct and listsmccall_riskexactly once — the sources were never the problem.The change
One step after the artifact download, dropping
.doctreesandhtmlfrom the restored tree and keeping.jupyter_cache, which is the expensive notebook execution and the only part the artifact exists to supply.ci.ymlhas carried exactly this step ("Clear stale Sphinx environment") since it was added;publish.ymlhad it only as a commented-out line next to the HTML build. The stale comment there is replaced with a pointer to the new step._build/htmlis dropped alongside the doctrees so that output for a lecture removed from the table of contents cannot survive in the deploy. The removal sits before "Copy Download Notebooks for GH-PAGES", which recreates_build/html/_notebooks, so the download-notebook assets are unaffected.The cost is a Sphinx render, not a re-execution — notebook execution still comes from the cache.
Verifying this
Merging alone changes nothing already published; the fix takes effect at the next publish. The re-cut that #270 needs is the verification: after a green
cache.ymlrun, tag and then confirm thatcareer.htmllistsmccall_riskin its navigation and that no two lectures share a chapter number. A cache run was dispatched onmainon 2026-08-24 and gates that re-cut.Worth noting for whoever reviews the re-published site: this fix does not address #266, the duplicated Roman numeral V on those same two lectures. That is a source-content defect — the five undelivered upstream renumberings — and it will still be there after a clean rebuild.
Why this was invisible
Every signal was green. The workflow succeeded, all 145 pages return HTTP 200,
check-tofu --sitereports no missing glyphs, and no link 404s. The defect exists only in cross-page consistency, which nothing currently checks. Related: #271 covers thecache.ymlgate defects that let the artifact go stale in the first place.🤖 Generated with Claude Code