tickets: run: on Windows, ticket ids that differ only by case share one worktree path and branch, so a kept failed unit is discarded by its twin

Abierto
#963 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
git, python
Área
cli, devtools, testing

Línea de trabajo

Start by tracing ticket ID validation in _bmad/method/scripts/tickets.py and the tickets-mode checks in validate; compare them with the case-only ID guard in stories.py:162-176. Then inspect the worktree path and branch construction described in the report, and run the supplied control and twin reproductions on Windows. Done means case-only ticket IDs are rejected or handled distinctly before they can overwrite a kept failed worktree, with validation and dry-run reporting the problem.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

tickets.py treats entry ids A1 and a1 in one epic as two tickets (1.A1, 1.a1), and bmad-loop accepts them: run --dry-run lists both with no warning, and validate reports no id problem (its tickets.py capability check does not run without --probes). validate --probes does not flag the twins either. Under worktree isolation the unit's mount is worktrees/<ref> and its branch bmad-loop/<run>/<epic>/<ref>. On a case-insensitive filesystem (NTFS) the two twins get the same directory and the same loose ref. When the first twin fails and is kept for inspection (keep_failed = true, the default), the second twin's worktree open finds that mount and treats it as an orphan from an isolation flip, which this run never had. It snapshots the mount to a new refs/attempt-preserve-dirty/*-orphan ref, force-removes it, and builds the second twin in the same directory. After the run the first twin's branch is gone too. The run's ATTENTION file still says the failed work is "kept on branch bmad-loop/r1/epic-cart/1.A1", but that branch and the kept worktree no longer exist, and ATTENTION never names the new orphan ref. What remains for recovery is the failed/1.A1/changes.patch capture, the attempt-1 preserve ref ATTENTION does name, and the unadvertised orphan ref. Stories mode rejects case-only IDs to prevent case-insensitive story-spec glob collisions (stories.py:162-176); tickets mode has no analogous ID guard. On Linux (case-sensitive) the twins stay apart and the failed unit is kept.

Environment

bmad-loop a5a8f097, Windows 11 (10.0.26200, NTFS), PowerShell 7.6.6 (SHELL unset), Python 3.13.2, git 2.49.0.windows.1; mock adapter (TicketsEngine, real TicketTree over the sandbox's installed tickets.py, real git worktree) and the real CLI (python -m bmad_loop.cli) for the preflight; Linux oracle: differs (ext4: no alias)

Steps to reproduce

From a bmad-loop checkout at a5a8f097, in PowerShell 7 with SHELL removed (uv sync --all-extras done once). The commands below are complete and runnable as shown:

Remove-Item Env:SHELL -ErrorAction SilentlyContinue
$env:PYTHONUTF8 = '1'
# save the script below as repro_casetwin.py in the checkout root, then:
uv run python repro_casetwin.py control cli   # preflight, positive control: ids A1 and B1
uv run python repro_casetwin.py twin cli      # preflight, trigger: ids A1 and a1
uv run python repro_casetwin.py control       # run, positive control
uv run python repro_casetwin.py twin          # run, trigger

The script builds the test suite's v7 sandbox (tests/conftest.py helpers) under $env:TEMP\casetwin-repro, a fresh copy per call. It replaces epic-cart/tickets.toml with two entries: id = "A1" "Cart model", and id = "a1" (or "B1") "Cart rules". With cli it adds a tickets-mode policy ([stories] source = "tickets", review off) and a profile whose binary is a stub that is never executed. It then runs only python -m bmad_loop.cli validate and run --dry-run against the sandbox. Without cli it runs TicketsEngine with worktree isolation, keep_failed = true and max_stories = 2: the mock dev session for 1.A1 crashes twice (two attempts, then deferred), and the other ticket builds.

"""Standalone repro: two tickets whose ids differ only by case (A1 / a1) in one epic,
worktree isolation with keep_failed. The first ticket's sessions crash (deferred, its
worktree and branch kept for inspection); the second then builds.
Run from a bmad-loop checkout: uv run python repro_casetwin.py <twin|control> [cli]
(with `cli`: build the same sandbox with a tickets-mode policy and run only `validate` and `run --dry-run`)"""
import json, os, subprocess, sys
from pathlib import Path

mode = sys.argv[1]
second = "a1" if mode == "twin" else "B1"
base = Path(os.environ.get("TEMP", "/tmp")).resolve() / "casetwin-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, ScmPolicy
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, "x"),)),))
(lay.initiative_folder / "epic-cart" / "tickets.toml").write_text(
    '[[entry]]\nid = "A1"\ntype = "story"\ntitle = "Cart model"\n\n'
    f'[[entry]]\nid = "{second}"\ntype = "story"\ntitle = "Cart rules"\n', encoding="utf-8")
C._commit_template(root)
plans = {r: Path(C.run_tickets(lay, "find", r)["plan"]) for r in ("1.A1", f"1.{second}")}

if sys.argv[2:] == ["cli"]:  # the operator's preflight: tickets-mode policy, then validate and run --dry-run
    C.install_build_auto_v7_skill(root)
    stub = root / ".bmad-loop" / "never-run.cmd"  # the profile binary; never executed (no `run`)
    stub.parent.mkdir(parents=True, exist_ok=True)
    stub.write_text("exit 1\n", encoding="utf-8")
    stub.chmod(0o755)
    (root / ".bmad-loop" / "profiles").mkdir()
    (root / ".bmad-loop" / "profiles" / "faketickets.toml").write_text(
        f'name = "faketickets"\nbinary = "{stub.as_posix()}"\nbypass_args = []\nusage_parser = "none"\n'
        'skill_tree = ".claude/skills"\n\n[hooks]\ndialect = "claude-settings-json"\n'
        'config_path = ".claude/settings.json"\nevents = { SessionStart = "SessionStart", Stop = "Stop" }\n',
        encoding="utf-8")
    (root / ".bmad-loop" / "policy.toml").write_text(
        '[adapter]\nname = "faketickets"\n\n[review]\nenabled = false\n\n[gates]\nretrospective = "never"\n\n'
        '[stories]\nsource = "tickets"\n', encoding="utf-8")
    subprocess.run(["git", "-C", str(root), "add", "-A"], check=True)
    subprocess.run(["git", "-C", str(root), "commit", "-q", "-m", "tickets-mode policy"], check=True)
    for argv in (["validate"], ["run", "--dry-run"]):
        p = subprocess.run([sys.executable, "-m", "bmad_loop.cli", *argv, "--project", str(root)],
                           capture_output=True, text=True)
        print(f"$ bmad-loop {' '.join(argv)} --project <sandbox>  -> rc={p.returncode}")
        print("\n".join(l for l in (p.stdout + p.stderr).splitlines()
                        if "FAIL" in l or "1." in l or "predicted" in l or "ticket" in l.lower()))
    sys.exit(0)


def session(spec):
    cwd, ref = Path(spec.cwd), spec.task_id.split("-dev-")[0]
    print(f"session {spec.task_id} cwd={cwd}")
    if ref == "1.A1":  # the first ticket's build crashes, leaving half-done work
        (cwd / "src.txt").write_bytes(b"half-done A1\n")
        return SessionResult(status="crashed")
    here = cwd / plans[ref].relative_to(root)
    (cwd / f"{ref}.txt").write_bytes(b"built\n")
    here.write_bytes(f"---\nticket: {ref[2:]}\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(here), "status": "built"})


run_dir = root / ".bmad-loop" / "runs" / "r1"
state = RunState(run_id="r1", project=str(root), started_at="now",
                 initiative=lay.initiative, initiative_folder=str(lay.initiative_folder))
state.max_stories = 2
policy = Policy(gates=GatesPolicy(mode="none"), notify=NotifyPolicy(desktop=False, file=True),
                review=ReviewPolicy(enabled=False), scm=ScmPolicy(isolation="worktree", keep_failed=True))
TicketsEngine(paths=load_paths(root, want_tickets=True), policy=policy, adapter=MockAdapter([session] * 4),
              run_dir=run_dir, journal=Journal(run_dir), state=state).run()
for k, t in load_state(run_dir).tasks.items():
    print(f"task {k}: phase={t.phase.value} branch={t.branch} worktree={t.worktree_path}")
for line in (run_dir / "journal.jsonl").read_text(encoding="utf-8").splitlines():
    e = json.loads(line)
    if e["kind"] in ("unit-closed", "worktree-opened", "isolation-flip-orphan-preserved", "worktree-kept"):
        print(e["kind"], {k: e[k] for k in ("story_key", "kept", "path", "ref") if k in e})
print("ATTENTION:", [l for l in (run_dir / "ATTENTION").read_text(encoding="utf-8").splitlines() if "deferred" in l])
git = lambda *a: subprocess.run(["git", "-C", str(root), *a], capture_output=True, text=True).stdout.strip()
print("refs:", git("for-each-ref", "--format=%(refname)").split())
print("worktrees:", [l for l in git("worktree", "list").splitlines()])
print("failed patch:", sorted(p.relative_to(run_dir).as_posix() for p in (run_dir / "failed").rglob("*") if p.is_file()))
print("ATTENTION names the orphan ref:", "orphan" in (run_dir / "ATTENTION").read_text(encoding="utf-8"))

Observed (Windows, PowerShell 7.6.6; 2 of 2 runs, identical apart from hashes and timestamps; 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_casetwin.py control cli
warning: in the working copy of '_bmad/method/scripts/tickets.py', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '_bmad/scripts/config_utils.py', LF will be replaced by CRLF the next time Git touches it
$ bmad-loop validate --project <sandbox>  -> rc=1
  ok: policy OK: gates=per-epic, adapter dev=faketickets, review=faketickets, triage=faketickets, retro=faketickets
  ok: BMAD v7 ticket tree: _bmad/method/scripts/tickets.py (method module 7.0.0), initiative initiative-demo
  ok: ticket store T1: $TEMP\casetwin-repro\control\_bmad-output (tracked inside the code checkout, versioned by the code repo)
  ok: tickets.py capability not probed — it executes the project's script; pass --probes to run it
  ok: bmad-build-auto dispatches from the ticket tree (tickets mode)
  ok: faketickets: adapter kind 'generic' registered
FAIL: bmad-loop hooks not registered for faketickets — run `bmad-loop init --cli faketickets`
FAIL: .claude/skills/bmad-loop-sweep not found — triage sessions would stall at an unknown /bmad-loop-sweep; run `bmad-loop init --force-skills` (it re-copies every bmad-loop-* skill in the tree, overwriting local edits)
$ bmad-loop run --dry-run --project <sandbox>  -> rc=0
tickets mode: initiative initiative-demo — 2 ready of 2 tickets (gates=per-epic)
  1. 1.A1  (no plan)  Cart model
    dev:    $TEMP/casetwin-repro/control/.bmad-loop/never-run.cmd "/bmad-build-auto ticket 1.A1"
    env:    BMAD_LOOP_MODE=1 BMAD_LOOP_STORY_KEY=1.A1
  2. 1.B1  (no plan)  Cart rules
    dev:    $TEMP/casetwin-repro/control/.bmad-loop/never-run.cmd "/bmad-build-auto ticket 1.B1"
    env:    BMAD_LOOP_MODE=1 BMAD_LOOP_STORY_KEY=1.B1
predicted: no pause predicted before 1.A1 finishes
rc=0  (6s)
### uv run python repro_casetwin.py twin cli
warning: in the working copy of '_bmad/method/scripts/tickets.py', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of '_bmad/scripts/config_utils.py', LF will be replaced by CRLF the next time Git touches it
$ bmad-loop validate --project <sandbox>  -> rc=1
  ok: policy OK: gates=per-epic, adapter dev=faketickets, review=faketickets, triage=faketickets, retro=faketickets
  ok: BMAD v7 ticket tree: _bmad/method/scripts/tickets.py (method module 7.0.0), initiative initiative-demo
  ok: ticket store T1: $TEMP\casetwin-repro\twin\_bmad-output (tracked inside the code checkout, versioned by the code repo)
  ok: tickets.py capability not probed — it executes the project's script; pass --probes to run it
  ok: bmad-build-auto dispatches from the ticket tree (tickets mode)
  ok: faketickets: adapter kind 'generic' registered
FAIL: bmad-loop hooks not registered for faketickets — run `bmad-loop init --cli faketickets`
FAIL: .claude/skills/bmad-loop-sweep not found — triage sessions would stall at an unknown /bmad-loop-sweep; run `bmad-loop init --force-skills` (it re-copies every bmad-loop-* skill in the tree, overwriting local edits)
$ bmad-loop run --dry-run --project <sandbox>  -> rc=0
tickets mode: initiative initiative-demo — 2 ready of 2 tickets (gates=per-epic)
  1. 1.A1  (no plan)  Cart model
    dev:    $TEMP/casetwin-repro/twin/.bmad-loop/never-run.cmd "/bmad-build-auto ticket 1.A1"
    env:    BMAD_LOOP_MODE=1 BMAD_LOOP_STORY_KEY=1.A1
  2. 1.a1  (no plan)  Cart rules
    dev:    $TEMP/casetwin-repro/twin/.bmad-loop/never-run.cmd "/bmad-build-auto ticket 1.a1"
    env:    BMAD_LOOP_MODE=1 BMAD_LOOP_STORY_KEY=1.a1
predicted: no pause predicted before 1.A1 finishes
rc=0  (5s)
### uv run python repro_casetwin.py control
session 1.A1-dev-1 cwd=$TEMP\casetwin-repro\control\.bmad-loop\runs\r1\worktrees\1.A1
session 1.A1-dev-2 cwd=$TEMP\casetwin-repro\control\.bmad-loop\runs\r1\worktrees\1.A1
session 1.B1-dev-1 cwd=$TEMP\casetwin-repro\control\.bmad-loop\runs\r1\worktrees\1.B1
task 1.A1: phase=deferred branch=bmad-loop/r1/epic-cart/1.A1 worktree=$TEMP\casetwin-repro\control\.bmad-loop\runs\r1\worktrees\1.A1
task 1.B1: phase=done branch=bmad-loop/r1/epic-cart/1.B1 worktree=$TEMP\casetwin-repro\control\.bmad-loop\runs\r1\worktrees\1.B1
worktree-opened {'story_key': '1.A1', 'path': '$TEMP\\casetwin-repro\\control\\.bmad-loop\\runs\\r1\\worktrees\\1.A1'}
unit-closed {'story_key': '1.A1', 'kept': True}
worktree-opened {'story_key': '1.B1', 'path': '$TEMP\\casetwin-repro\\control\\.bmad-loop\\runs\\r1\\worktrees\\1.B1'}
worktree-kept {'story_key': '1.A1', 'path': '$TEMP\\casetwin-repro\\control\\.bmad-loop\\runs\\r1\\worktrees\\1.A1'}
ATTENTION: ['[2026-10-18 15:30:43] story deferred: 1.A1: dev session crashed — failed work kept on branch `bmad-loop/r1/epic-cart/1.A1` — an earlier rolled-back attempt is parked at `refs/attempt-preserve-dirty/r1-9ddb151b-1`', '[2026-10-18 15:30:47] bmad-loop run finished: run r1: 1 done, 1 deferred, 0 escalated, 0 tokens']
refs: ['refs/attempt-preserve-dirty/r1-9ddb151b-1', 'refs/heads/bmad-loop/r1/epic-cart/1.A1', 'refs/heads/main']
worktrees: ['$TEMP/casetwin-repro/control                                    dbf732a [main]', '$TEMP/casetwin-repro/control/.bmad-loop/runs/r1/worktrees/1.A1  9ddb151 [bmad-loop/r1/epic-cart/1.A1]']
failed patch: ['failed/1.A1/changes.patch']
ATTENTION names the orphan ref: False
rc=0  (8s)
### uv run python repro_casetwin.py twin
session 1.A1-dev-1 cwd=$TEMP\casetwin-repro\twin\.bmad-loop\runs\r1\worktrees\1.A1
session 1.A1-dev-2 cwd=$TEMP\casetwin-repro\twin\.bmad-loop\runs\r1\worktrees\1.A1
session 1.a1-dev-1 cwd=$TEMP\casetwin-repro\twin\.bmad-loop\runs\r1\worktrees\1.A1
task 1.A1: phase=deferred branch=bmad-loop/r1/epic-cart/1.A1 worktree=$TEMP\casetwin-repro\twin\.bmad-loop\runs\r1\worktrees\1.A1
task 1.a1: phase=done branch=bmad-loop/r1/epic-cart/1.a1 worktree=$TEMP\casetwin-repro\twin\.bmad-loop\runs\r1\worktrees\1.A1
worktree-opened {'story_key': '1.A1', 'path': '$TEMP\\casetwin-repro\\twin\\.bmad-loop\\runs\\r1\\worktrees\\1.A1'}
unit-closed {'story_key': '1.A1', 'kept': True}
isolation-flip-orphan-preserved {'story_key': '1.a1', 'ref': 'refs/attempt-preserve-dirty/r1-56b35d17-orphan'}
worktree-opened {'story_key': '1.a1', 'path': '$TEMP\\casetwin-repro\\twin\\.bmad-loop\\runs\\r1\\worktrees\\1.A1'}
ATTENTION: ['[2026-10-18 15:30:52] story deferred: 1.A1: dev session crashed — failed work kept on branch `bmad-loop/r1/epic-cart/1.A1` — an earlier rolled-back attempt is parked at `refs/attempt-preserve-dirty/r1-56b35d17-1`', '[2026-10-18 15:30:57] bmad-loop run finished: run r1: 1 done, 1 deferred, 0 escalated, 0 tokens']
refs: ['refs/attempt-preserve-dirty/r1-56b35d17-1', 'refs/attempt-preserve-dirty/r1-56b35d17-orphan', 'refs/heads/main']
worktrees: ['$TEMP/casetwin-repro/twin  1369499 [main]']
failed patch: ['failed/1.A1/changes.patch']
ATTENTION names the orphan ref: False
rc=0  (10s)

In the twin run there is no worktree-kept record, and the kept 1.A1 worktree and the bmad-loop/r1/epic-cart/1.A1 branch no longer exist. The second ticket's session ran in, and its task records, the first ticket's mount path. The validate FAILs (hooks not registered, sweep skill missing) are the stub sandbox's and appear in the control too.

Loose refs on NTFS (observed, plain git 2.49.0.windows.1 in a scratch repo, core.ignorecase=true): after git branch x/1.A1, git rev-parse --verify refs/heads/x/1.a1 prints the x/1.A1 sha, and git branch -D x/1.a1 leaves only refs/heads/main.

Expected vs actual

actual (twin) expected (the A1/B1 control; the Linux run)
deferred 1.A1, keep_failed = true worktree reclaimed by 1.a1, branch gone, ATTENTION names a branch that does not exist and not the orphan ref worktree and branch kept (worktree-kept), as keep_failed documents ("worktree mode: keep a failed unit's worktree + branch mounted for inspection", docs/reference/configuration.md)
run --dry-run / validate both tickets listed by dry-run; no warning from either refused or warned up front, as stories mode rejects case-only IDs

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 and timestamps. Lines are unchanged:

### uv run python repro_casetwin.py twin cli
$ bmad-loop validate --project <sandbox>  -> rc=1
  ok: policy OK: gates=per-epic, adapter dev=faketickets, review=faketickets, triage=faketickets, retro=faketickets
  ok: BMAD v7 ticket tree: _bmad/method/scripts/tickets.py (method module 7.0.0), initiative initiative-demo
  ok: ticket store T1: /tmp/casetwin-repro/twin/_bmad-output (tracked inside the code checkout, versioned by the code repo)
  ok: tickets.py capability not probed — it executes the project's script; pass --probes to run it
  ok: bmad-build-auto dispatches from the ticket tree (tickets mode)
  ok: faketickets: adapter kind 'generic' registered
FAIL: bmad-loop hooks not registered for faketickets — run `bmad-loop init --cli faketickets`
FAIL: .claude/skills/bmad-loop-sweep not found — triage sessions would stall at an unknown /bmad-loop-sweep; run `bmad-loop init --force-skills` (it re-copies every bmad-loop-* skill in the tree, overwriting local edits)
$ bmad-loop run --dry-run --project <sandbox>  -> rc=0
tickets mode: initiative initiative-demo — 2 ready of 2 tickets (gates=per-epic)
  1. 1.A1  (no plan)  Cart model
    dev:    /tmp/casetwin-repro/twin/.bmad-loop/never-run.cmd "/bmad-build-auto ticket 1.A1"
    env:    BMAD_LOOP_MODE=1 BMAD_LOOP_STORY_KEY=1.A1
  2. 1.a1  (no plan)  Cart rules
    dev:    /tmp/casetwin-repro/twin/.bmad-loop/never-run.cmd "/bmad-build-auto ticket 1.a1"
    env:    BMAD_LOOP_MODE=1 BMAD_LOOP_STORY_KEY=1.a1
predicted: no pause predicted before 1.A1 finishes
rc=0
### uv run python repro_casetwin.py twin
session 1.A1-dev-1 cwd=/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.A1
session 1.A1-dev-2 cwd=/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.A1
session 1.a1-dev-1 cwd=/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.a1
task 1.A1: phase=deferred branch=bmad-loop/r1/epic-cart/1.A1 worktree=/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.A1
task 1.a1: phase=done branch=bmad-loop/r1/epic-cart/1.a1 worktree=/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.a1
worktree-opened {'story_key': '1.A1', 'path': '/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.A1'}
unit-closed {'story_key': '1.A1', 'kept': True}
worktree-opened {'story_key': '1.a1', 'path': '/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.a1'}
worktree-kept {'story_key': '1.A1', 'path': '/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.A1'}
ATTENTION: ['[2026-10-18 15:43:41] story deferred: 1.A1: dev session crashed — failed work kept on branch `bmad-loop/r1/epic-cart/1.A1` — an earlier rolled-back attempt is parked at `refs/attempt-preserve-dirty/r1-023a1723-1`', '[2026-10-18 15:43:42] bmad-loop run finished: run r1: 1 done, 1 deferred, 0 escalated, 0 tokens']
refs: ['refs/attempt-preserve-dirty/r1-023a1723-1', 'refs/heads/bmad-loop/r1/epic-cart/1.A1', 'refs/heads/main']
worktrees: ['/tmp/casetwin-repro/twin                                    d120283 [main]', '/tmp/casetwin-repro/twin/.bmad-loop/runs/r1/worktrees/1.A1  023a172 [bmad-loop/r1/epic-cart/1.A1]']
failed patch: ['failed/1.A1/changes.patch']
ATTENTION names the orphan ref: False
rc=0

The twins do not alias there: each gets its own worktree, and the deferred twin's worktree and branch are kept, like the Windows control. Silent acceptance of the twins by run --dry-run happens on both platforms; the destructive part needs a case-insensitive filesystem (Windows here; macOS not measured).

Source

At a5a8f097. The mount path and the branch both carry the ref verbatim (observed: both twins' paths and branch names above):

# src/bmad_loop/workspace.py:479-480 (open_unit_workspace)
    branch = unit_branch_name(run_id, unit_key, branch_per, epic_segment=epic_segment)
    unresolved_wt = unit_worktrees_dir(run_dir) / safe_segment(unit_key)

safe_segment's docstring leaves case collisions to the caller (platform_util.py:2437-2438: "case-insensitive NTFS collisions between clean names remain the caller's concern"). The open then reclaims whatever stands at wt: workspace.py:508 _preserve_orphan_state(...), then :546 discard_worktree(repo_root, str(wt), "", run_dir=run_dir). worktree_flow.py:2531 journals it as isolation-flip-orphan-preserved. branch_exists (workspace.py:494) sees the twin's branch for 1.a1 through the loose-ref aliasing shown above. That the post-merge branch delete is the step that removes …/1.A1 is source-derived; I did not trace it separately.

Stories mode's guard, which tickets mode lacks (src/bmad_loop/stories.py:162-176):

        folded = entry.id.casefold()
        if folded in seen_folded:
            raise StoriesError(
                f"stories.yaml ids {seen_folded[folded]!r} and {entry.id!r} differ only "
                "by case — story specs resolve by the case-insensitive glob <id>-*.md, so "
                "on a case-insensitive filesystem (Windows/macOS) they would cross-match"
            )

tickets_source.py and tickets_engine.py never fold a ref (grep for casefold/lower over refs: none).

Suggested fix

Not validated: refuse case-only twins among the refs a run would dispatch, as stories.load_stories does, in the tickets preflight, validate and run --dry-run. Alternatively, derive the mount and branch segment from a case-folded ref plus a digest of the original.

Lenguaje dominante
Python
Estrellas
196
Forks
78
Merge medio
9 h 24 min
PR fusionados (30 d)
44

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bmad-code-org/bmad-loop

Todos los issues de bmad-code-org/bmad-loop

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.