Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ breaking changes may land in a minor release.

### Fixed

- Recognize TOML-based TEA setup and enforce blocking gates from the current story or ticket's scoped reports.

- Read BMAD v7's `quick_lenses`/`thorough_lenses` review sets in `validate` and the
run preflight, so a v7 project is no longer required to install the deleted
`bmad-review-adversarial-general` and `bmad-review-edge-case-hunter`. A `workflow.review`
Expand Down
79 changes: 28 additions & 51 deletions docs/tea-plugin-guide.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The Test Architect (TEA) plugin

The bundled **`tea`** plugin wires the BMAD **Test Architect Enterprise (TEA)**
module — the "Murat" agent and its `bmad-testarch-*` workflows — into every
module into every
bmad-loop run and sweep as **advisory-by-default quality steps**. It injects
six TEA sessions across the pipeline (test-design, ATDD, automate after dev;
trace, NFR, test-review just before commit), and an operator can flip any of the
Expand All @@ -20,20 +20,9 @@ TEA-specific slice.

## Prerequisite: install TEA in your project

The plugin **orchestrates** TEA; it does not bundle it. You install TEA once, per
project, with the BMAD installer:

```bash
npx bmad-method install # choose "Test Architect" (Enterprise)
```

That writes TEA's runtime to `_bmad/tea/config.yaml` plus its compiled per-CLI
commands (`.claude/commands/bmad/tea/*`, and the equivalent under `.agents/`,
`.gemini/`, `.agent/`). The plugin's **readiness gate** checks for
`_bmad/tea/config.yaml` at startup and **fails the run fast** with a remediation
message if it's missing (see [Readiness gate](#readiness-gate) below) — so an
operator who enables `tea` without installing TEA learns immediately instead of
watching six sessions flail.
Install the [TEA skills](https://github.com/bmad-code-org/bmad-method-test-architecture-enterprise) in your project and run `bmad setup tea` in your coding assistant.
Setup writes the `[modules.tea]` table to `_bmad/config.toml`.
Loop also recognizes classic installs with `_bmad/tea/config.yaml`.

## Enabling the plugin

Expand All @@ -60,14 +49,14 @@ TEA work injects at **two** lifecycle stages that have a live worktree
Each step runs as an extra agent session through the `dev` or `review` adapter,
with `workflow-start` / `workflow-end` journal entries.

| Step | TEA workflow | Stage | Adapter | What it does |
| ---------- | --------------------------- | ----------------- | ------- | ---------------------------------------------------------------------- |
| `td` | `bmad-testarch-test-design` | `post_dev_phase` | dev | Risk assessment + risk-based coverage strategy for the change. |
| `atdd` | `bmad-testarch-atdd` | `post_dev_phase` | dev | Failing acceptance tests + an implementation checklist. |
| `automate` | `bmad-testarch-automate` | `post_dev_phase` | dev | Prioritized API/E2E tests, fixtures, and a Definition-of-Done summary. |
| `trace` | `bmad-testarch-trace` | `pre_commit_gate` | review | Map requirements → tests and record the quality-gate decision. |
| `nfr` | `bmad-testarch-nfr` | `pre_commit_gate` | review | Assess non-functional requirements and record the gate decision. |
| `review` | `bmad-testarch-test-review` | `pre_commit_gate` | review | Quality-check the written tests against TEA's knowledge base. |
| Step | TEA workflow | Stage | Adapter | What it does |
| ---------- | ------------------------------ | ----------------- | ------- | ---------------------------------------------------------------------- |
| `td` | `bmad-tea-test-design` | `post_dev_phase` | dev | Risk assessment + risk-based coverage strategy for the change. |
| `atdd` | `bmad-tea-automate` (red mode) | `post_dev_phase` | dev | Failing acceptance tests + an implementation checklist. |
| `automate` | `bmad-tea-automate` | `post_dev_phase` | dev | Prioritized API/E2E tests, fixtures, and a Definition-of-Done summary. |
| `trace` | `bmad-tea-trace` | `pre_commit_gate` | review | Map requirements → tests and record the quality-gate decision. |
| `nfr` | `bmad-tea-nfr` | `pre_commit_gate` | review | Assess non-functional requirements and record the gate decision. |
| `review` | `bmad-tea-test-review` | `pre_commit_gate` | review | Quality-check the written tests against TEA's knowledge base. |

The three `post_dev_phase` steps run **after** the dev phase, in the order above;
the three `pre_commit_gate` steps run **just before the commit**. That stage fires
Expand All @@ -76,10 +65,7 @@ on **every** path into a commit — the review-converged path, the skip path
`post_review_result` never fires because the review loop never runs), and the
review-budget rescue — so the gates always evaluate the exact tree about to
commit, and the `*_blocking` flags enforce even on stories that skip the review
loop. Each prompt is **CLI-agnostic** — natural-language intent plus the explicit
`bmad-testarch-*` workflow name, phrased around "the changes currently in the
working tree for `{story_key}`" so the same step works for a single story **and**
a sweep bundle.
loop. Gate prompts name the story spec or ticket ref as the target.

