tickets: on Windows, case-only twin ids can alias one plan file, and discard_unbuilt_plan can delete the twin's unbuilt plan

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

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

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

評価

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

調査の方向性

Start with src/bmad_loop/tickettree.py around discard_unbuilt_plan and the case-twin guard in src/bmad_loop/stories.py; then trace how tickets.py find names plan files. Add regression coverage for the three-entry case-only ID layout on Windows, including the rollback path described in the issue. Done means the twins cannot alias a plan and discarding one ticket's unbuilt plan preserves the other's.

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

説明

Status (needs confirmation)

  • Observed: on NTFS, an epic with three entries titled Cart model and ids X1, A1 and a1 gets plan names story-cart-model-A1-plan.md and story-cart-model-a1-plan.md from tickets.py find, which are one file. TicketTree.discard_unbuilt_plan("1.A1", <that path>) then deletes the file even though it holds ticket: a1 and was written for 1.a1. A twin plan with a body is refused (the frontmatter-only check), so only an unbuilt twin plan is at risk.
  • Observed controls: twins with two entries (same title, case-different titles, or different titles) get distinct names (story-cart-model-plan.md / story-cart-model-a1-plan.md, or …-rules-plan.md), and the discard leaves the twin's plan alone. A three-entry layout with a non-colliding third id (A2 instead of a1) also leaves the other plan alone.
  • Not driven: a tickets run in which this happens (a failed in-place attempt of one twin with rollback_on_failure = true while the other twin's plan is frontmatter-only). Also not driven: the wider consequence that both twins read and mark one shared plan file at all.
  • A tester should try: the layout above with [scm] isolation = "none", rollback_on_failure = true, and max_dev_attempts = 1. Start 1.a1 first and stop it at in-progress with a frontmatter-only plan, then run 1.A1 with a failing session, and check whether 1.a1's plan is gone. Please report whether a real run reaches the deletion.

Related: #963 (the same case-only twin ids alias the unit worktree and branch on Windows).

Summary

tickets.py disambiguates colliding title slugs with the entry id. For case-only twin ids, that suffix differs only by case, so on a case-insensitive filesystem both tickets resolve to one plan file. bmad-loop accepts case-only twin ids in tickets mode (stories mode refuses them), and discard_unbuilt_plan deletes a frontmatter-only plan without checking that its ticket: names the ref being rolled back. The deletion was observed through a direct TicketTree.discard_unbuilt_plan call; the proposed failed-run rollback sequence remains untested.

Environment

bmad-loop a5a8f097, Windows 11 10.0.26200 (NTFS), PowerShell 7.6.6 (SHELL unset), Python 3.13.2; pure calls (the real tickets.py find from the test suite's v7 sandbox, TicketTree.discard_unbuilt_plan); Linux oracle: n/a (on a case-sensitive filesystem the two plan names are two files; expected, not run).

Steps to reproduce (symbol level)

From a bmad-loop checkout at a5a8f097 after uv sync --all-extras, in PowerShell 7 with SHELL removed. The steps are complete and runnable as shown: save the script below as repro_twin_plan.py in the checkout root, then run:

Remove-Item Env:SHELL -ErrorAction SilentlyContinue
$env:PYTHONUTF8 = '1'
uv run python repro_twin_plan.py
import os, sys, tempfile
from pathlib import Path
sys.path.insert(0, "tests")
import conftest as C
from bmad_loop import tickettree
from bmad_loop.journal import Journal

root = Path(tempfile.mkdtemp(prefix="twin-plan-"))
(root / ".gitignore").write_text(C.V7_GITIGNORE, encoding="utf-8")
lay = C.install_bmad_v7(root)
C.write_ticket_tree(lay, (C.EpicSpec(1, "epic-cart", "Cart", (C.EntrySpec(1, "x"),)),))
(lay.initiative_folder / "epic-cart" / "tickets.toml").write_text(
    "".join(f'[[entry]]\nid = "{i}"\ntype = "story"\ntitle = "Cart model"\n\n' for i in ("X1", "A1", "a1")), encoding="utf-8")
C._commit_template(root)
plans = {r: Path(C.run_tickets(lay, "find", r)["plan"]) for r in ("1.A1", "1.a1")}
print({r: p.name for r, p in plans.items()}, "same file:", os.path.normcase(str(plans["1.A1"])) == os.path.normcase(str(plans["1.a1"])))
plans["1.a1"].write_bytes(b"---\nticket: a1\nstatus: in-progress\n---\n")   # 1.a1's unbuilt plan
(root / "run").mkdir()
print(tickettree.TicketTree(root).discard_unbuilt_plan("1.A1", plans["1.A1"], Journal(root / "run")))
print("1.a1's plan exists after 1.A1's discard:", plans["1.a1"].exists())

Observed (Windows, 2 of 2 runs; paths elided):

{'1.A1': 'story-cart-model-A1-plan.md', '1.a1': 'story-cart-model-a1-plan.md'} same file: True
PlanMark(ref='1.A1', …, before='in-progress', after='', outcome='discarded', created=False)
1.a1's plan exists after 1.A1's discard: False

For a non-colliding three-entry control, change the third entry id from a1 to A2, replace both lookup/use keys 1.a1 with 1.A2 throughout the script, and change the written frontmatter from ticket: a1 to ticket: A2. Keep the discard target 1.A1. Expected and observed: the plan names end in -A1-plan.md and -A2-plan.md, the discard returns outcome='noop', and the other plan remains present.

Source

At a5a8f097, src/bmad_loop/tickettree.py:530-565 (discard_unbuilt_plan): _locate(ref, plan) (:534) ties the path to what tickets.py find names for ref (here the shared file), then it reads the plan's status, refuses a plan with a body (:551-554) and unlinks it (:562). The plan's own ticket: is never compared with ref. Stories mode's case-twin guard is src/bmad_loop/stories.py:162-176. Source-derived: the inspected tickets source and engine contain no case-folded ticket-ID collision check; the direct TicketTree reproduction accepts these two refs. The full preflight and engine rollback route was not exercised.

Suggested fix

Not validated: refuse case-only twin ids in the tickets preflight, validate and run --dry-run, as stories mode does. Independently, have discard_unbuilt_plan refuse a plan whose ticket: does not name the ref.

主要言語
Python
スター
196
フォーク
78
平均マージ
9時間 24分
マージ済み PR(30日)
44

環境構築

はじめの一歩

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

bmad-code-org/bmad-loop のほかの issue

bmad-code-org/bmad-loop の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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