Files
crank/_bmad-output/test-artifacts/atdd-checklist-1-1-capability-inventory.md
T

201 lines
14 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
stepsCompleted: ['step-01-preflight-and-context', 'step-02-generation-mode', 'step-03-test-strategy', 'step-04c-aggregate', 'step-05-validate-and-complete']
lastStep: 'step-05-validate-and-complete'
lastSaved: '2026-08-08'
storyId: '1.1'
storyKey: '1-1-capability-inventory'
storyFile: '_bmad-output/planning-artifacts/epics.md'
atddChecklistPath: '_bmad-output/test-artifacts/atdd-checklist-1-1-capability-inventory.md'
generatedTestFiles:
- 'tests/unit/test_validate_capability_inventory.py'
inputDocuments:
- '_bmad-output/planning-artifacts/epics.md'
- '_bmad-output/project-context.md'
- '_bmad-output/test-artifacts/test-design-epic-1.md'
- '_bmad-output/test-artifacts/test-design-architecture.md'
- '_bmad-output/test-artifacts/test-design-qa.md'
- 'scripts/check-community-scope.py'
- 'tests/unit/test_check_community_scope.py'
- 'apps/ui/playwright.config.js'
---
# ATDD Checklist — Story 1.1 Capability Inventory
## Step 1: Preflight and Context
- **Detected stack:** fullstack (Rust backend plus existing Playwright UI), while Story 1.1 itself is a repository-level Python/CLI/schema guardrail with no new browser behavior.
- **Story approval:** acceptance criteria are complete in `_bmad-output/planning-artifacts/epics.md`, Story 1.1.
- **Framework readiness:** Python `unittest` runs in `just test` and Gitea CI; Rust and Playwright frameworks are configured. Development environment is available.
- **Story key:** `1-1-capability-inventory`; **Story ID:** `1.1`.
- **Affected contracts:** Capability Inventory schema, validator CLI, machine-readable inventory, evidence references, Community scope scanner/guardrails, Community docs and `project-context.md`.
- **Risk links:** E1-R-001 (score 9), coverage groups E1-01 and E1-02.
- **Existing pattern:** `scripts/check-community-scope.py` exposes deterministic stdlib CLI behavior and explicit `--files`; `tests/unit/test_check_community_scope.py` uses temporary repositories and subprocess assertions.
- **TEA flags:** Playwright Utils on; Pact.js Utils off; Pact MCP off; browser automation auto; stack auto→fullstack. Contract testing is relevant at CLI/schema boundary; browser automation is not required for this Story.
- **Preflight result:** PASS. No prerequisite or user input is missing.
## Step 2: Generation Mode
- **Mode:** AI generation.
- **Reason:** Story 1.1 is a deterministic repository CLI/schema contract. Acceptance criteria are explicit, existing subprocess/unit patterns are authoritative, and no live UI selector or interaction must be recorded.
- **Browser state:** no session opened; no recording artifact created.
## Step 3: Test Strategy
### Acceptance-criteria mapping
| Scenario | Acceptance contract | Level | Priority | Red-phase mechanism |
|---|---|---|---|---|
| ATDD-1.1-01 | Valid inventory requires unique ID, `ui/api/mcp`, FRs, outcome, owner, status and evidence | CLI contract/unit | P0 | Future validator script and schema do not exist |
| ATDD-1.1-02 | `implemented/planned/gap/blocked` accepted, while last three never counted as pass | CLI contract | P0 | Future summary/status logic absent |
| ATDD-1.1-03 | Duplicate ID, unknown status, owner missing and required field missing fail with stable codes | CLI contract | P0 | Future validation rules absent |
| ATDD-1.1-04 | Missing mandatory FR and broken evidence reference fail | CLI/filesystem integration | P0 | Future required-FR/evidence resolution absent |
| ATDD-1.1-05 | Error report is deterministic, ≤64 KiB and does not echo secret canaries/raw invalid payload | CLI security contract | P0 | Future bounded/redacted reporter absent |
| ATDD-1.1-06 | `resources`, `prompts`, `tasks`, `load_runs` are allowed planned capability kinds | CLI/schema contract | P0 | Future capability enum absent |
| ATDD-1.1-07 | `multi_workspace`, `enterprise_rbac`, `sso`, `non_rest_upstream`, `arbitrary_distributed_load_targets` remain forbidden even with allow-marker text | CLI/schema security | P0 | Future scope contract absent |
| ATDD-1.1-08 | Canonical inventory/schema/docs/project context files exist and do not claim planned target capabilities are implemented | Repository contract | P1 | Required artifacts/markers absent |
### Contract decisions for the red scaffold
- Canonical CLI: `scripts/validate-capability-inventory.py`.
- Canonical artifacts: `docs/capability-inventory.json` and `docs/schemas/capability-inventory.schema.json`.
- CLI accepts `--root`, `--inventory`, `--schema` and repeatable `--required-fr`; tests use temporary repositories and JSON only, adding no dependency.
- Deterministic failures use stable machine codes and sorted paths; sensitive values are never printed. Maximum human report is 64 KiB.
- Inventory `flows[]` owns `id`, `type`, `requirements`, `user_outcome`, `owner`, `status`, `capabilities` and `evidence`. Evidence links are repository-relative and must resolve to regular files.
- These are external test contracts, not implementation prescriptions: internal parsing/validation structure remains free.
### Existing green evidence retained, not duplicated
- `tests/unit/test_check_community_scope.py` already proves explicit `--files` scanning, forbidden markers, narrow inline directives and binary/default exclusions.
- New red tests focus on the missing Inventory-aware contract; they do not duplicate current scope-scanner branch tests or introduce browser tests.
### Red-phase expectation
All newly generated acceptance tests describe behavior that will fail before implementation because the validator/schema/inventory documentation contract is absent. During the shared RED-scaffold phase they are deliberately decorated with `@unittest.skip(RED_PHASE)` so ordinary CI stays green; each test is activated task-by-task and must be observed failing before the corresponding implementation is added.
## Step 4: RED-Phase Test Scaffolds
### Generation result
- **Execution:** SUBAGENT (API + E2E); capability probe enabled and resolved to the available subagent runner.
- **CLI/API contract tests:** 10 scenarios in `tests/unit/test_validate_capability_inventory.py`, all guarded by `@unittest.skip(RED_PHASE)`.
- **E2E browser tests:** 0. Story 1.1 introduces no UI journey, so browser scaffolding would duplicate the repository-level CLI contract.
- **TDD compliance:** PASS. Every generated test has a RED-phase skip guard, contains behavioral assertions rather than placeholders, and is marked `expected_to_fail` in generation metadata.
- **Browser session:** not opened.
### Acceptance Criteria Coverage
1. Complete inventory schema and every `ui`/`api`/`mcp` flow field are covered by the valid-inventory scenario.
2. The four statuses are accepted, while only `implemented` contributes to pass.
3. Duplicate IDs, unknown status/type, missing owner/field, mandatory FR gaps, and invalid evidence links produce stable failures.
4. Reports are deterministic, sorted, redacted, and bounded to 64 KiB.
5. `resources`, `prompts`, `tasks`, and `load_runs` are accepted as planned Community capabilities.
6. Multi-workspace, enterprise RBAC/SSO, non-REST upstream, and arbitrary distributed load targets remain forbidden despite allow-marker text.
7. New/untracked inventory and guardrail files are explicitly scanned with positive and negative coverage.
8. Canonical schema, inventory, Community documentation, and project context exist without promoting planned work to implemented.
### Fixture Infrastructure
The Python scaffold contains the minimal RED-phase fixture infrastructure locally: temporary repository factory, canonical-schema installer, flow/evidence factories, validator and scope-scanner subprocess runners, plus a secret canary. Keeping these helpers in the single Story 1.1 module avoids adding an unused cross-suite fixture API before the contract exists.
### Task-by-Task Activation
During implementation:
1. Remove `@unittest.skip(RED_PHASE)` only from the scenario for the current task.
2. Run `python3 -m unittest tests.unit.test_validate_capability_inventory` and observe the activated test fail for the missing behavior.
3. Implement the smallest production change that satisfies the contract, then rerun until green.
4. Keep unrelated scenarios skipped until their implementation task begins.
5. Finish with scope/boundary tests and `just verify` as required by Story 1.1.
### Implementation Handoff
- Validator CLI: `scripts/validate-capability-inventory.py` with `--root`, `--inventory`, `--schema`, and repeatable `--required-fr`.
- Canonical schema: `docs/schemas/capability-inventory.schema.json`.
- Canonical inventory: `docs/capability-inventory.json`.
- Community boundary: extend the existing scope checker without weakening narrow allow directives.
- Documentation: link the inventory from Community documentation and `_bmad-output/project-context.md`.
- Story backlink was not inserted because Story 1.1 lives inside the shared `epics.md` and has no dedicated `## Dev Notes` section. Use this checklist and its frontmatter as the implementation handoff.
### Generated Files
- `tests/unit/test_validate_capability_inventory.py`
- `_bmad-output/test-artifacts/atdd-checklist-1-1-capability-inventory.md`
### Summary
- Total tests: **10**, all skipped in shared RED scaffold.
- API/CLI tests: **10**.
- E2E tests: **0** (not applicable).
- Embedded fixture capabilities: **7**.
- Covered acceptance-contract groups: **8/8**.
- Activated tests are expected to fail until their corresponding behavior is implemented.
## Step 5: Validation and Completion
### Validation Result
- **Prerequisites:** PASS — approved Story 1.1, testable acceptance criteria, working Python `unittest` harness, and existing scope-checker patterns are present.
- **Scaffold syntax/discovery:** PASS — `python3 -m unittest tests.unit.test_validate_capability_inventory` discovered 10 tests and reported `OK (skipped=10)`.
- **RED safety:** PASS — AST inspection found 10 test methods and 10 `@unittest.skip` decorators; no generated acceptance scenario is active in ordinary CI.
- **Acceptance mapping:** PASS — all eight contract groups from Story 1.1 are represented.
- **Handoff metadata:** PASS — story ID/key/source, checklist path, generated test path, activation commands, and implementation targets are recorded.
- **Session cleanup:** PASS — no browser was opened and no CLI/browser process remains.
- **Artifact hygiene:** PASS — transient worker JSON files were removed from `/tmp`; durable summary metadata is stored in `_bmad-output/test-artifacts/atdd-summary-1-1-capability-inventory.json`.
- **Formatting:** PASS — Python compilation and `git diff --check` complete without errors.
### Applicability Decisions
- Primary level is **CLI contract / repository integration**. The file lives under the repository's established `tests/unit/` convention even though it exercises subprocess and filesystem boundaries.
- Browser E2E, component tests, selectors, `data-testid`, headed/debug commands, network interception, HTTP status matrices, external mocks, Pact, routes, and UI components are **N/A** for this story.
- Faker/TypeScript factory requirements are **N/A**. Deterministic Python builders are preferable for a schema validator; every test gets a fresh temporary root and `tearDown()` removes it.
- The ten scenarios intentionally group closely related assertions around one contract outcome (for example bounded + deterministic + redacted report). This gives actionable diagnostics without multiplying expensive subprocess setup.
### Implementation Checklist
- [ ] Create the canonical JSON schema and a minimal canonical inventory with the required flow fields and enum values.
- [ ] Implement CLI parsing plus structural validation for IDs, types, owners, outcomes, requirements, status, and evidence shape.
- [ ] Implement required-FR completeness and repository-contained regular-file evidence resolution.
- [ ] Implement stable error codes and deterministic, sorted, redacted, 64 KiB-bounded reporting.
- [ ] Encode allowed target capabilities and forbidden Community capability kinds without a text-marker bypass.
- [ ] Extend explicit scope-scanner coverage for new/untracked inventory and guardrail files.
- [ ] Update Community documentation and `_bmad-output/project-context.md` without marking planned capabilities implemented.
- [ ] Activate scenarios task-by-task, prove RED then GREEN, and finish with targeted tests, boundary/scope tests, and `just verify`.
Estimated implementation effort: **5–8 story points** (roughly 2–4 focused engineering days, excluding review latency).
### Red–Green–Refactor Contract
1. **RED:** remove the skip decorator from only the current scenario and run the specific module; retain the failing output in implementation evidence.
2. **GREEN:** implement the smallest compatible behavior until that scenario passes, without changing Rust dependencies, toolchain, or wire contracts.
3. **REFACTOR:** consolidate parser/reporting helpers only while all activated scenarios and existing scope tests remain green.
Execution commands:
```bash
# Discover the complete safe scaffold (all scenarios remain skipped initially)
python3 -m unittest tests.unit.test_validate_capability_inventory
# After activating one or more scenarios
python3 -m unittest -v tests.unit.test_validate_capability_inventory
# Existing boundary regression suite
python3 -m unittest -v tests.unit.test_check_community_scope
# Final repository gate
just verify
```
### Deliverable Summary
- Story: **1.1**, key `1-1-capability-inventory`.
- Story source: `_bmad-output/planning-artifacts/epics.md`.
- Primary level: CLI contract / repository integration.
- Tests: 10 CLI/API-contract, 0 E2E, 0 component.
- Generated test file: `tests/unit/test_validate_capability_inventory.py` (388 lines).
- Factories/fixtures: five local builders/runners plus temporary-root lifecycle and secret canary; no shared fixture files required.
- External mock requirements: 0; `data-testid` requirements: 0.
- Implementation tasks: 8; estimate: 5–8 points.
- Durable generation summary: `_bmad-output/test-artifacts/atdd-summary-1-1-capability-inventory.json`.
- Knowledge/patterns applied: API testing patterns, deterministic data factories, contract-testing principles, and the existing Community scope unittest/subprocess convention.
- Next workflow: implement Story 1.1 with `bmad-dev-story`; broader automation expansion follows after GREEN behavior exists.