Skip to content

promote: one pool copy of a file lectures share, kept together and recorded by its users - #62

Merged
mmcky merged 3 commits into
mainfrom
promote/shared-assets
Nov 16, 2026
Merged

mmcky merged 3 commits into
mainfrom
promote/shared-assets

Conversation

@mmcky

@mmcky mmcky commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Asset placement and provenance: the four gaps in #23, with the same-batch re-homing and the differing-bytes record from the promote hardening on QuantEcon/project-monorepo#11. It extends the rule a shared _admonition/ include got in #60 to every pool asset.

What it changes in the pool: tooling, tests, the README, and sync/ledger.yml (its header comment, and three records, below). No pool lecture or asset changes.

The rule

The pool keeps one copy of a file, used by every pool lecture that refers to it, while the series those lectures come from each carry their own. Today six assets are shared by lectures from different series: the GPU admonition (55 lectures), duopoly_mpe.py (markov_perf from intermediate, rob_markov_perf from advanced) and the four arellano figures (advanced and jax).

  • One series changes the file first. A series whose copy was the pool's version leads: the refresh takes its new version for every lecture that uses the file, in the refresh or not. The other series' copies are recorded on the asset as stale (their own digest and a stale_since time), reported as information for seven days and as drift after that, and are current again at the first refresh after they follow. (Decided by the owner on 2026-11-16: the admonition rule, for every shared file.)
  • Refused: two series that change the file differently; a stale copy that changes to anything but the pool's version; a hand-edited shared pool file, whatever would overwrite, restore or move it (a lecture's own file, with nothing else changing, is restored by re-promoting that lecture).
  • Lectures that share a file stay on one pool path (gap 1). A lecture outside the batch counts as a user of the version the batch brings, so a partial refresh no longer leaves one upstream file at two pool paths. When a file's pool path must change (a second lecture starts to use it, or two series' files become one), promote pulls the lectures that use it into the batch and re-promotes them with it. One that cannot be re-promoted holds the mover back, with the reason. arellano_jax no longer needs promoting by hand in one batch with arellano.
  • An asset's record follows its lectures (gap 2). Its sources are its copies in the series its user lectures come from, while those lecture copies are still the lecture the pool recorded. A series that merely has a file of the same name is not a source. A lecture that stops using a shared file takes the file's remaining users along, so the record never names a series that is no longer a user.
  • A destination collision refuses every lecture involved (gap 3), naming all of them, whatever order they were given in.
  • A copy that differs is recorded, never dropped (gap 4). A copy that fell behind is stale, as above. A copy that was never the pool's version is a different file under the same name: it is recorded with differs: true, reported as information, never followed, and a lecture that comes only from that series and uses the name gets its own series' file.

The drift-check

