promote: a new lecture that shares a single-consumer asset with a switched lecture can never be promoted

オープン
#16 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
tooling

調査の方向性

Start with the promotion destination pass and the test harness described in the issue. Read the existing test test_an_asset_shared_with_a_guarded_lecture_stays_guarded and trace how destination paths are chosen for assets with a canonical: pool ledger entry. Add a regression test for the reproduced transition; done means the new lecture promotes successfully, shares the existing pool path, and leaves the switched lecture and asset record unchanged.

索引モデルが issue の本文から書いたものです。

説明

Follow-up from the review of https://github.com/QuantEcon/lectures/pull/14.

What happens

After promote --switch SERIES, a switched lecture can never be re-promoted (by design: the pool copy is the source of truth). Its single-consumer assets stay at _static/<slug>/.... If a lecture from another series is later promoted and references the same asset (same mirror path, same bytes), the destination step decides the asset now has two consumers and belongs in _static/_shared/..., finds the old location is still used by a lecture outside the batch, and refuses with:

[other] FAILED: asset _static/lecture_specific/mccall/fig.png is recorded at _static/mccall/fig.png but now maps to _static/_shared/mccall/fig.png — re-promote its other consumer(s) (mccall) in the same batch

The remedy it names is impossible. Adding mccall to the batch gives:

[mccall] FAILED: lectures/mccall.md is canonical in the pool (switched from intermediate on 2026-10-08) — promotion would overwrite the pool copy

So the new lecture cannot enter the pool while it shares that asset. Switching the new lecture's series does not help either, since the switch only touches ledger entries and the lecture has none yet.

Reproduction (with the tools/tests harness)

repo = make_repo(["intro", "intermediate"])
fig = b"figure bytes"
repo.mirror_file("intermediate", "_static/lecture_specific/mccall/fig.png", fig)
repo.lecture("intermediate", "mccall", lecture_text("McCall", refs=["_static/lecture_specific/mccall/fig.png"]))
assert repo.promote("mccall").returncode == 0
assert repo.promote("--switch", "intermediate").returncode == 0
repo.mirror_file("intro", "_static/lecture_specific/mccall/fig.png", fig)
repo.lecture("intro", "other", lecture_text("Other", refs=["_static/lecture_specific/mccall/fig.png"]))
assert repo.promote("other").returncode == 1          # the error above
assert repo.promote("other", "mccall").returncode == 1  # the suggested remedy also fails

When it bites

Only mid-transition: one series switched, another still fed from its mirror, and a new lecture in the second reusing a figure the first already owns. Assets that already live in _static/_shared/ are unaffected (the destination does not change, and #14 already keeps a switched asset's record when another lecture comes to share it).

Suggested fix

Treat a switched asset's location as frozen. In the destination pass, when the old pool path of (src_rel, digest) is referenced by a lecture whose ledger entry is canonical: pool, keep dest_map[(src_rel, digest)] = old instead of recomputing it, so the new lecture is rewritten to the existing path and shares the file in place. The switched lecture's pool text is untouched, the ledger gains the new lecture as a user of the asset, and the asset keeps its canonical: pool record. A test alongside test_an_asset_shared_with_a_guarded_lecture_stays_guarded would cover it.

主要言語
Python
スター
1
フォーク
0
平均マージ
1日 3時間
マージ済み PR(30日)
17

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

QuantEcon/lectures のほかの issue

QuantEcon/lectures の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。