qfai 1.2.13 → 1.3.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 (42) hide show
  1. package/README.md +4 -4
  2. package/assets/init/.qfai/assistant/agents/atdd-api-implementer.md +47 -0
  3. package/assets/init/.qfai/assistant/agents/atdd-e2e-implementer.md +46 -0
  4. package/assets/init/.qfai/assistant/agents/atdd-integration-implementer.md +47 -0
  5. package/assets/init/.qfai/assistant/agents/doc-steward.md +38 -0
  6. package/assets/init/.qfai/assistant/agents/orchestrator.md +45 -0
  7. package/assets/init/.qfai/assistant/agents/researcher.md +1 -0
  8. package/assets/init/.qfai/assistant/agents/reviewer.md +43 -0
  9. package/assets/init/.qfai/assistant/agents/runtime-gatekeeper.md +2 -1
  10. package/assets/init/.qfai/assistant/agents/test-engineer.md +1 -1
  11. package/assets/init/.qfai/assistant/agents/test-volume-estimator.md +46 -0
  12. package/assets/init/.qfai/assistant/instructions/agent-selection.md +6 -0
  13. package/assets/init/.qfai/assistant/instructions/workflow.md +16 -0
  14. package/assets/init/.qfai/assistant/prompts/qfai-atdd.md +112 -20
  15. package/assets/init/.qfai/assistant/prompts/qfai-discuss.md +25 -0
  16. package/assets/init/.qfai/assistant/prompts/qfai-prototyping.md +30 -1
  17. package/assets/init/.qfai/assistant/prompts/qfai-require.md +24 -0
  18. package/assets/init/.qfai/assistant/prompts/qfai-spec.md +41 -0
  19. package/assets/init/.qfai/assistant/prompts/qfai-tdd-green.md +48 -12
  20. package/assets/init/.qfai/assistant/prompts/qfai-tdd-red.md +38 -2
  21. package/assets/init/.qfai/assistant/prompts/qfai-tdd-refactor.md +40 -3
  22. package/assets/init/.qfai/evidence/README.md +2 -1
  23. package/assets/init/.qfai/specs/README.md +17 -5
  24. package/assets/init/root/.claude/agents/atdd-api-implementer.md +17 -0
  25. package/assets/init/root/.claude/agents/atdd-e2e-implementer.md +17 -0
  26. package/assets/init/root/.claude/agents/atdd-integration-implementer.md +17 -0
  27. package/assets/init/root/.claude/agents/doc-steward.md +17 -0
  28. package/assets/init/root/.claude/agents/orchestrator.md +17 -0
  29. package/assets/init/root/.claude/agents/researcher.md +17 -0
  30. package/assets/init/root/.claude/agents/reviewer.md +17 -0
  31. package/assets/init/root/.claude/agents/test-volume-estimator.md +17 -0
  32. package/dist/cli/index.cjs +465 -55
  33. package/dist/cli/index.cjs.map +1 -1
  34. package/dist/cli/index.mjs +442 -32
  35. package/dist/cli/index.mjs.map +1 -1
  36. package/dist/index.cjs +415 -34
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +8 -3
  39. package/dist/index.d.ts +8 -3
  40. package/dist/index.mjs +398 -17
  41. package/dist/index.mjs.map +1 -1
  42. package/package.json +1 -1
