tickets: run: on Windows, after a case-only rename of the initiative folder on disk, the dirty-initiative gate lets a person's uncommitted edit ride the unit commit
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Find the dirty-initiative gate and its _overlaps path comparison in the ticket run code; the payload identifies the TicketsEngine and TicketTree as the repro entry points. Start by tracing how the gate compares paths reported by git status with the resolved initiative folder, then run the provided Windows fsrename reproduction and compare it with none and gitmv. Done means the filesystem-only case rename pauses at ticket-tree before opening a session, preserving the uncommitted edit.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Before it opens a ticket, the tickets run pauses at ticket-tree when the initiative folder holds uncommitted changes the run does not own, "because the ticket's commit stages the whole tree". The gate compares the folder's on-disk spelling (from resolve()) with the paths git status reports, using a case-sensitive string prefix. Suppose the initiative folder was renamed by letter case on disk only (Explorer, or Rename-Item through a temp name, rather than git mv). Git on a case-insensitive filesystem keeps reporting the index spelling, so the prefix never matches and the gate passes. The run then builds, and the unit's add -A commit includes the person's in-flight edit (here a line in epic-cart/tickets.toml) in story 1.1: implemented via bmad-loop. On Linux the same rename is a real rename, and the run pauses before any session.
Environment
bmad-loop a5a8f097, Windows 11 (10.0.26200, NTFS, core.ignorecase=true), PowerShell 7.6.6 (SHELL unset), Python 3.13.2, git 2.49.0.windows.1; mock adapter (TicketsEngine, real TicketTree), in-place isolation; Linux oracle: differs
Steps to reproduce
From a bmad-loop checkout at a5a8f097, in PowerShell 7 with SHELL removed (uv sync --all-extras done once). The steps below are complete and run as-is from that shell; they need no other setup:
Remove-Item Env:SHELL -ErrorAction SilentlyContinue
$env:PYTHONUTF8 = '1'
# save the script below as repro_caserename.py in the checkout root, then:
uv run python repro_caserename.py none # positive control: no rename
uv run python repro_caserename.py gitmv # positive control: same rename via git mv, committed
uv run python repro_caserename.py fsrename # trigger: rename on disk only
The script builds the test suite's v7 sandbox (tests/conftest.py helpers; one ticket 1.1, the store tracked in the checkout) under $env:TEMP\caserename-repro. It renames initiative-demo to Initiative-Demo according to the mode and appends # a person's in-flight edit to the tracked epic-cart/tickets.toml. It then runs TicketsEngine with a mock dev session that writes src.txt and the plan at built.
"""Standalone repro: the initiative folder renamed by letter case on disk only (Explorer,
`Rename-Item` through a temp name; not `git mv`), then a person's uncommitted edit in it,
then a tickets run. Run from a bmad-loop checkout:
uv run python repro_caserename.py <fsrename|gitmv|none>"""
import json, os, subprocess, sys
from pathlib import Path
mode = sys.argv[1]
base = Path(os.environ.get("TEMP", "/tmp")).resolve() / "caserename-repro"
os.environ["BMAD_LOOP_STATE_DIR"] = str(base / "state")
sys.path.insert(0, "tests")
import conftest as C
from bmad_loop import verify
from bmad_loop.adapters.base import SessionResult
from bmad_loop.adapters.mock import MockAdapter
from bmad_loop.bmadconfig import load_paths
from bmad_loop.journal import Journal, load_state
from bmad_loop.model import RunState
from bmad_loop.policy import GatesPolicy, NotifyPolicy, Policy, ReviewPolicy
from bmad_loop.tickets_engine import TicketsEngine
root = base / mode
if root.exists():
C.remove_tree(root)
root.mkdir(parents=True)
(root / "src.txt").write_text("original\n", encoding="utf-8")
(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, "Cart model"),)),))
C._commit_template(root)
git = lambda *a: subprocess.run(["git", "-C", str(root), *a], capture_output=True, text=True, check=True).stdout.strip()
out = root / "_bmad-output"
if mode == "fsrename":
os.rename(out / "initiative-demo", out / "tmp-x")
os.rename(out / "tmp-x", out / "Initiative-Demo")
elif mode == "gitmv":
git("mv", "_bmad-output/initiative-demo", "_bmad-output/tmp-x")
git("mv", "_bmad-output/tmp-x", "_bmad-output/Initiative-Demo")
git("commit", "-q", "-m", "rename")
print("index:", sorted({p.split("/")[1] for p in git("ls-files", "_bmad-output").split()}),
"disk:", [p.name for p in out.iterdir()])
folder = next(out.iterdir())
with open(folder / "epic-cart" / "tickets.toml", "ab") as f: # a person's in-flight edit
f.write(b"# a person's in-flight edit\n")
print("git status:", git("status", "--porcelain"))
find = subprocess.run([sys.executable, "-I", "-B", "-X", "utf8", str(lay.tickets_script), "--project-root",
str(root), "find", "1.1"], capture_output=True, encoding="utf-8")
print(f"tickets.py find 1.1: rc={find.returncode} {find.stderr.strip()[:200]}")
plan = Path(json.loads(find.stdout)["plan"]) if find.returncode == 0 else None
def build(spec):
cwd = Path(spec.cwd)
assert plan is not None
(cwd / "src.txt").write_bytes(b"cart model\n")
plan.write_bytes(f"---\nticket: 1\nstatus: built\nbaseline_revision: '{verify.rev_parse_head(cwd)}'\n---\n\n# plan\n".encode())
return SessionResult(status="completed",
result_json={"workflow": "auto-dev", "spec_file": str(plan), "status": "built"})
paths = load_paths(root, want_tickets=True)
run_dir = root / ".bmad-loop" / "runs" / "r1"
state = RunState(run_id="r1", project=str(root), started_at="now",
initiative=lay.initiative, initiative_folder=str(paths.initiative_folder))
state.max_stories = 1
adapter = MockAdapter([build])
TicketsEngine(paths=paths, policy=Policy(gates=GatesPolicy(mode="none"), notify=NotifyPolicy(desktop=False, file=True),
review=ReviewPolicy(enabled=False)), adapter=adapter, run_dir=run_dir,
journal=Journal(run_dir), state=state).run()
st = load_state(run_dir)
print(f"sessions={len(adapter.sessions)} paused_stage={st.paused_stage}")
for line in (run_dir / "journal.jsonl").read_text(encoding="utf-8").splitlines():
e = json.loads(line)
if e["kind"] in ("ticket-pick-halt", "story-done"):
print(e["kind"], {k: e[k] for k in ("cause", "detail", "commit") if k in e})
print("HEAD:", git("show", "--stat", "--format=%h %s", "HEAD").replace("\n", " | ")[:400])
Observed (Windows, PowerShell 7.6.6; 2 of 2 runs, identical apart from hashes; transcript lines unchanged except that the expanded temp directory (C:\Users\<user>\AppData\Local\Temp, in its plain, doubled-backslash and forward-slash spellings) is written as $TEMP):
### uv run python repro_caserename.py none
index: ['initiative-demo'] disk: ['initiative-demo']
git status: M _bmad-output/initiative-demo/epic-cart/tickets.toml
tickets.py find 1.1: rc=0
sessions=0 paused_stage=ticket-tree
ticket-pick-halt {'cause': 'dirty-initiative', 'detail': "the initiative folder _bmad-output/initiative-demo has uncommitted changes this run does not own (_bmad-output/initiative-demo/epic-cart/tickets.toml); commit or stash them before 1.1 is built, because the ticket's commit stages the whole tree"}
HEAD: 6a5e376 initial | | .claude/skills/bmod-method/bmod.toml | 5 + | .gitignore | 2 + | .../initiative-demo/epic-cart/epic-cart.md | 7 + | .../initiative-demo/epic-cart/tickets.toml | 4 + | _bmad-output/initiative-demo/initiative-demo.md | 7 + | _bmad-output/initiative-demo/tickets.toml | 3 + |
rc=0 (3s)
### uv run python repro_caserename.py gitmv
index: ['Initiative-Demo'] disk: ['Initiative-Demo']
git status: M _bmad-output/Initiative-Demo/epic-cart/tickets.toml
tickets.py find 1.1: rc=0
sessions=0 paused_stage=ticket-tree
ticket-pick-halt {'cause': 'dirty-initiative', 'detail': "the initiative folder _bmad-output/Initiative-Demo has uncommitted changes this run does not own (_bmad-output/Initiative-Demo/epic-cart/tickets.toml); commit or stash them before 1.1 is built, because the ticket's commit stages the whole tree"}
HEAD: cfda7f4 rename | | _bmad-output/{initiative-demo => Initiative-Demo}/epic-cart/epic-cart.md | 0 | _bmad-output/{initiative-demo => Initiative-Demo}/epic-cart/tickets.toml | 0 | _bmad-output/{initiative-demo => Initiative-Demo}/initiative-demo.md | 0 | _bmad-output/{initiative-demo => Initiative-Demo}/tickets.toml | 0 | 4 files changed, 0 insertions(+), 0 deletions(-)
rc=0 (2s)
### uv run python repro_caserename.py fsrename
index: ['initiative-demo'] disk: ['Initiative-Demo']
git status: M _bmad-output/initiative-demo/epic-cart/tickets.toml
tickets.py find 1.1: rc=0
sessions=1 paused_stage=epic-boundary
story-done {'commit': 'ed6e13c8c1641fd96efe95ce04788cf06e1c1d4e'}
ticket-pick-halt {'cause': 'epic-closure', 'detail': 'close epic-cart with bmad-ticket (closure check; retrospective verdict: unknown)'}
HEAD: ed6e13c story 1.1: implemented via bmad-loop | | _bmad-output/initiative-demo/epic-cart/story-cart-model-plan.md | 7 +++++++ | _bmad-output/initiative-demo/epic-cart/tickets.toml | 1 + | src.txt | 2 +- | 3 files changed, 9 insertions(+), 1 deletion(-)
rc=0 (4s)
Ablation (observed separately on the same mechanism): with _overlaps comparing path.casefold() and folder.casefold() in a scratch copy of the package (first on PYTHONPATH), the fsrename run pauses dirty-initiative with sessions=0, like the controls.
Expected vs actual
| actual (fsrename) | expected (docs/tickets-guide.md pause table: ticket-tree — "the initiative folder holds uncommitted changes the run does not own"; both controls) |
|
|---|---|---|
| uncommitted edit under the initiative folder | gate passes, ticket built, edit committed inside the unit commit | pause at ticket-tree before the ticket is opened |
Linux
The same script on Ubuntu (WSL2, ext4, case-sensitive), bmad-loop at the same commit from a git archive copy with its own uv venv, Python 3.13.2, git 2.43.0; 2 of 2 runs, identical apart from hashes. Lines are unchanged:
### uv run python repro_caserename.py none
index: ['initiative-demo'] disk: ['initiative-demo']
git status: M _bmad-output/initiative-demo/epic-cart/tickets.toml
tickets.py find 1.1: rc=0
sessions=0 paused_stage=ticket-tree
ticket-pick-halt {'cause': 'dirty-initiative', 'detail': "the initiative folder _bmad-output/initiative-demo has uncommitted changes this run does not own (_bmad-output/initiative-demo/epic-cart/tickets.toml); commit or stash them before 1.1 is built, because the ticket's commit stages the whole tree"}
HEAD: 33354c9 initial | | .claude/skills/bmod-method/bmod.toml | 5 + | .gitignore | 2 + | .../initiative-demo/epic-cart/epic-cart.md | 7 + | .../initiative-demo/epic-cart/tickets.toml | 4 + | _bmad-output/initiative-demo/initiative-demo.md | 7 + | _bmad-output/initiative-demo/tickets.toml | 3 + |
rc=0
### uv run python repro_caserename.py fsrename
index: ['initiative-demo'] disk: ['Initiative-Demo']
git status: D _bmad-output/initiative-demo/epic-cart/epic-cart.md
D _bmad-output/initiative-demo/epic-cart/tickets.toml
D _bmad-output/initiative-demo/initiative-demo.md
D _bmad-output/initiative-demo/tickets.toml
?? _bmad-output/Initiative-Demo/
tickets.py find 1.1: rc=1 {"error": "active initiative folder not found: /tmp/caserename-repro/fsrename/_bmad-output/initiative-demo"}
sessions=0 paused_stage=ticket-tree
ticket-pick-halt {'cause': 'tree-fault', 'detail': 'tickets.py fault: active initiative folder not found: /tmp/caserename-repro/fsrename/_bmad-output/initiative-demo'}
HEAD: 59ee8b9 initial | | .claude/skills/bmod-method/bmod.toml | 5 + | .gitignore | 2 + | .../initiative-demo/epic-cart/epic-cart.md | 7 + | .../initiative-demo/epic-cart/tickets.toml | 4 + | _bmad-output/initiative-demo/initiative-demo.md | 7 + | _bmad-output/initiative-demo/tickets.toml | 3 + |
rc=0
On a case-sensitive filesystem the rename is a real one: git reports the old paths deleted and the new folder untracked, and tickets.py no longer finds the active initiative, so the run pauses loudly before any session. The fail-open needs a case-insensitive filesystem (Windows here; macOS not measured).
Source
At a5a8f097, src/bmad_loop/tickets_engine.py. The prefix comes from the on-disk spelling and the dirty paths from git's index spelling, and the match is a case-sensitive startswith. Observed: in the fsrename run, index and disk differ and git status reports the old spelling.
# :446-447, :462-466 (_gate_dirty_initiative)
try:
prefix = folder.resolve().relative_to(repo.resolve()).as_posix()
...
touched = sorted(
path
for path in dirty
if _overlaps(path.rstrip("/"), prefix) and path.rstrip("/") not in owned
)
# :210-216
def _overlaps(path: str, folder: str) -> bool:
...
if folder == ".":
return True
return path == folder or path.startswith(folder + "/") or folder.startswith(path + "/")
Same shape, source-derived and not observed: _retro_doc_uncommitted (tickets_engine.py:731-739) tests rel in verify.dirty_paths(root) with rel from doc.resolve(), so after the same rename a dirty retrospective document reads as clean.
Suggested fix
Not validated beyond the ablation above: on case-insensitive filesystems, compare with os.path.normcase / casefold, or ask git for the paths with a :(icase) pathspec of the prefix. Do it in both _overlaps and _retro_doc_uncommitted.
- Lingua principale
- Python
- Stelle
- 196
- Fork
- 78
- Merge medio
- 9h 24m
- PR unite (30g)
- 44
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bmad-code-org/bmad-loop
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bmad-code-org/bmad-loop#1063 ·
I maintainer di solito rispondono entro 1 giorno
-
psmux: task window name starting with '-' creates no window; session reads as crashedForse già presa @RECOHA l’ha presa 8 giorni fa. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
bmad-code-org/bmad-loop#1061 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
bmad-code-org/bmad-loop#1057 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
bmad-code-org/bmad-loop#973 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
bmad-code-org/bmad-loop#965 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di bmad-code-org/bmad-loop
Issue simili
-
accepted
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
future-agi/future-agi#5274 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
GenericMappingTools/pygmt#5014 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Feed validator crashes with "Memory error" when validating https://www.tidyverse.org/index.xmlApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
w3c/feedvalidator#204 ·
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Forse già presa @sumitkhond111-del l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
open-mmlab/mmcv#3352 ·