### Runs and sweeps, no extra wiring

Expand Down Expand Up @@ -121,23 +107,18 @@ the orchestrator review loop entirely.
When you mark a gate blocking (e.g. `nfr_blocking = true`), at commit time the
plugin:

1. Locates that gate's latest artifact under TEA's configured `test_artifacts`
directory (read from `_bmad/tea/config.yaml`; falls back to the installer
default `_bmad-output/test-artifacts`).
2. Parses the gate verdict — from the trace gate's JSON, or the
`## Gate Decision` / `**Gate Status**` / `**Recommendation**` line of the NFR
and test-review markdown reports.
3. On a **FAIL** or **CONCERNS** verdict, vetoes the commit with `pause` — the
unit **escalates for human review** instead of landing. (`pre_commit` honors
only a `pause` veto, which is the right "blocking gate failed" semantic.)
`PASS` and `WAIVED` never block.

**Enforcement is fail-open by design.** A gate with no blocking flag, no artifact,
or an artifact that can't be parsed into a known verdict **never** blocks the
commit — an unknown format must never wrongly stop a commit. Only a
confidently-parsed FAIL/CONCERNS on an operator-marked-blocking gate escalates.
The verdicts the plugin did read are recorded on the shared context (`tea_gates`)
as a breadcrumb for the journal.
1. Reads `[modules.tea].test_artifacts` from `_bmad/config.toml`, applying team and user overrides from `_bmad/custom/`.
The default is `_bmad-output/test-artifacts`.
2. Looks up the current story or ticket's exact report in `trace/`, `nfr/`, or `test-review/`.
Trace prefers the gate decision JSON, then the summary JSON, then the matrix.
3. Pauses for human review on **FAIL** or **CONCERNS**.
Missing, unreadable, and unevaluated results leave the commit path open.
The hook records recognized verdicts in the shared context under `tea_gates`.

For classic installs, Loop reads `test_artifacts` from `_bmad/tea/config.yaml` and accepts the legacy flat files when the unit has no scoped report for that gate.
With central TEA configuration, Loop reads only scoped reports.
Sweep bundles without a story or ticket can still run the workflows for advisory evidence.
Loop leaves their current-format gates unevaluated because a system-wide report cannot identify a specific bundle.

## Worktree seeding

Expand All @@ -147,7 +128,7 @@ or not guaranteed in a fresh checkout, so the plugin declares `seed_globs` to

