tickets: should the `run --dry-run` "NOT runnable" banner mirror the `uv`-on-PATH check? (preview is clean, run refuses)

Ouverte
#970 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
58/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
cli

Piste de recherche

Start in src/bmad_loop/cli.py at _warn_preflight_would_abort and the tickets queue preflight wiring; compare its banner checks with the tickets.uv-missing finding in src/bmad_loop/install.py. The report limits the requested behavior to checking whether uv is on PATH when require_tickets is set. Done means an unavailable uv produces the preflight warning in run --dry-run while the preview still exits 0.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Summary

This is an enhancement request to extend the dry-run banner's documented boundary; the existing queue-preflight exclusion is intentional. In tickets mode, bmad-loop run --dry-run exits 0, prints the build order and predicted: no pause predicted before 1.1 finishes, and prints no "NOT runnable" banner when uv is not on PATH, while bmad-loop run on the same project refuses with FAIL: uv not found on PATH and exits 1. The banner's docstring deliberately leaves the queue preflights out, and tickets mode's uv check lives in its queue preflight, so this is the documented boundary rather than a slip in the code; the question this issue asks is whether uv on PATH should cross it, because it is a fact about the host, which is the docstring's own reason for putting the git floor in the banner. An operator who previews before an unattended run otherwise gets a clean preview of a run that cannot start.

Environment

bmad-loop a5a8f097, Windows 11 10.0.26200, PowerShell 7.6.6 (SHELL unset), Python 3.13.2 (the checkout's .venv), uv 0.11.28 removed from PATH for the failing row; run driven through cli.main with every adapter replaced by an empty MockAdapter, so no coding CLI can start; Linux: same symptom (Ubuntu under WSL, Python 3.13.2, git 2.43.0)

Steps to reproduce

From a bmad-loop checkout at a5a8f097 after uv sync --all-extras, in PowerShell 7 with the checkout as the current directory; the script removes SHELL first and runs as-is from that shell. The script builds a committed one-ticket v7 tickets project with the test suite's own helpers (tests/conftest.py), then runs run --dry-run and run with uv on PATH (control) and without it. run goes through cli.main with cli._make_adapters returning empty MockAdapters, so the control row stops at its first session (ScriptExhausted, the harness's own stop) and no coding CLI is ever started; a plain bmad-loop run --project <p> behaves the same up to the first session. The uvless row checks that uv is gone and git still runs before it measures anything.

