bmad-method-test-architecture-enterprise 3.4.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/cli/lib/trace-command.js +972 -48
  3. package/cli/lib/trace-live.js +46 -8
  4. package/cli/trace.js +16 -3
  5. package/package.json +1 -1
  6. package/skills/bmad-tea-automate/SKILL.md +1 -0
  7. package/skills/bmad-tea-automate/red/atdd-checklist-template.md +7 -2
  8. package/skills/bmad-tea-automate/red/checklist.md +1 -1
  9. package/skills/bmad-tea-automate/red/resources/atdd-checklist-2-4-guest-checkout.example.md +5 -2
  10. package/skills/bmad-tea-automate/red/steps-c/step-01-preflight-and-context.md +12 -14
  11. package/skills/bmad-tea-automate/red/steps-c/step-01b-resume.md +4 -2
  12. package/skills/bmad-tea-automate/red/steps-c/step-04c-aggregate.md +7 -5
  13. package/skills/bmad-tea-automate/red/steps-c/step-05-validate-and-complete.md +5 -3
  14. package/skills/bmad-tea-automate/steps-c/step-01-preflight-and-context.md +4 -2
  15. package/skills/bmad-tea-automate/steps-c/step-01b-resume.md +2 -0
  16. package/skills/bmad-tea-automate/steps-c/step-02-identify-targets.md +1 -1
  17. package/skills/bmad-tea-evaluate/references/ci.md +2 -2
  18. package/skills/bmad-tea-framework/resources/framework-setup-progress.example.md +1 -1
  19. package/skills/bmad-tea-framework/resources/hooks/tea-enforce.cjs +295 -39
  20. package/skills/bmad-tea-framework/steps-c/step-04-docs-and-scripts.md +2 -2
  21. package/skills/bmad-tea-nfr/SKILL.md +1 -0
  22. package/skills/bmad-tea-nfr/steps-c/step-01-load-context.md +4 -2
  23. package/skills/bmad-tea-nfr/steps-c/step-01b-resume.md +2 -0
  24. package/skills/bmad-tea-test-design/steps-c/step-01-detect-mode.md +4 -1
  25. package/skills/bmad-tea-test-review/SKILL.md +2 -1
  26. package/skills/bmad-tea-test-review/steps-c/step-01-load-context.md +7 -4
  27. package/skills/bmad-tea-test-review/steps-c/step-01b-resume.md +2 -0
  28. package/skills/bmad-tea-trace/SKILL.md +1 -0
  29. package/skills/bmad-tea-trace/checklist.md +20 -1
  30. package/skills/bmad-tea-trace/resources/traceability-matrix.example.md +8 -8
  31. package/skills/bmad-tea-trace/steps-c/step-01-load-context.md +126 -8
  32. package/skills/bmad-tea-trace/steps-c/step-01b-resume.md +16 -4
  33. package/skills/bmad-tea-trace/steps-c/step-02-discover-tests.md +4 -0
  34. package/skills/bmad-tea-trace/steps-c/step-03-map-criteria.md +172 -8
  35. package/skills/bmad-tea-trace/steps-c/step-04-analyze-gaps.md +52 -10
  36. package/skills/bmad-tea-trace/steps-c/step-05-gate-decision.md +81 -10
  37. package/skills/bmad-tea-trace/trace-template.md +50 -3
  38. package/skills/bmod-tea/bmod.toml +1 -1
  39. package/skills/bmod-tea/contracts/story-identity.md +79 -0
  40. package/skills/bmod-tea/help/help.md +38 -6
  41. package/skills/bmod-tea/migration-2.toml +100 -0
@@ -51,8 +51,36 @@ function assertLiveSourceRevision(capture, projectRoot) {
51
51
  throw new Error('Trace source revision changed during the run; rerun with current live evidence.');
52
52
  }
53
53
 