check_asset applies the same rule to every asset: a leading copy is a refresh finding, a stale copy stale-copy, a fork asset-diverged. Two new refresh findings keep the record true, so that promote and the drift-check never disagree about a copy: asset-caught-up (a copy recorded as stale now matches the pool; without it, the next change by that series was refused as a fork, which was also true of the admonition as merged in #60) and asset-record (a record whose canonical series is no longer a user). The refresh acts on both.

sync/ledger.yml

  • The header comment describes the new fields.
  • _static/markov_perf/judd_fig1.png, judd_fig2.png and mpe_vs_monopolist.png lose advanced as a source: advanced has files of those names with the same bytes, and no advanced lecture uses them. These were the three records the new rule changes; a full re-promotion of all six series' tocs changes nothing else, in the ledger or the pool.

Left out, by the owner's call on 2026-11-16

Two of the four older hardening items: a per-series name map (no pool lecture has a different name in another series), and refusing many-to-one rewrites (the one case in the pool, long_run_growth, writes one figure two ways and both resolve to the same file; a test keeps it accepted).

Checks

  • tools/tests: 209 passed, 1 skipped (28 new tests, most in test_shared_assets.py; one admonition test replaced by two, since a series with no lecture using a file is no longer a source of it).
  • On the branch: tools/drift-check and tools/pool-check clean; tools/promote --refresh has nothing to refresh.
  • Rehearsed on scratch copies of the real pool, following the nightly's steps over four nights of edits to duopoly_mpe.py: intermediate leads (advanced recorded stale, one pool file), advanced catches up (recorded, run clean), advanced leads, intermediate forks (a drift issue, no refresh loop). The pool-check was clean throughout.
  • Two adversarial reviews on scratch copies before this was opened. Reproduced and fixed here, each with a test: a lecture canonical in one series silently given another series' bytes through a first-promotion "stale" record (now differs); a caught-up copy never recorded, so its next change was refused; a refresh loop when a non-canonical series edits both its lecture copy and the file; a record left naming a series whose lecture stopped using the file; two records for what became one file never merged; a hand-edited file lost when its asset moved; one lecture's refusal taking down unrelated users of the same asset; a pulled-in lecture written although the lecture that needed it failed; pulled-in lectures not named in the output. The organiser's review then found, reproduced, and these are fixed with tests: an asset that moved in the run lost its stale record; a hand-edited shared file was restored silently when every user was in the batch; a series left out with --exclude that only holds a copy was dropped from the record; a file renamed upstream split in two; an optional pull-in could turn the run red. Its re-review found that a renamed file could be matched to an unrelated new lecture's identical file; a rename is now recognised only for a lecture that already used the asset.

Known limits

  • A consequence of keeping one 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.
  • A lecture pulled in only because another lecture stopped using a file they shared is let go, with a warning, if it cannot be re-promoted. That night stays green. From the next night the drift-check asks for the file's record to be rewritten through that lecture (asset-record), and the refresh fails on it, every night, until its own refusal (a real divergence) is settled.
  • A copy two versions behind that catches up one version is refused as a fork until it reaches the pool's version, and that refusal holds every user of the file. The same holds for a series left out with --exclude that caught up to a version the pool has since left.
  • After a refresh, a non-canonical source's promoted_at pin stays at its old value until a --toc run (as on main).
  • Lectures in subfolders: the refresh looks an entry up by its base name (as on main).

Closes #23.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WT8bMXuHMiWb8victibwcU

…corded by its users

The rule a shared `_admonition/` include got in #60 now holds for every pool
asset (#23), and an asset's record follows the lectures that use it.

- One version. The pool keeps one copy of a file. A series whose copy was
  the pool's version and changes it leads: the pool takes the new version
  for every lecture that uses the file, in the batch or not. Copies that did
  not follow are recorded stale; two leaders that differ and a stale copy
  that moves to a third version are refused.
- Lectures that share a file stay on one pool path. A lecture outside the
  batch counts as a user of the version the batch brings, so a partial
  refresh no longer splits a shared file in two. When a file's pool path
  must change, the lectures that use it are pulled into the batch; one that
  cannot be re-promoted holds the mover back. A lecture that stops using a
  shared file takes its remaining users along, so the record follows them.
- Provenance from users. An asset's sources are its copies in the series
  its user lectures come from, while those lecture copies are still the
  lecture the pool recorded; never a series that merely has a file of that
  name. A copy that was never the pool's version is recorded as a different
  file (`differs: true`) and never followed or handed to a lecture.
- A destination collision refuses every lecture involved, naming all of
  them, whatever order they were given in.
- The drift-check applies the same rule to every asset, asks for a refresh
  when a stale copy has caught up (so the record says so) or a record names
  a canonical series that is no longer a user, and watches only copies
  behind a user lecture.

sync/ledger.yml: the header comment, and the three `markov_perf` figures
lose `advanced` as a source (no advanced lecture uses them). No pool
lecture or asset changes.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXuHMiWb8victibwcU
Copilot AI balanced review requested due to automatic review settings November 16, 2026 02:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🔵 Needs a closer look

Because the change entails a substantial refactor of tools/promote and tools/drift-check affecting shared asset/version and ledger rewrite behavior, it needs human validation against real pool/legacy ledgers and nightly refresh workflows (including --exclude and subfolder lecture paths) beyond the synthetic test harness.

No open issues 🎉

What changed in this PR

Generalizes the pool’s “single canonical shared asset with recorded per-series provenance” behavior across all shared files, keeping promote/refresh and drift-check consistent while preventing split-path assets and preserving stale/differing copies (closes #23).

Changes:

  • Extends shared-asset rules beyond _admonition/ to track canonical/stale/differing copies and keep ledger records aligned with lecture users.
  • Updates tools/promote --refresh to batch/pull in all user lectures for shared assets so moves and placement remain atomic and consistent.
  • Adds comprehensive tests, updates documentation, and adjusts the ledger header/affected entries to match the new semantics.
File Description
tools/​tests/​test_shared_assets.py Adds a new regression test suite covering shared-asset placement/provenance rules, collisions, and stale/differing copy behaviors.
tools/​tests/​test_admonition.py Updates and expands admonition-related tests to match the generalized shared-file rules and source semantics.
tools/​tests/​conftest.py Adjusts shared test utilities/fixtures to support deterministic pin movement and stale-since related assertions.
tools/​promote Implements generalized shared-asset canonical selection, provenance recording, and same-batch pull-in logic to keep shared assets on one pool path.
tools/​drift-check Aligns drift detection with the new shared-asset rules and adds findings to keep ledger records and recorded sources consistent over time.
sync/​ledger.yml Updates the header documentation and revises affected asset records to ensure sources reflect only series with user lectures under the new rule.
README.md Documents the generalized “file lectures share” rule set, including canonical/stale/differing handling and batch behavior.

Review effort: Balanced

mmcky and others added 2 commits November 16, 2026 14:04
…eft out; a shared file is never restored over a hand edit

- An asset that moves to another pool path in the run keeps its record:
  its stale copies stay stale, and a series left out keeps its item.
- A hand-edited shared file is refused even with every user in the batch
  and no version change, as on main. Only a lecture's own file is restored
  by re-promoting the lecture.
- A series left out of a run keeps its item if the ledger has it as a
  user series, whether or not it is canonical for a user.
- A file moved or renamed upstream with the same bytes is still the
  recorded asset, and a recorded asset is one file however its series spell
  its path: its users are counted together and its pool path is decided
  once.
- A lecture pulled in only so that a record could follow its users is let
  go with a warning if it cannot be re-promoted; it never fails the run.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXuHMiWb8victibwcU
… it; say what a declined pull-in means

- A file in the same series with the same bytes as a recorded asset whose
  path is gone upstream is that asset only for a lecture that already used
  it. A new lecture that carries an identical file has an asset of its own.
- The warning for a pull-in that could not be re-promoted says what follows:
  from the next run the drift-check asks for the record to be rewritten
  through that lecture, and the refresh fails on it until it is settled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMXuHMiWb8victibwcU
@mmcky
mmcky merged commit 03224b4 into main Nov 16, 2026
5 checks passed
@mmcky
mmcky deleted the promote/shared-assets branch November 16, 2026 03:49
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.

promote: asset provenance and placement gaps

2 participants