Remove-Item Env:SHELL -ErrorAction SilentlyContinue
$env:PYTHONUTF8 = '1'
$Root = Join-Path $env:TEMP 'bl-tickets-dryrun'
$env:BMAD_LOOP_STATE_DIR = Join-Path $Root 'state'
Remove-Item -Recurse -Force $Root -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force $Root | Out-Null
$utf8 = [Text.UTF8Encoding]::new($false)
[IO.File]::WriteAllText("$Root\build.py", @'
import sys
from pathlib import Path
sys.path.insert(0, "tests")
import conftest as c
dest = Path(sys.argv[1])
dest.mkdir(parents=True)
(dest / "src.txt").write_text("original\n", encoding="utf-8")
(dest / ".gitignore").write_text(c.V7_GITIGNORE, encoding="utf-8")
layout = c.install_bmad_v7(dest)
c.write_ticket_tree(layout, (c.EpicSpec(1, "epic-cart", "Cart", (c.EntrySpec(1, "Cart model"),)),))
c.install_build_auto_v7_skill(dest)
(dest / ".bmad-loop").mkdir(exist_ok=True)
(dest / ".bmad-loop" / "policy.toml").write_text('[adapter]\nname = "claude"\nmodel = "opus"\n\n[stories]\nsource = "tickets"\n', encoding="utf-8")
c._commit_template(dest)
'@, $utf8)
[IO.File]::WriteAllText("$Root\run.py", @'
import sys
from bmad_loop import cli
from bmad_loop.adapters.mock import MockAdapter
handed = []
def make(*a, **k):
    out = {r: MockAdapter([]) for r in cli.ROLES}
    handed.extend(out.values())
    return out
cli._make_adapters = make
rc = cli.main(["run", "--project", sys.argv[1]])
print(f"rc={rc} sessions dispatched={[s.task_id for a in handed for s in a.sessions]}")
'@, $utf8)
$gitBefore = git --version
foreach ($cond in @('control', 'uvless')) {
  $p = Join-Path $Root $cond
  uv run python "$Root\build.py" $p | Out-Null
  $savedPath = $env:PATH
  try {
    if ($cond -eq 'uvless') {  # drop every PATH entry holding uv.exe; python is called by full path
      $env:PATH = (($env:PATH -split ';') | Where-Object { $_ -and -not (Test-Path (Join-Path $_ 'uv.exe')) }) -join ';'
      if (Get-Command uv -ErrorAction SilentlyContinue) { throw 'uv is still on PATH' }
      if ((git --version) -ne $gitBefore) { throw 'git changed or vanished with uv: build a PATH that keeps git' }
    }
    "`n=== ${cond}: run --dry-run"
    & .\.venv\Scripts\python.exe -m bmad_loop.cli run --dry-run --project $p 2>&1 | Select-String 'predicted|NOT runnable|FAIL'
    "rc=$LASTEXITCODE"
    "=== ${cond}: run"
    & .\.venv\Scripts\python.exe "$Root\run.py" $p 2>&1 | Select-String 'rc=|PAUSED|FAIL|CRASHED'
  } finally { $env:PATH = $savedPath }  # the caller's PATH comes back even when a guard throws
}

Output (this script as written, 2 of 2 runs identical except that the uvless run row's stderr FAIL: line and its stdout rc= line arrive in either order):

=== control: run --dry-run
predicted: no pause predicted before 1.1 finishes
rc=0
=== control: run
CRASHED: ScriptExhausted: no scripted result for session 1.1-dev-1
rc=0 sessions dispatched=['1.1-dev-1']

=== uvless: run --dry-run
predicted: no pause predicted before 1.1 finishes
rc=0
=== uvless: run
rc=1 sessions dispatched=[]
FAIL: uv not found on PATH — bmad-build-auto runs tickets.py with `uv run`; install uv (https://docs.astral.sh/uv/)

The control row shows the preview and the run agree when uv is present (the run reaches its first session). Without uv the preview is unchanged and has no banner, while the run refuses before creating a session.

Expected vs actual

actual proposed
run --dry-run, uv not on PATH rc 0, build order, predicted: no pause predicted before 1.1 finishes, no banner note: this preview is NOT runnable as-is — the real command aborts at preflight: with FAIL: uv not found on PATH …, as the banner prints for the git floor (rc stays 0 by design)
run, same project rc 1, FAIL: uv not found on PATH … same

Linux

Same result on Linux (Ubuntu under WSL, Python 3.13.2, git 2.43.0, uv removed from PATH for the uvless row), the same harness run from a git archive of a5a8f097 with its own venv, 2 of 2 passes. Reported uvless output from the first Linux pass (the omitted lines are the build-order block, which is identical to the control row, and lines carrying sandbox paths):

uv on PATH: []
--- dry-run
rc=0
predicted: no pause predicted before 1.1 finishes
groups: ready_to_refine=0 ready_to_start=1 in_progress=0 blocked=0 backlog=0
stderr:
--- run (harness)
rc=1
--- stderr
FAIL: uv not found on PATH — bmad-build-auto runs tickets.py with `uv run`; install uv (https://docs.astral.sh/uv/)
run `bmad-loop validate --probes` for details
adapters handed=0 sessions=[]
verdict: NO-DISPATCH

The reported Linux control with uv on PATH predicts the same line and reaches session 1.1-dev-1. The Windows and Linux transcripts show the same symptom for these environments.

Source

At a5a8f097. Observed: the banner is absent and run refuses at the tickets preflight. Source-derived: why.

The banner states its boundary in its docstring: the exclusion (src/bmad_loop/cli.py:2233-2234)

    as a `FAIL:` line would promise an abort that never comes. The dirty-tree, queue
    and run-id gates are deliberately not part of this banner.

and the reason a host fact is mirrored anyway (cli.py:2224-2226):

    The git floor belongs here for the reason the dirty-tree and queue gates do
    NOT: it is a fact about the HOST, so it cannot come true between this preview
    and the real command the way cleaning a tree can. Both of its arms are

Its problem list (cli.py:2260-2291) is skill findings, ticketstore.store_conflict, the isolation conflict, the git floor, unknown adapter kinds and plugin trust, and never install.tickets_preflight. The tickets preflight is wired in as the tickets queue preflight (cli.py:3700-3706, called at cli.py:3759):

_RUN_PREFLIGHTS: dict[
    str, Callable[[bmadconfig.ProjectPaths, Any, argparse.Namespace, str], int | None]
] = {
    worksource.SOURCE_SPRINT: _preflight_sprint_queue,
    worksource.SOURCE_STORIES: _preflight_stories_queue,
    worksource.SOURCE_TICKETS: _preflight_tickets_queue,
}

and its uv check is a host fact (src/bmad_loop/install.py:913-922):

    if shutil.which("uv") is None:
        findings.append(
            Finding(
                "tickets.uv-missing",
                "problem",
                "uv not found on PATH — bmad-build-auto runs tickets.py with `uv run`; "
                "install uv (https://docs.astral.sh/uv/)",
                None,
            )
        )

The dry-run itself works without uv because the script runs on the current interpreter when its requires-python is met (src/bmad_loop/tickettree.py:338-340):

        spec = ticketmodel.parse_requires_python(self._script_text())
        if ticketmodel.requires_python_satisfied(spec, _running_version()):
            return [sys.executable, "-I", "-B", "-X", "utf8"], None

Source-derived: the missing-uv check is outside the preview path, while this fixture's tickets.py can run on the current interpreter. Other tickets_preflight findings, including its capability probe, were not independently tested here; this request is limited to surfacing tickets.uv-missing.

Suggested enhancement

A scratch-copy feasibility check confirmed that adding only the tickets.uv-missing finding to the banner makes the warning appear while keeping rc 0; a production change and its broader regression coverage were not implemented. In _warn_preflight_would_abort, when require_tickets is set, add the tickets.uv-missing problem (the same shutil.which("uv") test install.tickets_preflight uses, with no capability probe and no exit-code change), and say in the docstring that this one host fact of the tickets queue preflight is mirrored. With it, the uvless preview prints note: this preview is NOT runnable as-is — the real command aborts at preflight: / FAIL: uv not found on PATH …, and rc stays 0.

Langage dominant
Python
Étoiles
196
Forks
78
Merge moyen
9 h 24 min
PR mergées (30 j)
44

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de bmad-code-org/bmad-loop

Toutes les issues de bmad-code-org/bmad-loop

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.