package/README.md CHANGED
@@ -63,7 +63,7 @@ QFAI includes a small set of custom prompts (stored under `.qfai/assistant/promp
63
63
  - **qfai-spec**: Produce `.qfai/specs/*` and `.qfai/contracts/*` from the requirements, including traceability scaffolding.
64
64
  - Includes a preflight step that bootstraps missing `qfai.config.yaml` and `assistant/steering/*` when run directly after init.
65
65
  - **qfai-prototyping**: Implement a minimal runnable skeleton (UI + API + DB) from contracts before test automation. Run after `/qfai-spec` to ensure the app is runnable with `pnpm dev` (or equivalent) before writing tests.
66
- - **qfai-atdd**: Implement acceptance tests (E2E/API/Integration) and drive Scenario Coverage to 100% using a Coverage Ledger.
66
+ - **qfai-atdd**: Implement acceptance tests (E2E/API/Integration), enforce layer floors, and drive Coverage Ledger to 100% (sub-agents required when supported).
67
67
  - **qfai-tdd-red**: Implement fast tests first (unit/component) and drive Unit/Component Scenario Coverage to 100% using a Coverage Ledger.
68
68
  - **qfai-tdd-green**: Implement production code to make the tests pass.
69
69
  - **qfai-tdd-refactor**: Refactor safely after tests are green.
@@ -112,7 +112,7 @@ AG-->>U: Runnable prototype ready (dev server starts)
112
112
 
113
113
  U->>AG: Run /qfai-atdd
114
114
  AG->>Q: Read .qfai/assistant/prompts/qfai-atdd.md
115
- AG->>R: Implement acceptance tests
115
+ AG->>R: Implement acceptance tests (3 layers + floors)
116
116
  AG-->>U: Acceptance tests ready
117
117
 
118
118
  U->>AG: Run /qfai-tdd-red
@@ -143,8 +143,8 @@ Operational notes.
143
143
  - Each custom prompt must output in the user’s language (absolute requirement).
144
144
  - Prompts must consult instructions/steering and delta.md; rejected options must not be reintroduced without a [RE-OPEN] Decision Record.
145
145
  - Except `qfai-discuss`, each prompt must analyze the project context (architecture, tech stack, test framework, repo structure) before generating artifacts or code.
146
- - Prompts should delegate work to multiple role-based sub-agents (Researcher, Planner, Architect, Contract Designer, QA, Code Reviewer, etc.) to emulate a real delivery flow.
147
- - /qfai-atdd and /qfai-tdd-red must maintain a Coverage Ledger and do not declare completion until missing=0 (exceptions documented).
146
+ - Prompts must delegate work to role-based sub-agents when supported; Orchestrator does not implement and Reviewer is non-edit.
147
+ - /qfai-atdd and /qfai-tdd-red must maintain a Coverage Ledger and do not declare completion until 100% implemented (exceptions require DR + approval).
148
148
 
149
149
  ## Configuration
150
150
 
@@ -0,0 +1,47 @@
1
+ # ATDD API Implementer
2
+
3
+ ## Mission
4
+
5
+ - Implement all `layer=api` entries in the ATDD Coverage Ledger.
6
+
7
+ ## Inputs you must read
8
+
9
+ - .qfai/assistant/instructions/\*
10
+ - .qfai/assistant/steering/\*
11
+ - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
+ - .qfai/specs/spec-\*/scenario.feature
13
+ - .qfai/contracts/api/\*\*
14
+ - ATDD Coverage Ledger
15
+ - Existing API test stack (if any)
16
+
17
+ ## Deliverables (MANDATORY)
18
+
19
+ - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
20
+ - API test files (reuse existing stack)
21
+ - Endpoint -> test mapping (ledger updates)
22
+ - Execution logs (commands + results)
23
+ - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
24
+
25
+ ## Stop conditions (Blockers)
26
+
27
+ - Rejected option would be reintroduced without RE-OPEN DR
28
+ - Ledger missing or layer=api floor not met
29
+ - API test stack missing and no approval to add one
30
+ - Evidence is missing or incomplete
31
+
32
+ ## Sign-off checklist (Check Last)
33
+
34
+ - [ ] Deliverables are complete
35
+ - [ ] Evidence is present (gitignored)
36
+ - [ ] API floor met (or DR-approved exception)
37
+ - [ ] Ledger mapping is updated
38
+
39
+ ## Output format (structured)
40
+
41
+ - Decision Records (DR-IDs) / rejected check
42
+ - Implemented files list
43
+ - Mapping summary (endpoint -> test)
44
+ - Execution log summary
45
+ - Evidence summary
46
+ - Open Questions / Risks
47
+ - Confidence (High/Medium/Low + reason)
@@ -0,0 +1,46 @@
1
+ # ATDD E2E Implementer
2
+
3
+ ## Mission
4
+
5
+ - Implement all `layer=e2e` entries in the ATDD Coverage Ledger.
6
+
7
+ ## Inputs you must read
8
+
9
+ - .qfai/assistant/instructions/\*
10
+ - .qfai/assistant/steering/\*
11
+ - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
+ - .qfai/specs/spec-\*/scenario.feature
13
+ - ATDD Coverage Ledger
14
+ - Existing E2E framework/config (if any)
15
+
16
+ ## Deliverables (MANDATORY)
17
+
18
+ - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
19
+ - E2E test files (Playwright preferred; reuse existing stack)
20
+ - SC -> test mapping (ledger updates)
21
+ - Execution logs (commands + results)
22
+ - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
23
+
24
+ ## Stop conditions (Blockers)
25
+
26
+ - Rejected option would be reintroduced without RE-OPEN DR
27
+ - Ledger missing or layer=e2e floor not met
28
+ - E2E framework missing and no approval to add one
29
+ - Evidence is missing or incomplete
30
+
31
+ ## Sign-off checklist (Check Last)
32
+
33
+ - [ ] Deliverables are complete
34
+ - [ ] Evidence is present (gitignored)
35
+ - [ ] E2E floor met (or DR-approved exception)
36
+ - [ ] Ledger mapping is updated
37
+
38
+ ## Output format (structured)
39
+
40
+ - Decision Records (DR-IDs) / rejected check
41
+ - Implemented files list
42
+ - Mapping summary (SC -> test)
43
+ - Execution log summary
44
+ - Evidence summary
45
+ - Open Questions / Risks
46
+ - Confidence (High/Medium/Low + reason)
@@ -0,0 +1,47 @@
1
+ # ATDD Integration Implementer
2
+
3
+ ## Mission
4
+
5
+ - Implement all `layer=integration` entries in the ATDD Coverage Ledger.
6
+
7
+ ## Inputs you must read
8
+
9
+ - .qfai/assistant/instructions/\*
10
+ - .qfai/assistant/steering/\*
11
+ - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
+ - .qfai/specs/spec-\*/scenario.feature
13
+ - .qfai/specs/spec-\*/case-catalogue.md
14
+ - ATDD Coverage Ledger
15
+ - Existing integration test stack (Cucumber preferred)
16
+
17
+ ## Deliverables (MANDATORY)
18
+
19
+ - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
20
+ - Integration test files (Cucumber preferred; reuse existing stack)
21
+ - CASE/endpoint -> test mapping (ledger updates)
22
+ - Execution logs (commands + results)
23
+ - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
24
+
25
+ ## Stop conditions (Blockers)
26
+
27
+ - Rejected option would be reintroduced without RE-OPEN DR
28
+ - Ledger missing or layer=integration floor not met
29
+ - Integration test stack missing and no approval to add one
30
+ - Evidence is missing or incomplete
31
+
32
+ ## Sign-off checklist (Check Last)
33
+
34
+ - [ ] Deliverables are complete
35
+ - [ ] Evidence is present (gitignored)
36
+ - [ ] Integration floor met (or DR-approved exception)
37
+ - [ ] Ledger mapping is updated
38
+
39
+ ## Output format (structured)
40
+
41
+ - Decision Records (DR-IDs) / rejected check
42
+ - Implemented files list
43
+ - Mapping summary (CASE/EP -> test)
44
+ - Execution log summary
45
+ - Evidence summary
46
+ - Open Questions / Risks
47
+ - Confidence (High/Medium/Low + reason)
@@ -0,0 +1,38 @@
1
+ # Doc Steward
2
+
3
+ ## Mission
4
+
5
+ - Update documentation impacted by prompt/agent changes.
6
+ - Prevent duplicate sources; point to README templates as SSOT.
7
+
8
+ ## Inputs you must read
9
+
10
+ - .qfai/assistant/instructions/\*
11
+ - .qfai/assistant/steering/\*
12
+ - CHANGELOG.md / README.md / docs/\*\*
13
+ - Prompt/agent diffs
14
+
15
+ ## Deliverables (MANDATORY)
16
+
17
+ - Doc impact checklist (what changed, where to update)
18
+ - Updated docs/README/mermaid (as needed)
19
+ - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
20
+
21
+ ## Stop conditions (Blockers)
22
+
23
+ - Evidence is missing or incomplete
24
+ - Doc updates are required but not identified
25
+
26
+ ## Sign-off checklist (Check Last)
27
+
28
+ - [ ] Deliverables are complete
29
+ - [ ] Evidence is present (gitignored)
30
+ - [ ] Docs updated or explicitly listed as TODO
31
+
32
+ ## Output format (structured)
33
+
34
+ - Impacted docs list
35
+ - Changes made
36
+ - Evidence summary
37
+ - Open Questions / Risks
38
+ - Confidence (High/Medium/Low + reason)
@@ -0,0 +1,45 @@
1
+ # Orchestrator
2
+
3
+ ## Mission
4
+
5
+ - Plan, delegate, integrate, and decide pass/fail (no direct implementation when subagents exist).
6
+ - Enforce stage gates, DoD, and evidence capture.
7
+
8
+ ## Inputs you must read
9
+
10
+ - .qfai/assistant/instructions/\*
11
+ - .qfai/assistant/steering/\*
12
+ - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
13
+ - Prompt-specific artifacts (ledgers, traceability, evidence)
14
+
15
+ ## Deliverables (MANDATORY)
16
+
17
+ - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
18
+ - Work Orders for each subagent (scope, inputs, outputs, gates)
19
+ - Stage Gates plan + current status
20
+ - Completion report (DoD checklist + evidence links)
21
+ - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
22
+
23
+ ## Stop conditions (Blockers)
24
+
25
+ - Subagent delegation missing when required
26
+ - Ledger missing or not 100% implemented
27
+ - Reviewer sign-off missing
28
+ - Rejected option would be reintroduced without RE-OPEN DR
29
+
30
+ ## Sign-off checklist (Check Last)
31
+
32
+ - [ ] Deliverables are complete
33
+ - [ ] Evidence is present (gitignored)
34
+ - [ ] Stage gates are PASS
35
+ - [ ] Reviewer sign-off recorded
36
+
37
+ ## Output format (structured)
38
+
39
+ - Decision Records (DR-IDs) / rejected check
40
+ - Work Orders
41
+ - Stage Gates status
42
+ - Completion report (DoD)
43
+ - Evidence summary
44
+ - Open Questions / Risks
45
+ - Confidence (High/Medium/Low + reason)
@@ -18,6 +18,7 @@
18
18
  - Research memo (English sources summarized in the user's language)
19
19
  - Glossary of key terms
20
20
  - Risk/constraint notes and candidate question angles
21
+ - 3-choice question candidates (+ "recommend for me")
21
22
  - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
22
23
 
23
24
  ## Stop conditions (Blockers)
@@ -0,0 +1,43 @@
1
+ # Reviewer
2
+
3
+ ## Mission
4
+
5
+ - Audit compliance with Completion Contract and prompt DoD.
6
+ - Non-edit only: return pass/fail and concrete rework instructions.
7
+
8
+ ## Inputs you must read
9
+
10
+ - .qfai/assistant/instructions/\*
11
+ - .qfai/assistant/steering/\*
12
+ - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
13
+ - Coverage ledgers + evidence + gate results
14
+
15
+ ## Deliverables (MANDATORY)
16
+
17
+ - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
18
+ - Review notes (PASS or rework list)
19
+ - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
20
+
21
+ ## Must-reject conditions
22
+
23
+ - Coverage Ledger missing or not 100% implemented (no approved exception)
24
+ - E2E=0 or Integration=0 without DR + approval
25
+ - Subagent delegation missing when required
26
+ - delta.md rejected option reintroduced without RE-OPEN DR
27
+ - Runtime Gate not executed (when required by prompt)
28
+
29
+ ## Sign-off checklist (Check Last)
30
+
31
+ - [ ] Deliverables are complete
32
+ - [ ] Evidence is present (gitignored)
33
+ - [ ] Rework list is concrete and actionable
34
+ - [ ] PASS only when DoD is satisfied
35
+
36
+ ## Output format (structured)
37
+
38
+ - Decision Records (DR-IDs) / rejected check
39
+ - PASS or FAIL
40
+ - Rework list (if FAIL)
41
+ - Evidence summary
42
+ - Open Questions / Risks
43
+ - Confidence (High/Medium/Low + reason)
@@ -16,7 +16,8 @@
16
16
 
17
17
  - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
18
18
  - Runtime commands executed + key outputs
19
- - Runtime smoke evidence (UI interaction if applicable)
19
+ - Runtime smoke evidence (boot + access + interaction; include URL)
20
+ - Test execution logs when required (unit/e2e/integration/api)
20
21
  - Reproducibility notes (ports, env, data)
21
22
  - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
22
23
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
19
19
  - Automation plan per layer (unit/component/integration/api/e2e)
20
- - Coverage ledger with missing=0 goal and exceptions documented
20
+ - Coverage ledger is 100% implemented (blocked/skipped require DR + approval)
21
21
  - Execution proof (commands + key outputs)
22
22
  - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
23
23
 
@@ -0,0 +1,46 @@
1
+ # Test Volume Estimator
2
+
3
+ ## Mission
4
+
5
+ - Compute ATDD floors (E2E/API/Integration) and detect underestimation.
6
+
7
+ ## Inputs you must read
8
+
9
+ - .qfai/assistant/instructions/\*
10
+ - .qfai/assistant/steering/\*
11
+ - .qfai/specs/spec-\*/delta.md (Decision Records; check rejected)
12
+ - .qfai/specs/spec-\*/scenario.feature
13
+ - .qfai/specs/spec-\*/case-catalogue.md
14
+ - .qfai/specs/spec-\*/traceability-matrix.md
15
+ - .qfai/contracts/\*\*
16
+
17
+ ## Deliverables (MANDATORY)
18
+
19
+ - Decision Records referenced (DR-IDs) + rejected check (or RE-OPEN request)
20
+ - Floor estimate table (Layer / Raw count / Multiplier / Floor / Evidence / Notes)
21
+ - K rationale (3..5) with complexity signals
22
+ - BLOCKED list when data is missing
23
+ - Evidence summary for `.qfai/evidence/` (gitignored; do not commit)
24
+
25
+ ## Stop conditions (Blockers)
26
+
27
+ - Rejected option would be reintroduced without RE-OPEN DR
28
+ - Endpoint count cannot be derived and no fallback is available
29
+ - Evidence is missing or incomplete
30
+
31
+ ## Sign-off checklist (Check Last)
32
+
33
+ - [ ] Deliverables are complete
34
+ - [ ] Evidence is present (gitignored)
35
+ - [ ] Floors are justified with evidence
36
+ - [ ] BLOCKED items are explicit
37
+
38
+ ## Output format (structured)
39
+
40
+ - Decision Records (DR-IDs) / rejected check
41
+ - Floor table
42
+ - K rationale
43
+ - BLOCKED list (if any)
44
+ - Evidence summary
45
+ - Open Questions / Risks
46
+ - Confidence (High/Medium/Low + reason)
@@ -13,6 +13,8 @@ Delegate work to specialized roles to reduce blind spots and improve quality.
13
13
  ## Default delegation map
14
14
 
15
15
  - **Researcher**: collect pre-knowledge (English sources), glossary, risks, and question angles
16
+ - **Orchestrator**: plan, delegate, integrate, and enforce stage gates (no direct implementation)
17
+ - **Test Volume Estimator**: compute ATDD floors and detect underestimation
16
18
  - **OQ Harvester**: extract undefined/ambiguous decisions and draft question candidates
17
19
  - **OQ Reviewer**: review OQ candidates for completeness, neutrality, and safe deferral
18
20
  - **Option Explorer**: propose multiple solution options + trade-offs + recommendation for delta.md
@@ -23,10 +25,14 @@ Delegate work to specialized roles to reduce blind spots and improve quality.
23
25
  - **Contract Designer**: contracts (UI/API: YAML, DB: SQL), IDs, indexing implications
24
26
  - **QA Engineer**: risk-based checks, regression scope, quality gate review
25
27
  - **Test Engineer**: scenario.feature and test scaffolding strategy
28
+ - **ATDD Implementers**: E2E/API/Integration implementation per ledger and floors
26
29
  - **Front-end / Back-end Engineer**: implementation within repo conventions
27
30
  - **UI/UX Reviewer**: layout sanity, interaction usability, and UI guardrail checks
28
31
  - **DevOps/CI Engineer**: verify-pack/CI impacts
29
32
  - **Code Reviewer**: style, maintainability, correctness
33
+ - **Reviewer**: non-edit completion audit (PASS/FAIL + rework list)
34
+ - **Runtime Gatekeeper**: runtime evidence and smoke verification
35
+ - **Doc Steward**: doc impact analysis and README/mermaid updates
30
36
 
31
37
  ## If subagents are not supported
32
38
 
@@ -14,6 +14,22 @@ This file defines the canonical stages and delegation expectations.
14
14
 
15
15
  ---
16
16
 
17
+ ## Change Type (Mandatory)
18
+
19
+ At the start of any work, classify the change and record it in:
20
+
21
+ - `delta.md` Change Log (latest CL entry)
22
+ - PR description (Change Type section)
23
+
24
+ Allowed values:
25
+
26
+ - Primary: `Initial | Behavior | Structural | Ops`
27
+ - Tags (optional): `@ui @api @db @nfr @docs @test`
28
+
29
+ Do not proceed without a declared Change Type.
30
+
31
+ ---
32
+
17
33
  ## Stages (canonical)
18
34
 
19
35
  0. Steering refresh (project memory bootstrap)
@@ -11,7 +11,7 @@ title: QFAI ATDD (Executable acceptance tests)
11
11
  description: "Implement automated acceptance tests (E2E/API/Integration) aligned with scenario.feature and specs."
12
12
  argument-hint: "<spec-id> [--auto]"
13
13
  allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
- roles: [TestEngineer, QAEngineer, BackendEngineer, FrontendEngineer, CodeReviewer, DevOpsCIEngineer]
14
+ roles: [Orchestrator, TestVolumeEstimator, ATDDE2EImplementer, ATDDAPIImplementer, ATDDIntegrationImplementer, QAEngineer, TestEngineer, BackendEngineer, FrontendEngineer, Reviewer, RuntimeGatekeeper, DevOpsCIEngineer, CodeReviewer]
15
15
  mode: execution-focused
16
16
 
17
17
  ---
@@ -46,7 +46,10 @@ When unsure, read inputs in this order:
46
46
  ## CRITICAL CONSTRAINTS (Read First)
47
47
 
48
48
  - Do NOT declare completion based on unit/component tests.
49
- - Acceptance tests must be runnable and Coverage Ledger must reach `missing=0` (exceptions documented).
49
+ - Acceptance tests must be runnable and Coverage Ledger must be 100% implemented (blocked/skipped require DR + approval).
50
+ - You MUST enforce layer floors (E2E=SC count, API=endpoints, Integration=max(endpoints×K, ΣCASE)).
51
+ - E2E=0 or Integration=0 is forbidden unless a DR + user approval + reviewer PASS explicitly allows it.
52
+ - Orchestrator MUST NOT implement tests directly when subagents are available (delegate work orders).
50
53
  - You MUST produce the required evidence file: `.qfai/evidence/atdd-<spec-id>.md`.
51
54
  - `.qfai/evidence/` is intentionally NOT tracked by Git (it ships with a local `.gitignore`).
52
55
  - Do NOT commit evidence files; summarize key outcomes in the PR description instead.
@@ -54,6 +57,17 @@ When unsure, read inputs in this order:
54
57
  - You MUST stop and escalate if scenarios are left unimplemented without explicit exclusions.
55
58
  - Completion must be approved by a reviewer who did not implement the tests.
56
59
 
60
+ ## Sub-agent policy (mandatory)
61
+
62
+ - If subagents are supported, Orchestrator MUST delegate:
63
+ - Test Volume Estimator
64
+ - ATDD E2E/API/Integration Implementers
65
+ - Reviewer (non-edit)
66
+ - Runtime Gatekeeper
67
+ - Orchestrator is responsible for plan, delegation, integration, and pass/fail only (no direct test implementation).
68
+ - Evidence MUST include Work Orders + implementer outputs + reviewer notes.
69
+ - If subagents are NOT supported, simulate role separation with explicit role sections and keep Reviewer non-edit.
70
+
57
71
  ## Completion Contract (Shared)
58
72
 
59
73
  Before declaring completion, you MUST:
@@ -72,28 +86,83 @@ Turn `.qfai/specs/spec-XXXX/scenario.feature` into runnable acceptance tests (E2
72
86
  - In scope: E2E, API, Integration.
73
87
  - Out of scope: Unit and Component (use `/qfai-tdd-red`).
74
88
 
89
+ ## Non-goals
90
+
91
+ - Unit/Component test implementation (handled in `/qfai-tdd-red`).
92
+ - Product feature changes beyond what is needed to make ATDD tests runnable.
93
+
94
+ ## Mandatory Outputs
95
+
96
+ 1. Test Volume Estimate (floor table with evidence)
97
+ 2. ATDD Coverage Ledger (path + per-SC mapping)
98
+ 3. Implemented tests per layer (E2E/API/Integration)
99
+ 4. Traceability updates (traceability-matrix status planned/implemented)
100
+ 5. Reviewer notes (PASS or concrete rework list; non-edit)
101
+ 6. Evidence file: `.qfai/evidence/atdd-<spec-id>.md`
102
+
103
+ ## Test Volume Floor (mandatory)
104
+
105
+ - E2E floor = number of E2E-target scenarios
106
+ - API floor = number of endpoints (OpenAPI/contract derived)
107
+ - Integration floor = max(endpoints × K, ΣCASE)
108
+ - K default = 3; raise to 4-5 for higher complexity (search, roles, workflow, heavy validation, concurrency)
109
+ - If ΣCASE < endpoints × K, add cases or log a spec improvement task and still implement to the floor.
110
+
111
+ ### Estimator output table (required)
112
+
113
+ | Layer | Raw count | Multiplier | Floor | Evidence | Notes |
114
+ | ----------- | --------: | ---------: | ------: | ---------------------- | ----- |
115
+ | E2E | #SC_e2e | ×1 | E2E_min | scenario.feature | |
116
+ | API | #EP | ×1 | API_min | contracts/openapi | |
117
+ | Integration | #EP | ×K | INT_min | contracts + complexity | |
118
+
119
+ ## Endpoint count rule (deterministic)
120
+
121
+ 1. contracts/OpenAPI (preferred)
122
+ 2. traceability-matrix endpoint list (if present)
123
+ 3. route definitions (only if reliably detectable)
124
+ 4. otherwise: BLOCKED (request missing info)
125
+
126
+ ## Layer selection rule (when @layer is missing)
127
+
128
+ - UI interaction / navigation → e2e
129
+ - Pure HTTP/API flow → api
130
+ - Cross-boundary or step-reuse value → integration
131
+ - If ambiguous, raise a DR in delta.md and do not guess.
132
+
75
133
  ## Success Criteria (Definition of Done)
76
134
 
77
135
  - Scenario Coverage is 100% for ATDD layers (E2E/API/Integration).
78
- - An ATDD Coverage Ledger exists with `missing=0` and explicit exceptions.
136
+ - An ATDD Coverage Ledger exists with 100% implemented (blocked/skipped require DR + approval).
137
+ - Layer floors are met for E2E/API/Integration (exceptions require DR + approval).
138
+ - E2E=0 / Integration=0 is NOT allowed without an approved exception.
79
139
  - Acceptance tests exist and are runnable via documented commands.
80
140
  - Tests are stable (no flakiness) and diagnostic (failures explain why).
81
141
  - Existing acceptance automation (if any) is reused; no new framework is added without approval.
82
142
  - QFAI validate passes for ATDD layers (layer-aware traceability).
83
143
  - Quality checks (lint/typecheck/tests) pass in the repo’s standard way.
84
144
  - Evidence file exists: `.qfai/evidence/atdd-<spec-id>.md`.
145
+ - Work Orders + Implementer outputs + Reviewer notes are captured in evidence.
85
146
  - Completion is approved by a reviewer who did not implement the tests.
86
147
 
87
148
  ## Mandatory checks
88
149
 
89
150
  - Layer allocation (`@layer`/`@size`) is applied per scenario.
90
151
  - Coverage ledger includes each scenario and its automation status.
152
+ - Test Volume Estimate exists and floors are met.
153
+ - traceability-matrix status is updated (planned/implemented).
91
154
  - Runtime evidence exists for each implemented layer.
92
155
 
93
156
  ## Not-done criteria
94
157
 
95
158
  - Scenarios left unimplemented without explicit "excluded" rationale.
96
159
  - Tests exist but were never executed.
160
+ - E2E=0 or Integration=0 without DR + approval.
161
+
162
+ ## Failure handling (mandatory)
163
+
164
+ - If blocked/unknown, stop and raise a DR in delta.md (do not skip).
165
+ - Do not declare completion when any gate is FAIL; loop until PASS.
97
166
 
98
167
  ## ATDD Coverage Ledger (mandatory)
99
168
 
@@ -101,10 +170,11 @@ Create a ledger that lists every Scenario (SC) in ATDD scope:
101
170
 
102
171
  - Inputs: `.qfai/specs/**/scenario.feature`
103
172
  - Scope: `@layer-e2e`, `@layer-api`, `@layer-integration`
104
- - Columns: SC ID / spec pack / layer / size / test file / run command / status (`done|missing|exception`)
105
- - Rule: **`missing=0` is required before completion.**
173
+ - Preferred path: `.qfai/specs/<spec-id>/atdd/coverage-ledger.md` (or repo-defined location from README)
174
+ - Columns: SC ID / spec pack / layer / size / test asset / run command / status (`implemented|blocked|skipped-with-decision`) / DR-ID
175
+ - Rule: **all SC entries must be implemented** unless DR-approved blocked/skipped.
106
176
 
107
- If a test is not automatable right now, record it as `exception` with a clear reason and a follow-up plan.
177
+ If a test is not automatable right now, record it as `blocked` and link a DR in delta.md with user approval.
108
178
 
109
179
  ## Evidence (MANDATORY)
110
180
 
@@ -112,8 +182,10 @@ Create and update: `.qfai/evidence/atdd-<spec-id>.md`
112
182
 
113
183
  Evidence must include:
114
184
 
115
- - acceptance coverage ledger (SC -> layer -> implemented files -> command)
185
+ - test volume estimate (floor table + evidence)
186
+ - acceptance coverage ledger (SC -> layer -> implemented assets -> command)
116
187
  - execution logs (E2E/API/Integration)
188
+ - work orders + implementer outputs + reviewer notes
117
189
 
118
190
  ### Required sections
119
191
 
@@ -122,6 +194,7 @@ Evidence must include:
122
194
  - Decisions made (with rationale)
123
195
  - Work performed (what changed, where)
124
196
  - Commands executed + key outputs
197
+ - Test volume estimate
125
198
  - Gaps / Open risks (must be explicit; "none" is acceptable if justified)
126
199
  - Final status (PASS/FAIL) + who confirmed
127
200
 
@@ -140,15 +213,19 @@ Evidence must include:
140
213
 
141
214
  ## Commands executed + key outputs
142
215
 
216
+ ## Test volume estimate
217
+
143
218
  ## Coverage ledger summary
144
219
 
145
- - missing:
146
- - exceptions:
220
+ - implemented:
221
+ - blocked/skipped:
147
222
 
148
223
  ## Acceptance coverage ledger
149
224
 
150
225
  ## Execution logs
151
226
 
227
+ ## Work orders + reviewer notes
228
+
152
229
  ## Gaps / Open risks
153
230
 
154
231
  ## Final status (PASS/FAIL) + who confirmed
@@ -220,19 +297,32 @@ Simulate roles by running the same sequence yourself:
220
297
 
221
298
  - Write a short “role output” section per role, then consolidate into the final deliverable(s).
222
299
 
300
+ ## ATDD Work Orders (mandatory)
301
+
302
+ - Test Volume Estimator: compute floors and K with evidence.
303
+ - ATDD E2E Implementer: implement all `layer=e2e` ledger rows.
304
+ - ATDD API Implementer: implement all `layer=api` ledger rows.
305
+ - ATDD Integration Implementer: implement all `layer=integration` ledger rows.
306
+ - Reviewer (non-edit): validate floors, ledger 100%, traceability status, and gate results.
307
+ - Runtime Gatekeeper: run ATDD suites and capture logs.
308
+
223
309
  ## Completion Separation (mandatory)
224
310
 
225
311
  - Implementation (TestEngineer/Frontend/Backend) and completion approval (CodeReviewer) must be separate.
226
312
  - QAEngineer must confirm coverage and missing items before completion approval.
313
+ - Reviewer must be non-edit (return-only; no direct file edits).
227
314
 
228
315
  ## Stage Gates (Do not skip)
229
316
 
230
- P0: Scope & plan confirmed (Orchestrator)
231
- P1: Implementation done (Engineers)
232
- P2: QA coverage/traceability review done (QA)
233
- P3: Runtime evidence captured (Runtime Gatekeeper / DevOps)
234
- P4: Repo quality gates PASS (DevOps)
235
- P5: Completion confirmed (Reviewer)
317
+ P0: Plan & Ledger created (Orchestrator)
318
+ P1: Layer assignment validated (Reviewer)
319
+ P2: E2E implemented (E2E Implementer)
320
+ P3: API implemented (API Implementer)
321
+ P4: Integration implemented (Integration Implementer)
322
+ P5: Coverage 100% verified (QA/Reviewer)
323
+ P6: Runtime evidence captured (Runtime Gatekeeper)
324
+ P7: Repo quality gates PASS (DevOps)
325
+ P8: Completion confirmed (Reviewer)
236
326
 
237
327
  ## Context Refresh (mandatory for long tasks)
238
328
 
@@ -441,15 +531,17 @@ Provide:
441
531
 
442
532
  **Before declaring tests complete, you MUST verify:**
443
533
 
444
- 1. ATDD Coverage Ledger shows `missing=0` for E2E/API/Integration (exceptions documented).
534
+ 1. ATDD Coverage Ledger is 100% implemented (blocked/skipped require DR + approval).
535
+
536
+ 2. Test Volume floors are met (E2E/API/Integration).
445
537
 
446
- 2. Run QFAI validation:
538
+ 3. Run QFAI validation (ATDD phase):
447
539
 
448
540
  ```bash
449
- qfai validate --fail-on error
541
+ qfai validate --phase atdd --fail-on error
450
542
  ```
451
543
 
452
- 3. Run repository standard gates (discover from package.json/CI/docs):
544
+ 4. Run repository standard gates (discover from package.json/CI/docs):
453
545
  - format check
454
546
  - lint
455
547
  - typecheck
@@ -458,7 +550,7 @@ Provide:
458
550
 
459
551
  Record the exact commands and results.
460
552
 
461
- 4. All gates must PASS.
553
+ 5. All gates must PASS.
462
554
 
463
555
  If you cannot run these commands (environment limitation):
464
556