54
- /** Mirror Steps 2-4 dispositions; the fresh-failure cap uses each record's actual SHA. */
55
- function liveReference(capture, criterionIds) {
54
+ /** The local part of a qualified id: `AC-1` of `shop--e1-s2--AC-1`, `R1` of `shop--e1--R1`. */
55
+ const localId = (id) => id.slice(id.lastIndexOf('--') + 2);
56
+
57
+ /**
58
+ * Requirement-oracle live identity, the rule Trace Step 3 states: a qualified criterion id
59
+ * (`<story key>--<criterion id>`) maps to itself; a local id (`AC-1`) maps to the one criterion
60
+ * carrying it. A local id two criteria carry, or a requirement row's id (qualified or local `R<n>`),
61
+ * maps to an unmatched reason. Entries are set in that order and never overwritten. Ids absent from
62
+ * the map are unknown.
63
+ */
64
+ function liveAliasMap(criterionIds, requirementIds = []) {
65
+ const aliases = new Map();
66
+ const carriers = new Map();
67
+ for (const id of criterionIds) {
68
+ aliases.set(id, { id });
69
+ carriers.set(localId(id), [...(carriers.get(localId(id)) ?? []), id]);
70
+ }
71
+ for (const id of requirementIds) if (!aliases.has(id)) aliases.set(id, { reason: 'requirement-row' });
72
+ for (const [key, ids] of carriers)
73
+ if (!aliases.has(key)) aliases.set(key, ids.length === 1 ? { id: ids[0] } : { reason: 'ambiguous-local-id', carriers: ids });
74
+ for (const id of requirementIds) if (!aliases.has(localId(id))) aliases.set(localId(id), { reason: 'requirement-row' });
75
+ return aliases;
76
+ }
77
+
78
+ /**
79
+ * Mirror Steps 2-4 dispositions; the fresh-failure cap uses each record's actual SHA. Records are
80
+ * normalized through `aliases` before failure grouping, so a pass and a fail for one criterion meet
81
+ * whichever spelling each used; the supplied id stays on the record for diagnostics.
82
+ */
83
+ function liveReference(capture, aliases) {
56
84
  if (!capture) return;
57
85
  const { manifest, currentSha } = capture;
58
86
  if (!manifest) return { present: true, freshness: 'unreadable', current_source_sha: currentSha, failed: 0, freshFailed: 0 };
@@ -60,13 +88,13 @@ function liveReference(capture, criterionIds) {
60
88
  const records = manifest.results.map((entry) => {
61
89
  const row = entry && typeof entry === 'object' && !Array.isArray(entry) ? entry : {};
62
90
  const id = asString(row.id),
63
- requirement = asString(row.requirement_id),
91
+ supplied = asString(row.requirement_id),
64
92
  status = asString(row.status).toLowerCase();
65
93
  const sha = normalizedSha(row.source_sha ?? manifest.source_sha);
66
94
  const duplicate = Boolean(id) && seen.has(id);
67
95
  if (id) seen.add(id);
68
96
  let disposition;
69
- if (!id || !requirement || !['pass', 'fail', 'blocked', 'skipped'].includes(status) || !sha || duplicate) disposition = 'invalid';
97
+ if (!id || !supplied || !['pass', 'fail', 'blocked', 'skipped'].includes(status) || !sha || duplicate) disposition = 'invalid';
70
98
  else if (status !== 'pass') disposition = status;
71
99
  else if (!currentSha) disposition = 'unverifiable';
72
100
  else if (shaMatches(sha, currentSha)) {
@@ -74,13 +102,16 @@ function liveReference(capture, criterionIds) {
74
102
  } else {
75
103
  disposition = 'stale';
76
104
  }
77
- return { requirement, sha, disposition };
105
+ const resolved = aliases.get(supplied);
106
+ return { id, supplied, requirement: resolved?.id ?? supplied, resolved, sha, disposition, reason: null };
78
107
  });
79
108
  const failedRequirements = new Set(records.filter((row) => row.disposition === 'fail').map((row) => row.requirement));
80
109
  for (const row of records) {
81
110
  if (row.disposition !== 'counted') continue;
82
- if (!criterionIds.has(row.requirement)) row.disposition = 'unmatched';
83
- else if (failedRequirements.has(row.requirement)) row.disposition = 'contradicted';
111
+ if (!row.resolved?.id) {
112
+ row.disposition = 'unmatched';
113
+ row.reason = row.resolved?.reason ?? 'unknown-id';
114
+ } else if (failedRequirements.has(row.requirement)) row.disposition = 'contradicted';
84
115
  }
85
116
  const count = (status) => records.filter((row) => row.disposition === status).length;
86
117
  return {
@@ -95,7 +126,14 @@ function liveReference(capture, criterionIds) {
95
126
  : 'stale'
96
127
  : 'unverifiable',
97
128
  freshFailed: records.filter((row) => row.disposition === 'fail' && shaMatches(row.sha, currentSha)).length,
129
+ records: records.map((row) => ({
130
+ id: row.id,
131
+ supplied_requirement_id: row.supplied,
132
+ requirement_id: row.requirement,
133
+ disposition: row.disposition,
134
+ reason: row.reason,
135
+ })),
98
136
  };
99
137
  }
100
138
 
101
- module.exports = { captureLiveResults, assertLiveSourceRevision, liveReference };
139
+ module.exports = { captureLiveResults, assertLiveSourceRevision, liveAliasMap, liveReference, localId };
package/cli/trace.js CHANGED
@@ -9,6 +9,8 @@ const { captureLiveResults, assertLiveSourceRevision } = require('./lib/trace-li
9
9
  const { addAgentOptions, projectPath, readInput, resolveWorkflowSkill, headlessPrompt, runWithEvidence } = require('./lib/workflow-cli');
10
10
  const {
11
11
  sourceOracleLedger,
12
+ epicTicketSources,
13
+ requirementOracle,
12
14
  COLLECTION_MODES,
13
15
  GATE_TYPES,
14
16
  resolveTraceTarget,
@@ -65,7 +67,16 @@ function execute(options, registerOutputGuard = () => {}) {
65
67
  const targetFile = options.target ? readInput(projectRoot, options.target, '--target') : undefined;
66
68
  const target = resolveTraceTarget({ projectRoot, target: targetFile, targetId: options.targetId, gateType: options.gateType });
67
69
  const targetText = targetFile ? fs.readFileSync(targetFile, 'utf8') : '';
68
- const oracleLedger = sourceOracleLedger(targetText, targetFile ?? 'project');
70
+ const oracleLedger = sourceOracleLedger(targetText, targetFile ?? 'project', target);
71
+ // The requirement oracle's criteria come from the epic's tickets; capture them before the agent runs.
72
+ const tickets = requirementOracle(target, oracleLedger) ? epicTicketSources(projectRoot, target) : undefined;
73
+ const requirementLines = tickets
74
+ ? [
75
+ `This is v7 epic ${target.epicKey}; the frozen ledger holds its Requirements lines. Record oracleGranularity: requirements.`,
76
+ 'Persist Step 1 criterionLedger and the requirement and exception oracleLedger rows in matrix YAML frontmatter with every field Step 1 section 1b names.',
77
+ 'In the summary JSON, set oracle.granularity to "requirements" and oracle.rows to one entry per oracleLedger row, in ledger order: {id, kind, priority, priority_basis, coverage}, plus parent, missing_behaviors and contributors [{id, story, coverage}] for a requirement row, or exception for an exception row.',
78
+ ]
79
+ : [];
69
80
  const liveResults = options.liveResults
70
81
  ? readInput(projectRoot, options.liveResults, '--live-results')
71
82
  : path.join(artifactRoot, 'live-verification-results.json');
@@ -83,7 +94,7 @@ function execute(options, registerOutputGuard = () => {}) {
83
94
  const rightStat = fs.statSync(right);
84
95
  return leftStat.dev === rightStat.dev && leftStat.ino === rightStat.ino;
85
96
  };
86
- const inputs = [targetFile, liveResults, waiverRegister].filter(Boolean);
97
+ const inputs = [...new Set([targetFile, liveResults, waiverRegister, ...(tickets?.files.keys() ?? [])].filter(Boolean))];
87
98
  const heldInputs = inputs.map((file) => {
88
99
  if (!fs.existsSync(file)) return { file, missing: true };
89
100
  const stat = fs.statSync(file);
@@ -104,7 +115,7 @@ function execute(options, registerOutputGuard = () => {}) {
104
115
  if (outputs.some((left, index) => outputs.slice(index + 1).some((right) => aliases(left, right))))
105
116
  throw new Error('Trace artifacts must use separate paths from each other.');
106
117
  if (Object.values(destinations).some((output) => inputs.some((input) => aliases(output, input))))
107
- throw new Error('Trace artifacts must use separate paths from the target, live results, and waiver register.');
118
+ throw new Error('Trace artifacts must use separate paths from the target, its ticket sources, live results, and waiver register.');
108
119
  if (!options.json) return;
109
120
  projectPath(projectRoot, options.json, '--json');
110
121
  const protectedPaths = [...inputs, ...Object.values(destinations)];
@@ -133,6 +144,7 @@ function execute(options, registerOutputGuard = () => {}) {
133
144
  'Execute both trace phases, finishing Step 5. Use deterministic gate decisions.',
134
145
  `Frozen source oracle ledger: ${JSON.stringify(oracleLedger)}. Preserve its requirement text, source references, identities, and explicit priorities in Step 1 and the final matrix.`,
135
146
  'Persist Step 1 oracleLedger in matrix YAML frontmatter as an array of {id, requirement, priority, source} records. Assign priorities only where the source leaves them unspecified.',
147
+ ...requirementLines,
136
148
  `The only trace target for this run is ${target.document ? JSON.stringify(target.document) : `the project (${target.runScope})`}.`,
137
149
  `Resolved identity: ${JSON.stringify(target)}. Preserve it in every output.`,
138
150
  `Resolve {gate_type} to ${JSON.stringify(target.type)}, {run_scope} to ${JSON.stringify(target.runScope)}, and {run_key} to ${JSON.stringify(target.runKey)}.`,
@@ -179,6 +191,7 @@ function execute(options, registerOutputGuard = () => {}) {
179
191
  requireOracleLedger: true,
180
192
  liveCapture,
181
193
  requireLiveManifest: true,
194
+ tickets,
182
195
  });
183
196
  },
184
197
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "bmad-method-test-architecture-enterprise",
4
- "version": "3.4.0",
4
+ "version": "3.6.0",
5
5
  "description": "Master Test Architect for quality strategy, test automation, and release gates",
6
6
  "keywords": [
7
7
  "bmad",
@@ -17,6 +17,7 @@ You will continue to operate with your given name, identity, and communication_s
17
17
  - `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives).
18
18
  - `{project-root}` is the nearest folder containing `_bmad/`, starting at the project working directory and moving up through its parents.
19
19
  - `{tea-knowledge}` is the `knowledge/` folder of the `bmod-tea` skill, installed beside this one: `{skill-root}/../bmod-tea/knowledge`. `tea-index.csv` there lists every fragment by a path relative to that folder.
20
+ - `{tea-contracts}` is the `contracts/` folder of the `bmod-tea` skill, installed beside this one: `{skill-root}/../bmod-tea/contracts`. `story-identity.md` there says how a story is resolved, read and named.
20
21
  - `{skill-name}` resolves to the skill directory's basename.
21
22
  - Resolve sibling workflow files such as `instructions.md`, `checklist.md`, `steps-c/...`, `steps-e/...`, `steps-v/...`, and templates from `{skill-root}`.
22
23
 
@@ -9,6 +9,7 @@ workflowType: 'testarch-atdd'
9
9
  storyId: '{story_id}'
10
10
  storyKey: '{story_key}'
11
11
  storyFile: '{story_file}'
12
+ ticketRef: '{ticket_ref}'
12
13
  atddChecklistPath: '{test_artifacts}/atdd/atdd-checklist-{story_key}.md'
13
14
  generatedTestFiles:
14
15
  - '{api_test_file_path}'
@@ -52,10 +53,11 @@ inputDocuments: []
52
53
  - **Story ID:** `{story_id}`
53
54
  - **Story Key:** `{story_key}`
54
55
  - **Story File:** `{story_file}`
56
+ - **Ticket:** `{ticket_ref}` (v7; the builder's plan: `{plan_path}`)
55
57
  - **Checklist Path:** `{test_artifacts}/atdd/atdd-checklist-{story_key}.md`
56
58
  - **Generated Test Files:** `{e2e_test_file_path}`, `{api_test_file_path}`, `{component_test_file_path}`
57
59
 
58
- If this story is implemented with BMM `bmad-build`, list these artifact paths in its spec (Code Map and the tasks that turn them green) so the implementation agent discovers and activates the red-phase scaffolds. On BMAD releases before 6.12, mirror them into the `create-story` story's `Dev Notes` for `dev-story` instead.
60
+ If this story is implemented with BMM `bmad-build`, list these artifact paths in its plan (on v7, the plan path above; its Code Map and the tasks that turn them green) so the implementation agent discovers and activates the red-phase scaffolds. On BMAD releases before 6.12, mirror them into the `create-story` story's `Dev Notes` for `dev-story` instead.
59
61
 
60
62
  ---
61
63
 
@@ -331,7 +333,10 @@ test('should do something', async ({ {fixtureName} }) => {
331
333
  6. **Work one activated test at a time** (red → green for each)
332
334
  7. **Share progress** in daily standup
333
335
  8. **When all activated tests pass**, refactor code for quality
334
- 9. **When refactoring complete**, manually mark the story done where your project tracks it (the story's ticket entry in `tickets.toml`, or `sprint-status.yaml` on a v6 project)
336
+ 9. **When refactoring complete**, close the story where your project tracks it. This checklist changes no ticket, plan or story status.
337
+ - **v7 ticket:** the builder records the work in the story's plan, and you or your orchestrator mark the ticket done. Ask Sofia the Product Owner (`bmad-agent-po`): she runs `tickets.py mark` on a repo store, or the tracker transition on a Jira, Linear or GitHub store.
338
+ - **v6 story:** update the story file and `sprint-status.yaml` as your sprint process does.
339
+ - **No BMad method module:** hand this checklist and the tests to your team's own process.
335
340
 
336
341
  ---
337
342
 
@@ -195,7 +195,7 @@ Before starting this workflow, verify:
195
195
  - [ ] Red-green-refactor workflow
196
196
  - [ ] Execution commands
197
197
  - [ ] Next steps for DEV team
198
- - [ ] Checklist frontmatter includes `storyId`, `storyKey`, `storyFile`, `atddChecklistPath`, and generated test file paths
198
+ - [ ] Checklist frontmatter includes `storyId`, `storyKey`, `storyFile` or `ticketRef`, `atddChecklistPath`, and generated test file paths
199
199
  - [ ] If a writable story file was provided, ATDD artifacts were linked back into story context
200
200
  - [ ] If a story file could not be updated, manual handoff instructions are present
201
201
 
@@ -63,7 +63,7 @@ Shoppers currently must create an account before they can pay, and cart abandonm
63
63
  - **Checklist Path:** `docs/test-artifacts/atdd/atdd-checklist-2-4-guest-checkout.md`
64
64
  - **Generated Test Files:** `tests/e2e/guest-checkout.spec.ts`, `tests/api/guest-checkout.spec.ts`
65
65
 
66
- If this story is implemented with BMM `bmad-build`, list these artifact paths in its spec (Code Map and the tasks that turn them green) so the implementation agent discovers and activates the red-phase scaffolds. On BMAD releases before 6.12, mirror them into the `create-story` story's `Dev Notes` for `dev-story` instead.
66
+ If this story is implemented with BMM `bmad-build`, list these artifact paths in its plan (on v7, the plan path above; its Code Map and the tasks that turn them green) so the implementation agent discovers and activates the red-phase scaffolds. On BMAD releases before 6.12, mirror them into the `create-story` story's `Dev Notes` for `dev-story` instead.
67
67
 
68
68
  ---
69
69
 
@@ -510,7 +510,10 @@ npx c8 --reporter=text npx playwright test tests/api/guest-checkout.spec.ts
510
510
  6. **Work one activated test at a time** (red → green for each)
511
511
  7. **Share progress** in daily standup
512
512
  8. **When all activated tests pass**, refactor code for quality
513
- 9. **When refactoring complete**, manually mark the story done where your project tracks it (the story's ticket entry in `tickets.toml`, or `sprint-status.yaml` on a v6 project)
513
+ 9. **When refactoring complete**, close the story where your project tracks it. This checklist changes no ticket, plan or story status.
514
+ - **v7 ticket:** the builder records the work in the story's plan, and you or your orchestrator mark the ticket done. Ask Sofia the Product Owner (`bmad-agent-po`): she runs `tickets.py mark` on a repo store, or the tracker transition on a Jira, Linear or GitHub store.
515
+ - **v6 story:** update the story file and `sprint-status.yaml` as your sprint process does.
516
+ - **No BMad method module:** hand this checklist and the tests to your team's own process.
514
517
 
515
518
  ---
516
519
 
@@ -72,22 +72,19 @@ If any are missing: **HALT** and notify the user.
72
72
 
73
73
  ## 3. Load Story Context
74
74
 
75
- - Read story markdown from `{story_file}` (or ask user if not provided)
76
- - Extract acceptance criteria and constraints into a criterion registry in source order
75
+ - Resolve and read the story by `{tea-contracts}/story-identity.md` sections 1 to 3: a v7 ticket through `tickets.py find`, or a v6 story file at `{story_file}`. Ask the user for the story when none was given.
76
+ - Extract the criteria that contract selects, and the constraints, into a criterion registry in source order. Keep the `R` ids each v7 criterion names in its row's text.
77
+ - Check every selected criterion for an observable outcome a failing test can assert. In an interactive run, name each criterion that has none and ask the user to refine it with Sofia the Product Owner (`bmad-agent-po`) or rewrite it; **halt** until answered. A headless run halts with "Story `{story_id}` has criteria red mode cannot turn into failing tests: {unusable criteria}; refine them first."
77
78
  - Preserve every supplied criterion id that matches `AC-<positive integer>` exactly
78
79
  - Reject duplicate supplied ids
79
80
  - Assign ids to unnamed criteria deterministically. Reserve all supplied ids first, then visit unnamed criteria in source order and assign the lowest unused `AC-<positive integer>` id
80
81
  - Persist each registry row as `{ id, idSource: supplied | generated, text }` and persist the exact ordered id set as `{criterion_ids}`. The same story content must always produce the same registry
81
82
  - Identify affected components and integrations
82
- - Derive and store `story_id` from story metadata, the H1 heading, or the filename when available (for BMM stories, this is typically `{epic_num}.{story_num}`)
83
- - Derive and store `story_key`:
84
- - With a story file, `story_key` is the BMM story file basename without `.md` (for example `1-2-user-authentication`)
85
- - Without a story file, use `story_id` with `.` replaced by `-` (`1.2` becomes `1-2`)
86
- - With neither, use a slug of the story title: lowercase; replace every run of characters outside `a-z` and `0-9` with a single `-`; trim leading and trailing `-`; truncate to 64 characters
83
+ - Derive and store `story_id`, `story_key`, `ticket_ref` and `story_file` by `{tea-contracts}/story-identity.md` section 4. For a v6 story file, `story_id` comes from story metadata, the H1 heading, or the filename (typically `{epic_num}.{story_num}`); with neither a file nor an id, `story_key` is a slug of the story title: lowercase; replace every run of characters outside `a-z` and `0-9` with a single `-`; trim leading and trailing `-`; truncate to 64 characters
87
84
  - Use that `story_key` for the `{outputFile}` basename so all checklist and handoff paths stay consistent
88
- - If `story_id` is still unavailable after metadata/H1/filename parsing, set it to the final `story_key` so `story_id` is never empty
89
- - Preserve `{story_file}` as a tracked artifact path for later handoff into BMM `bmad-build` (`dev-story` before BMAD 6.12)
90
- - If a test design covers this story, read it for P0-P3 priorities and risks. Look in `{test_artifacts}/test-design/` first (`test-design-epic-{epic_num}.md` for the story's epic, then the system-level `test-design-qa.md` and `test-design-architecture.md`), then the legacy root `{test_artifacts}/` for the same names. Record the path you loaded in `inputDocuments`, or state that no test design was found in either location.
85
+ - If `story_id` is still unavailable, set it to the final `story_key` so `story_id` is never empty
86
+ - Preserve `{story_file}` and `{ticket_ref}` for the handoff to the builder. For a v7 ticket, also keep the `plan` path `find` returned, and whether that file exists yet
87
+ - If a test design covers this story, read it for P0-P3 priorities and risks. When the story belongs to a numbered epic (section 3 of the contract; a v6 story's epic number), look for `test-design-epic-{epic_num}.md` in `{test_artifacts}/test-design/` and then at the legacy root `{test_artifacts}/`, before any system-level file. Only when neither exists, look for the system-level `test-design-qa.md` and `test-design-architecture.md` in the same two places. A story with no numbered epic skips the epic lookup; never derive an epic number from a bare entry id. Record the path you loaded in `inputDocuments`, or state that no test design was found in either location.
91
88
 
92
89
  ---
93
90
 
@@ -183,7 +180,7 @@ An ATDD run always covers exactly one story, so its checklist filename carries t
183
180
  Resolve the story in this order:
184
181
 
185
182
  1. Use the story the user named in this invocation.
186
- 2. Otherwise use the story carried by the loaded artifacts: the story file name, or the story id from its metadata or H1 heading.
183
+ 2. Otherwise use the story carried by the loaded artifacts: the v7 ticket resolved in section 3, or the v6 story file name, or the story id from its metadata or H1 heading.
187
184
  3. If several stories are candidates and the run is interactive, list them and ask which one this run covers. **Halt** until the user answers. A headless or autonomous run with no resolvable story halts with "A story with acceptance criteria is required for ATDD." ATDD has no `system` fallback because a story is a hard prerequisite.
188
185
 
189
186
  Derive `story_key` from the resolved story as described in section 3, then set:
@@ -191,7 +188,7 @@ Derive `story_key` from the resolved story as described in section 3, then set:
191
188
  - `run_scope` to `story`
192
189
  - `run_key` to `story-{story_key}`
193
190
 
194
- `story-{story_key}` follows the shared run_key grammar: `story_key` is the BMM story file basename without `.md` (for example `1-2-user-authentication`); without a story file, it is the story id with `.` replaced by `-` (`1.2` becomes `1-2`).
191
+ `story-{story_key}` follows the shared run_key grammar in `{tea-contracts}/story-identity.md` section 4: `shop--e1-s2` for a v7 epic entry, the BMM story file basename such as `1-2-user-authentication` for a v6 story.
195
192
 
196
193
  Carry `story_key`, `run_scope`, and `run_key` forward through every remaining step. `{outputFile}` is `{test_artifacts}/atdd/atdd-checklist-{story_key}.md`.
197
194
 
@@ -201,7 +198,7 @@ Carry `story_key`, `run_scope`, and `run_key` forward through every remaining st
201
198
 
202
199
  Check whether `{outputFile}` already exists. A checklist at this path belongs to a previous run for the **same** story; checklists for other stories live under their own filenames and are never read or written here.
203
200
 
204
- - **Does not exist:** this is a fresh run. Proceed to Save Progress.
201
+ - **Does not exist:** this is a fresh run. For a story resolved through the v7 route, when the test artifacts folder holds story checklists with a pre-v7 key, follow section 5 of the contract before continuing. Proceed to Save Progress.
205
202
  - **Exists with `workflowStatus: 'in-progress'`:** a previous run for this story was interrupted. Display its `lastStep` and `lastSaved`, then ask:
206
203
 
207
204
  > "An unfinished ATDD run for `{run_key}` was last saved {lastSaved} at step {lastStep}. Resume it, or start over? Starting over replaces the checklist."
@@ -241,7 +238,8 @@ Then write this step's output below the frontmatter.
241
238
 
242
239
  - Set `storyId` to `{story_id}`
243
240
  - Set `storyKey` to `{story_key}`
244
- - Set `storyFile` to `{story_file}`
241
+ - Set `storyFile` to `{story_file}` (empty for a v7 entry that is not pulled)
242
+ - Set `ticketRef` to `{ticket_ref}` (empty for a v6 story)
245
243
  - Set `atddChecklistPath` to `{outputFile}`
246
244
  - Initialize `generatedTestFiles` to `[]`
247
245
  - Set `inputDocuments` to the list of artifact paths loaded in this step (e.g., knowledge fragments, test design documents, configuration files)
@@ -69,7 +69,7 @@ Read the selected checklist and parse YAML frontmatter for:
69
69
  - `stepsCompleted` — array of completed step names
70
70
  - `lastStep` — last completed step name
71
71
  - `lastSaved` — timestamp of last save
72
- - `storyId`, `storyKey`, `storyFile` — the story this checklist covers
72
+ - `storyId`, `storyKey`, `storyFile`, `ticketRef` — the story this checklist covers (`ticketRef` is absent on checklists written before v7 keys)
73
73
 
74
74
  **Run identity check.** Check only identity fields first, before reading progress or rendering the dashboard. A mismatch response names the conflicting identities only and omits all saved status/step details. When the user named a story in this invocation, `runKey` must equal the `run_key` resolved for it, and `storyKey` must equal the resolved `story_key`. If either differs, display "⚠️ **Checklist belongs to a different story** (`{runKey}`, not `{run_key}`). Refusing to resume." **Halt.** Do not read its progress state and do not report its `workflowStatus`. When the user named no story, adopt the checklist's own `storyKey`, `runScope`, and `runKey` as this run's identity.
75
75
 
@@ -87,6 +87,8 @@ If `workflowStatus` is missing (legacy checklist), infer it from `lastStep`: `'s
87
87
 
88
88
  ---
89
89
 
90
+ For a story run, read `{tea-contracts}/story-identity.md` before continuing: a named story is resolved by its sections 1 and 4 for the identity check, `ticketRef` locates the story when `storyFile` is empty or gone, and section 5 governs every citation the checkpoint carries (read through `resolvedSources`; report, never follow, an `unresolved` one). This holds on every resume path, named or not.
91
+
90
92
  ### 3. Display Progress Dashboard
91
93
 
92
94
  Display:
@@ -94,7 +96,7 @@ Display:
94
96
  "📋 **Workflow Resume — Acceptance Test-Driven Development**
95
97
 
96
98
  **Run:** {runKey} ({runScope})
97
- **Story:** {storyId} (`{storyFile}`)
99
+ **Story:** {storyId} (`{storyFile}` or `{ticketRef}`)
98
100
  **Workflow status:** {workflowStatus}
99
101
  **Last saved:** {lastSaved}"
100
102
 
@@ -276,7 +276,8 @@ UI components to implement:
276
276
  `{outputFile}` already holds this run's frontmatter and working notes from Steps 1-3. The checklist becomes the document body: replace everything below the frontmatter with `checklistContent`, and keep the frontmatter block (`runScope`, `runKey`, `workflowStatus`, `stepsCompleted`, and the story fields) exactly as this run wrote it. Save Progress below then updates the frontmatter for this step.
277
277
 
278
278
  ```javascript
279
- const outputFile = `{test_artifacts}/atdd/atdd-checklist-{story_key}.md`;
279
+ // The checklist this run is bound to: Step 1's path, or the exact path Resume selected.
280
+ const outputFile = `{atddChecklistPath}`;
280
281
  const existing = fs.readFileSync(outputFile, 'utf8');
281
282
  const frontmatter = existing.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n/)?.[0];
282
283
  if (!frontmatter) {
@@ -287,13 +288,13 @@ if (!frontmatter) {
287
288
  fs.writeFileSync(outputFile, `${frontmatter}\n${checklistContent}`, 'utf8');
288
289
  ```
289
290
 
290
- The file only ever holds this run's work: Step 1 replaced any earlier checklist for this story, and checklists for other stories live under their own filenames.
291
+ The file only ever holds this run's work: Step 1 replaced any earlier checklist for this story, and checklists for other stories live under their own filenames. Write only to the bound `{atddChecklistPath}`; never rebuild the path from `story_key`, so a resumed checklist at another path is the one updated.
291
292
 
292
- **If `{story_file}` exists and is writable, attempt to link artifacts back into the story:**
293
+ **If the story is a v6 story file and `{story_file}` exists and is writable, attempt to link artifacts back into the story.** Never write to a v7 leaf file, plan or `tickets.toml`; for a v7 ticket the completion summary hands these paths to the builder instead:
293
294
 
294
295
  - Add or update a `### ATDD Artifacts` subsection under `## Dev Notes`
295
296
  - Record:
296
- - `Checklist: {test_artifacts}/atdd/atdd-checklist-{story_key}.md`
297
+ - `Checklist: {atddChecklistPath}`
297
298
  - `API tests: {api_test_file_path}` when present
298
299
  - `E2E tests: {e2e_test_file_path}` when present
299
300
  - `Component tests: {component_test_file_path}` when present
@@ -375,7 +376,7 @@ Display to user:
375
376
  - tests/api/[feature].spec.ts (with test.skip())
376
377
  - tests/e2e/[feature].spec.ts (with test.skip())
377
378
  - tests/fixtures/test-data.ts
378
- - {test_artifacts}/atdd/atdd-checklist-{story_key}.md
379
+ - {atddChecklistPath}
379
380
 
380
381
  📝 Next Steps:
381
382
  1. Link ATDD artifacts into the story file if available
@@ -416,6 +417,7 @@ Proceed to Step 5 when:
416
417
  - Set `storyId` to `{story_id}`
417
418
  - Set `storyKey` to `{story_key}`
418
419
  - Set `storyFile` to `{story_file}`
420
+ - Set `ticketRef` to `{ticket_ref}`
419
421
  - Set `atddChecklistPath` to `{outputFile}`
420
422
  - Set `generatedTestFiles` deterministically to the list of present test paths in this order: API, E2E, Component (omit blanks / N/A values)
421
423
 
@@ -87,9 +87,10 @@ Report:
87
87
 
88
88
  - Test files created
89
89
  - Checklist output path
90
- - Story key / story file handoff path
90
+ - Story key, and the handoff: for a v7 ticket, its `ticketRef` and the `plan` path `find` returned, saying whether that plan exists yet, so the builder lists these red tests in it; for a v6 story, the story file
91
91
  - Key risks or assumptions
92
- - Next recommended workflow (usually BMM `bmad-build`, or `dev-story` before BMAD 6.12; `automate` comes after implementation)
92
+ - Next recommended workflow: `bmad-build` when the method module is installed (`dev-story` before BMAD 6.12), otherwise the team's own implementation process; `automate` comes after implementation
93
+ - Red mode changed no ticket, plan or story status
93
94
 
94
95
  ---
95
96
 
@@ -111,6 +112,7 @@ Preserve or include the loop's resolved YAML frontmatter keys `test_mode`, `test
111
112
  storyId: '{story_id}'
112
113
  storyKey: '{story_key}'
113
114
  storyFile: '{story_file}'
115
+ ticketRef: '{ticket_ref}'
114
116
  atddChecklistPath: '{outputFile}'
115
117
  generatedTestFiles: []
116
118
  ---
@@ -124,7 +126,7 @@ Preserve or include the loop's resolved YAML frontmatter keys `test_mode`, `test
124
126
  - Add `'step-05-validate-and-complete'` to `stepsCompleted` array (only if not already present)
125
127
  - Set `lastStep: 'step-05-validate-and-complete'`
126
128
  - Set `lastSaved: '{date}'`
127
- - Ensure `storyId`, `storyKey`, `storyFile`, and `atddChecklistPath` are present and populated
129
+ - Ensure `storyId`, `storyKey`, `atddChecklistPath`, and `storyFile` or `ticketRef` are present and populated
128
130
  - Ensure `generatedTestFiles` remains populated with the deterministic list of present generated test paths
129
131
  - Retain the resolved frontmatter settings and `healing_rounds_used` saved by the loop; completion never resets the budget.
130
132
  - Append this step's output to the appropriate section.
@@ -193,7 +193,7 @@ Every run writes an automation summary whose filename carries the run's scope, s
193
193
 
194
194
  - `system`: the whole project or system, or no narrower scope could be resolved.
195
195
  - `epic-{epic_num}`: one epic.
196
- - `story-{story_key}`: one story. `story_key` is the BMM story file basename without `.md` (for example `1-2-user-authentication`). Without a story file, use the story id with `.` replaced by `-` (`1.2` becomes `1-2`).
196
+ - `story-{story_key}`: one story. Resolve, read and name the story by `{tea-contracts}/story-identity.md`: `story_key` is `shop--e1-s2` for a v7 epic entry and the v6 story file basename (`1-2-user-authentication`) for a v6 story.
197
197
  - `target-{slug}`: when no story or epic applies, the slug of the automated path or feature name. Use `target_feature` when it is set. For `target_files`, use the single file path, or the deepest directory the files share.
198
198
 
199
199
  Slug rule (used for every `{slug}` and for an epic title with no number): lowercase; replace every run of characters outside `a-z` and `0-9` with a single `-`; trim leading and trailing `-`; truncate to 64 characters.
@@ -201,7 +201,7 @@ Slug rule (used for every `{slug}` and for an epic title with no number): lowerc
201
201
  ### Resolution order
202
202
 
203
203
  1. Use the scope the user named in this invocation (a story, an epic, a feature or path, or the whole system).
204
- 2. Otherwise use the scope carried by the loaded artifacts: a story file gives `story-{story_key}`; an epic document gives `epic-{epic_num}` from its metadata, H1 heading, or filename; a `target_feature` or `target_files` value with no story or epic gives `target-{slug}`. When a story and its epic are both loaded, the story is the scope.
204
+ 2. Otherwise use the scope carried by the loaded artifacts: a story (a v7 ticket or a v6 story file) gives `story-{story_key}`; an epic document gives `epic-{epic_num}` from its metadata, H1 heading, or filename; a `target_feature` or `target_files` value with no story or epic gives `target-{slug}`. When a story and its epic are both loaded, the story is the scope.
205
205
  3. If several candidates of the same kind remain (for example two stories) and the run is interactive, list them and ask which one this run covers. **Halt** until the user answers. A headless or autonomous run with no resolvable scope uses `system` and says so in the summary.
206
206
 
207
207
  Auto-discovery across the whole codebase with no story, epic, or target is `system`.
@@ -248,6 +248,8 @@ lastSaved: '{date}'
248
248
 
249
249
  Then write this step's output below the frontmatter.
250
250
 
251
+ For a story run (`run_scope` is `story`), also write `storyId`, `storyKey`, `ticketRef` and `storyFile` into this frontmatter, as `{tea-contracts}/story-identity.md` section 4 defines them. Other scopes leave them out.
252
+
251
253
  `runScope` and `runKey` are this run's identity. Later steps carry both forward unchanged and never re-derive them, and Resume mode refuses to continue a summary whose `runKey` does not match the run being resumed.
252
254
 
253
255
  **Update `inputDocuments`**: Set `inputDocuments` in the output template frontmatter to the list of artifact paths loaded in this step (e.g., knowledge fragments, test design documents, configuration files).
@@ -82,6 +82,8 @@ If `workflowStatus` is missing (legacy summary), infer it from `lastStep`: `'ste
82
82
 
83
83
  ---
84
84
 
85
+ For a story run, read `{tea-contracts}/story-identity.md` before continuing: a named story is resolved by its sections 1 and 4 for the identity check, `ticketRef` locates the story when `storyFile` is empty or gone, and section 5 governs every citation the checkpoint carries (read through `resolvedSources`; report, never follow, an `unresolved` one). This holds on every resume path, named or not.
86
+
85
87
  ### 3. Display Progress Dashboard
86
88
 
87
89
  Display:
@@ -41,7 +41,7 @@ Determine what needs to be tested and select appropriate test levels and priorit
41
41
  **BMad-Integrated:**
42
42
 
43
43
  - Map acceptance criteria to test scenarios
44
- - Check for existing ATDD outputs to avoid duplication. Look for the story's checklist at `{test_artifacts}/atdd/atdd-checklist-{story_key}.md` first, then the legacy root `{test_artifacts}/atdd-checklist-{story_key}.md`. When this run has no story file, `story_key` is only the dashed story id (`1-2`) while ATDD named its checklist from the story file (`1-2-user-authentication`): if neither exact name exists, look for `{test_artifacts}/atdd/atdd-checklist-{dashed story id}-*.md`, then the same pattern at the legacy root, and accept a match only when its frontmatter `storyId` or `storyKey` names this story. For an epic or wider scope, check every `atdd-checklist-*.md` for the in-scope stories in both locations. Name the checklists you found, and read their `generatedTestFiles` to see which scaffolds already exist.
44
+ - Check for existing ATDD outputs to avoid duplication. Look for the story's checklist at `{test_artifacts}/atdd/atdd-checklist-{story_key}.md` first, then the legacy root `{test_artifacts}/atdd-checklist-{story_key}.md`. A v7 ticket's key is the same in every workflow, so the exact name is enough. On a v6 project, when this run has no story file, `story_key` is only the dashed story id (`1-2`) while ATDD named its checklist from the story file (`1-2-user-authentication`): if neither exact name exists, look for `{test_artifacts}/atdd/atdd-checklist-{dashed story id}-*.md`, then the same pattern at the legacy root, and accept a match only when its frontmatter `storyId` or `storyKey` names this story. For an epic or wider scope, check every `atdd-checklist-*.md` for the in-scope stories in both locations. Name the checklists you found, and read their `generatedTestFiles` to see which scaffolds already exist.
45
45
  - Expand coverage with edge cases and negative paths
46
46
 
47
47
  **Standalone:**
@@ -250,7 +250,7 @@ With no accepted baseline, skip the tier runs and record that in the `## CI` sec
250
250
 
251
251
  ## Hand the plan to framework setup with CI scope
252
252
 
253
- Invoke `bmad-tea-framework` with explicit CI setup scope and Edit operation on the adopter's pipeline file, naming the plan's path, or Create when the inspection found no pipeline file. Its CI phase detects `ci/evaluation-ci-plan.json` and validates it; the rendering rules belong to `skills/bmad-tea-framework/ci/steps-c/step-03b-render-evaluation-plans.md` from TEA's repository root. In an installed skill set, resolve it as `{skill-root}/../bmad-tea-framework/ci/steps-c/step-03b-render-evaluation-plans.md`, where `{skill-root}` is the Evaluate skill root. Setup scope and operation are independent, so this handoff selects CI and preserves an existing framework. CI Edit validates the changed pipeline syntax, injection safety and evaluation-plan rendering/gates; it does not require the adopter's full suite to pass or activate framework hooks. CI Create uses the existing framework contract and its execution gate. Name in the request the concrete event of this repository for each tier it should render, such as `release`: the push of `v*` tags that starts `.github/workflows/release.yml`.
254
- That step renders each `gates` entry as a wait of the named job on the evaluation job of the tier, and its summary reports the edit to the job, a name that matches no job and a conflicting gate, so relay that report to the adopter.
253
+ Invoke `bmad-tea-framework` with explicit CI setup scope and Edit operation on the adopter's pipeline file, naming the plan's path, or Create when the inspection found no pipeline file. Its CI phase detects `ci/evaluation-ci-plan.json`, validates it and renders it; the rendering rules belong to `bmad-tea-framework`, so never read or apply its files from here. Setup scope and operation are independent, so this handoff selects CI and preserves an existing framework. CI Edit validates the changed pipeline syntax, injection safety and evaluation-plan rendering/gates; it does not require the adopter's full suite to pass or activate framework hooks. CI Create uses the existing framework contract and its execution gate. Name in the request the concrete event of this repository for each tier it should render, such as `release`: the push of `v*` tags that starts `.github/workflows/release.yml`.
254
+ Framework's CI phase renders each `gates` entry as a wait of the named job on the evaluation job of the tier, and its summary reports the edit to the job, a name that matches no job and a conflicting gate, so relay that report to the adopter.
255
255
  When the plan gates a job, invoke it on the workflow file that holds that job.
256
256
  When that skill is not installed, give the adopter the request and the plan's path and record the hand-off as an open item in the inspection record. Stage 12 is complete when the plan passes `check` and the hand-off is made; a declined baseline or a missing `bmad-tea-framework` stays a named open item in the `## CI` section and does not reopen the stage. Finish with the closing summary: the placement table, the deviations and their reasons, the secrets the live tiers need (the names from `environmentKeys`), the gates adopted, the baseline still to accept, every tier that exited non-zero with the stage that owns its repair, and each publish or deploy job that waits for the evaluation job through `gates`, with every such job the plan leaves ungated and the reason.
@@ -157,7 +157,7 @@ This project runs on Claude Code, which supports tool hooks, so the hook was ins
157
157
  "maxFileLines": 1000,
158
158
  "stopScanWindowSeconds": 900,
159
159
  "maxScannedFiles": 5000,
160
- "hookSha256": "f2ede9d399358d8810c660a29590f0c1683f7164bb3199038d26787f8324491c"
160
+ "hookSha256": "6d3aad7acbfb1c1cd37667e267d22e1509ae9296fb56191b5d3f67faece82fc5"
161
161
  }
162
162
  ```
163
163