```toml
seed_globs = [
"_bmad/**", # TEA runtime: config.yaml + testarch workflows + knowledge base
"_bmad/**", # TEA runtime: config, scripts, and knowledge base
".claude/skills/bmad-t*", # compiled TEA skills for claude-code
".agents/skills/bmad-t*", # codex / cursor compiled skill home
".gemini/skills/bmad-t*", # gemini compiled skill home
Expand All @@ -173,9 +154,5 @@ The canonical source lives at `src/bmad_loop/data/plugins/tea/`:

### Readiness gate

With `require_tea` on (the default), `TeaPlugin.validate` refuses to start the run
unless `_bmad/tea/config.yaml` is present, raising a `PluginError` that names the
missing file and tells the operator to either run `npx bmad-method install` →
Test Architect, or set `require_tea = false` to run the steps advisory-only. Turn
`require_tea` off when you deliberately want the prompts to degrade gracefully
(e.g. on a CLI where TEA isn't installed) rather than gate the whole run.
With `require_tea` on (the default), Loop checks the selected project's TEA setup before starting the run.
Run `bmad setup tea` to configure TEA, or set `require_tea = false` to skip the startup check.
15 changes: 15 additions & 0 deletions src/bmad_loop/bmadconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,21 @@ def read_core_value(project: Path, key: str) -> tuple[str, str] | None:
return None if central is None else _core_value(central, key)


def read_module_config(project: Path, module: str) -> dict[str, object] | None:
"""Read a module's settings from the three current central config layers."""
central = _load_central(project, V7_CENTRAL_LAYERS_REL)
modules = central.get("modules") if central is not None else None
if not isinstance(modules, _Table):
return None
table = modules.get(module)
if table is None:
return None
if not isinstance(table, _Table):
assert isinstance(table, _Leaf)
raise BmadConfigError(f"`modules.{module}` in {table.layer} must be a table")
return {key: node.value if isinstance(node, _Leaf) else node for key, node in table.items()}


def active_initiative(project: Path) -> str | None:
"""The project's live ``[core] active_initiative`` (stripped, as `tickets.py`
strips it), or None when none is active. Read fresh on every call: the value is
Expand Down
32 changes: 16 additions & 16 deletions src/bmad_loop/data/plugins/tea/plugin.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Bundled Test Architect Enterprise (TEA) plugin for bmad-loop.
#
# Wires the BMAD "Test Architect Enterprise" module (the "Murat" agent + its
# `bmad-testarch-*` workflows) into every run and sweep as advisory-by-default
# `bmad-tea-*` skills) into every run and sweep as advisory-by-default
# quality steps. It assumes TEA is already installed in the project
# (`npx bmad-method install` -> Test Architect), and orchestrates by injecting
# (install its skills and run `bmad setup tea`), and orchestrates by injecting
# natural-language sessions that invoke the relevant TEA workflow at two
# stages that have a live worktree:
#
Expand Down Expand Up @@ -46,7 +46,7 @@ author = "bmad-loop"
# a fresh checkout, so prime them into an isolated per-worktree checkout. No-ops
# under today's in-place (isolation = none) mode; needed once worktrees are used.
seed_globs = [
"_bmad/**", # TEA runtime: config.yaml + testarch workflows + knowledge base
"_bmad/**", # TEA runtime: config, scripts, and knowledge base
".claude/skills/bmad-t*", # compiled TEA skills for claude-code (bmad-tea + bmad-testarch-*)
".agents/skills/bmad-t*", # codex/cursor compiled skill home
".gemini/skills/bmad-t*", # gemini compiled skill home
Expand All @@ -70,7 +70,7 @@ key = "require_tea"
type = "bool"
default = true
label = "Require TEA installed"
help = "Fail fast at startup if the project has no _bmad/tea/config.yaml (TEA not installed). false = run anyway."
help = "Require [modules.tea] in BMAD's TOML config or a legacy _bmad/tea/config.yaml at startup."

# Per-step enable flags (workflow-overlay convention: <name>_enabled). Every
# step ships on; set one false to drop just that workflow.
Expand All @@ -79,42 +79,42 @@ key = "td_enabled"
type = "bool"
default = true
label = "Enable test-design (TD)"
help = "post_dev_phase: risk assessment + coverage strategy for the changes (bmad-testarch-test-design)."
help = "post_dev_phase: risk assessment + coverage strategy for the changes (bmad-tea-test-design)."

[[settings]]
key = "atdd_enabled"
type = "bool"
default = true
label = "Enable ATDD (AT)"
help = "post_dev_phase: failing acceptance tests + implementation checklist (bmad-testarch-atdd)."
help = "post_dev_phase: failing acceptance tests + implementation checklist (bmad-tea-automate)."

[[settings]]
key = "automate_enabled"
type = "bool"
default = true
label = "Enable automate (TA)"
help = "post_dev_phase: prioritized API/E2E tests, fixtures, DoD summary (bmad-testarch-automate)."
help = "post_dev_phase: prioritized API/E2E tests, fixtures, DoD summary (bmad-tea-automate)."

[[settings]]
key = "trace_enabled"
type = "bool"
default = true
label = "Enable trace (TR)"
help = "pre_commit_gate: map requirements to tests + record the quality-gate decision (bmad-testarch-trace)."
help = "pre_commit_gate: map requirements to tests + record the quality-gate decision (bmad-tea-trace)."

[[settings]]
key = "nfr_enabled"
type = "bool"
default = true
label = "Enable NFR (NR)"
help = "pre_commit_gate: assess non-functional requirements + record the gate decision (bmad-testarch-nfr)."
help = "pre_commit_gate: assess non-functional requirements + record the gate decision (bmad-tea-nfr)."

[[settings]]
key = "review_enabled"
type = "bool"
default = true
label = "Enable test-review (RV)"
help = "pre_commit_gate: quality check against the written tests (bmad-testarch-test-review)."
help = "pre_commit_gate: quality check against the written tests (bmad-tea-test-review)."

# Per-gate blocking flags (workflow-overlay convention: <name>_blocking). The
# gate steps ship advisory; flip one true so a FAIL/CONCERNS verdict escalates
Expand Down Expand Up @@ -150,35 +150,35 @@ help = "true = a failing test-review gate escalates the unit at commit instead o
[workflows.td]
stage = "post_dev_phase"
role = "dev"
prompt = "Run the TEA Test Design workflow (skill `bmad-testarch-test-design`) for `{story_key}`. Produce a risk assessment and a risk-based coverage strategy for the changes currently in the working tree, and write the artifacts under TEA's configured test_artifacts directory. Do not modify production code."
prompt = "Run the TEA Test Design workflow (skill `bmad-tea-test-design`, or legacy `bmad-testarch-test-design` if installed) for `{story_key}`. Produce a risk assessment and a risk-based coverage strategy for the changes currently in the working tree, and write the artifacts under TEA's configured test_artifacts directory. Do not modify production code."
blocking = false

[workflows.atdd]
stage = "post_dev_phase"
role = "dev"
prompt = "Run the TEA ATDD workflow (skill `bmad-testarch-atdd`) for `{story_key}`. Generate failing acceptance tests plus an implementation checklist covering the changes currently in the working tree, written under TEA's configured test_artifacts directory."
prompt = "Run the TEA ATDD workflow (red mode in `bmad-tea-automate`, or legacy `bmad-testarch-atdd` if installed) for `{story_key}`. Generate failing acceptance tests plus an implementation checklist covering the changes currently in the working tree, written under TEA's configured test_artifacts directory."
blocking = false

[workflows.automate]
stage = "post_dev_phase"
role = "dev"
prompt = "Run the TEA Test Automation workflow (skill `bmad-testarch-automate`) for `{story_key}`. Generate prioritized API/E2E tests and fixtures for the changes currently in the working tree, plus a Definition-of-Done summary, under TEA's configured test_artifacts directory."
prompt = "Run the TEA Test Automation workflow (skill `bmad-tea-automate`, or legacy `bmad-testarch-automate` if installed) for `{story_key}`. Generate prioritized API/E2E tests and fixtures for the changes currently in the working tree, plus a Definition-of-Done summary, under TEA's configured test_artifacts directory."
blocking = false

[workflows.trace]
stage = "pre_commit_gate"
role = "review"
prompt = "Run the TEA Trace Requirements workflow (skill `bmad-testarch-trace`) for `{story_key}`. Map the requirements to the tests covering the changes currently in the working tree and record the quality-gate decision under TEA's configured test_artifacts directory."
prompt = "Run the TEA Trace Requirements workflow (skill `bmad-tea-trace`, or legacy `bmad-testarch-trace` if installed) for `{unit_ref}`. When this unit is a story or ticket, use it as the explicit story target. Map the requirements to the tests covering the changes currently in the working tree and record the quality-gate decision under TEA's configured test_artifacts directory."
blocking = false

[workflows.nfr]
stage = "pre_commit_gate"
role = "review"
prompt = "Run the TEA Non-Functional Requirements workflow (skill `bmad-testarch-nfr`) for `{story_key}`. Assess the NFRs of the changes currently in the working tree and record the gate decision under TEA's configured test_artifacts directory."
prompt = "Run the TEA Non-Functional Requirements workflow (skill `bmad-tea-nfr`, or legacy `bmad-testarch-nfr` if installed) for `{unit_ref}`. When this unit is a story or ticket, use it as the explicit story target. Assess the NFRs of the changes currently in the working tree and record the gate decision under TEA's configured test_artifacts directory."
blocking = false

[workflows.review]
stage = "pre_commit_gate"
role = "review"
prompt = "Run the TEA Test Review workflow (skill `bmad-testarch-test-review`) for `{story_key}`. Perform a quality check against the tests covering the changes currently in the working tree, using TEA's knowledge base and best practices, and record findings under TEA's configured test_artifacts directory."
prompt = "Run the TEA Test Review workflow (skill `bmad-tea-test-review`, or legacy `bmad-testarch-test-review` if installed) for `{unit_ref}`. When this unit is a story or ticket, use it as the explicit story target. Perform a quality check against the tests covering the changes currently in the working tree, using TEA's knowledge base and best practices, and record findings at TEA's default scoped report path under its configured test_artifacts directory."
blocking = false
Loading
Loading