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
@@ -58,6 +58,13 @@ When unsure, read inputs in this order:
58
58
  - You MUST stop and escalate if scope remains ambiguous or required inputs are missing.
59
59
  - Completion must be approved by a reviewer who did not lead the discussion.
60
60
 
61
+ ## Sub-agent policy (mandatory)
62
+
63
+ - If subagents are supported, Orchestrator MUST delegate: Researcher, Facilitator/Interviewer, Reviewer (non-edit).
64
+ - Orchestrator must not lead and approve the same discussion.
65
+ - Evidence must include work orders and reviewer notes.
66
+ - If subagents are not supported, simulate role separation with explicit role sections.
67
+
61
68
  ## Completion Contract (Shared)
62
69
 
63
70
  Before declaring completion, you MUST:
@@ -71,6 +78,19 @@ Before declaring completion, you MUST:
71
78
 
72
79
  Turn a vague idea into explicit, testable requirements and decisions that downstream prompts can implement without guesswork.
73
80
 
81
+ ## Non-goals
82
+
83
+ - Writing final requirements/specs (use `/qfai-require` / `/qfai-spec`).
84
+ - Implementation work.
85
+
86
+ ## Mandatory Outputs
87
+
88
+ - Requirements Seed
89
+ - Decision Table (with rejected/deferred options)
90
+ - Discuss record: `.qfai/discussions/discuss-XXXX.md`
91
+ - Evidence file: `.qfai/evidence/discuss-<discuss-id>.md`
92
+ - Reviewer notes (PASS or concrete rework list)
93
+
74
94
  ## Success Criteria (Definition of Done)
75
95
 
76
96
  - A “Requirements Seed” exists: goals, non-goals, constraints, acceptance criteria (high level), and open questions.
@@ -92,6 +112,11 @@ Turn a vague idea into explicit, testable requirements and decisions that downst
92
112
  - "We discussed" without decision and rationale.
93
113
  - No explicit scope boundary.
94
114
 
115
+ ## Failure handling (mandatory)
116
+
117
+ - If blocked/unknown, stop and record a DR in delta.md (do not skip).
118
+ - If required coverage remains undecided, do not declare completion.
119
+
95
120
  ## Required Coverage (MUST address)
96
121
 
97
122
  The discussion MUST cover the following topics before completion:
@@ -64,6 +64,13 @@ When unsure, read inputs in this order:
64
64
  - Implementation must align with existing project conventions; do NOT introduce new frameworks.
65
65
  - Completion must be approved by a reviewer who did not implement the code.
66
66
 
67
+ ## Sub-agent policy (mandatory)
68
+
69
+ - If subagents are supported, Orchestrator MUST delegate: implementation (Frontend/Backend/DB), Runtime Gatekeeper, Reviewer (non-edit).
70
+ - Orchestrator must not implement directly when delegation is available.
71
+ - Evidence must include work orders and reviewer notes.
72
+ - If subagents are not supported, simulate role separation with explicit role sections.
73
+
67
74
  ## Completion Contract (Shared)
68
75
 
69
76
  Before declaring completion, you MUST:
@@ -73,6 +80,22 @@ Before declaring completion, you MUST:
73
80
  - OQ / placeholder scan: scan all generated artifacts (including evidence) for placeholders such as "TBD", "TODO", "TBA", "TBC", "XXX", "???", "OQ", "OPEN QUESTION", "UNDEFINED", "PLACEHOLDER", and localized equivalents in the user's language. Resolve or explicitly defer; do not leave silent placeholders.
74
81
  - Smoke check (if applicable): when the prompt produces runnable code/tests/configs, execute the smallest command that proves basic run/start/operate and record evidence. If not applicable, state "not applicable" with a short rationale.
75
82
 
83
+ ## Goal
84
+
85
+ Build a minimal runnable vertical slice from contracts so the app boots and users can perform at least one primary interaction.
86
+
87
+ ## Non-goals
88
+
89
+ - Acceptance tests (use `/qfai-atdd`).
90
+ - Unit/component tests (use TDD phases).
91
+
92
+ ## Mandatory Outputs
93
+
94
+ - Runnable skeleton implementation aligned with contracts
95
+ - Runtime Interaction Gate evidence (boot + access + interaction)
96
+ - Evidence file: `.qfai/evidence/prototyping-<spec-id>.md`
97
+ - Reviewer notes (PASS or concrete rework list)
98
+
76
99
  ## Inputs (read first)
77
100
 
78
101
  - `.qfai/contracts/ui/*.yaml` (routes/screens/elements/actions)
@@ -145,12 +168,13 @@ Implement the following **contract-satisfying skeleton**, aiming for the smalles
145
168
  5. Implement DB skeleton and connect (or provide clear temporary store).
146
169
  6. Run the dev server and perform a manual “happy path” click-through.
147
170
 
148
- ## Sub-agent assignments (recommended)
171
+ ## Sub-agent assignments (required when supported)
149
172
 
150
173
  - UI Skeleton Builder: FrontendEngineer (apply UI layout guardrails).
151
174
  - API/DB Skeleton Builder: BackendEngineer + DBEngineer.
152
175
  - Runtime Smoke Checker: RuntimeGatekeeper (boot/access/interaction evidence).
153
176
  - UI/UX Reviewer: UIUXReviewer (layout sanity check).
177
+ - Reviewer: CodeReviewer (non-edit; PASS/FAIL only).
154
178
 
155
179
  ## Runtime Interaction Gate (mandatory)
156
180
 
@@ -182,6 +206,11 @@ You may declare completion ONLY if:
182
206
  - includes “Format Self-Check”,
183
207
  - includes a short manual verification log.
184
208
 
209
+ ## Failure handling (mandatory)
210
+
211
+ - If blocked/unknown, stop and record a DR in delta.md (do not skip).
212
+ - If Runtime Interaction Gate fails, fix and re-run before declaring completion.
213
+
185
214
  ## Reviewer checklist (for CodeReviewer role)
186
215
 
187
216
  - No test automation was added here.
@@ -68,6 +68,13 @@ When unsure, read inputs in this order:
68
68
  - You MUST stop and escalate if requirements are ambiguous or acceptance signals are missing.
69
69
  - Completion must be approved by a reviewer who did not author the requirements.
70
70
 
71
+ ## Sub-agent policy (mandatory)
72
+
73
+ - If subagents are supported, Orchestrator MUST delegate: OQ Harvester, OQ Reviewer, Requirements Analyst, Reviewer (non-edit).
74
+ - Orchestrator must not author and approve the same artifact.
75
+ - Evidence must include work orders and reviewer notes.
76
+ - If subagents are not supported, simulate role separation with explicit role sections.
77
+
71
78
  ## Completion Contract (Shared)
72
79
 
73
80
  Before declaring completion, you MUST:
@@ -81,6 +88,18 @@ Before declaring completion, you MUST:
81
88
 
82
89
  Turn the Requirements Seed into a reviewable, testable requirements artifact under `.qfai/require/`.
83
90
 
91
+ ## Non-goals
92
+
93
+ - Spec/contract authoring (use `/qfai-spec`).
94
+ - Implementation work.
95
+
96
+ ## Mandatory Outputs
97
+
98
+ - `.qfai/require/require.md`
99
+ - `.qfai/require/open-questions.md` (OQ ledger)
100
+ - Evidence file: `.qfai/evidence/require-<work-id>.md`
101
+ - Reviewer notes (PASS or concrete rework list)
102
+
84
103
  ## Success Criteria (Definition of Done)
85
104
 
86
105
  - A requirements document (`require.md`) exists in the requirements directory and is readable by a newcomer.
@@ -104,6 +123,11 @@ Turn the Requirements Seed into a reviewable, testable requirements artifact und
104
123
  - Missing acceptance signal for any requirement.
105
124
  - Any Open item remains in open-questions.md.
106
125
 
126
+ ## Failure handling (mandatory)
127
+
128
+ - If blocked/unknown, stop and record a DR in delta.md (do not skip).
129
+ - If Open items remain, do not declare completion.
130
+
107
131
  ## Evidence (MANDATORY)
108
132
 
109
133
  Create and update: `.qfai/evidence/require-<work-id>.md`
@@ -51,6 +51,18 @@ When unsure, read inputs in this order:
51
51
  - P3: `.qfai/specs/<spec-id>/delta.md` (Decision Records; if no spec yet, state "not applicable")
52
52
  - P4: other artifacts (spec.md, scenario.feature, contracts, evidence)
53
53
 
54
+ ## Change Type (Mandatory)
55
+
56
+ Before editing `delta.md`, declare the Change Type and record it in:
57
+
58
+ - `delta.md` Change Log (latest CL entry)
59
+ - PR description (Change Type section)
60
+
61
+ Allowed values:
62
+
63
+ - Primary: `Initial | Behavior | Structural | Ops`
64
+ - Tags (optional): `@ui @api @db @nfr @docs @test`
65
+
54
66
  ## Delta Rejected Guard (Mandatory)
55
67
 
56
68
  - Do NOT reintroduce options marked as rejected in delta.md.
@@ -74,6 +86,13 @@ When unsure, read inputs in this order:
74
86
  - You MUST stop and escalate if IDs, contracts, or scope are inconsistent.
75
87
  - Completion must be approved by a reviewer who did not author the spec pack.
76
88
 
89
+ ## Sub-agent policy (mandatory)
90
+
91
+ - If subagents are supported, Orchestrator MUST delegate: OQ Harvester, OQ Reviewer, Option Explorer, Option Reviewer, Contract Designer, Reviewer (non-edit).
92
+ - Orchestrator must not author and approve the same artifact.
93
+ - Evidence must include work orders and reviewer notes.
94
+ - If subagents are not supported, simulate role separation with explicit role sections.
95
+
77
96
  ## Completion Contract (Shared)
78
97
 
79
98
  Before declaring completion, you MUST:
@@ -89,6 +108,23 @@ Create/update an atomic spec pack that is readable and mechanically verifiable.
89
108
 
90
109
  This prompt is intentionally strict. If you cannot satisfy the strict rules, you MUST split the work into additional spec packs.
91
110
 
111
+ ## Non-goals
112
+
113
+ - Implementation work.
114
+ - Skipping OQ/decision logging.
115
+
116
+ ## Mandatory Outputs
117
+
118
+ - `.qfai/specs/spec-XXXX/spec.md`
119
+ - `.qfai/specs/spec-XXXX/delta.md`
120
+ - `.qfai/specs/spec-XXXX/scenario.feature`
121
+ - `.qfai/specs/spec-XXXX/case-catalogue.md`
122
+ - `.qfai/specs/spec-XXXX/traceability-matrix.md` (status planned/implemented)
123
+ - Updated contracts under `.qfai/contracts/**` (if needed)
124
+ - `.qfai/require/open-questions.md` (OQ ledger)
125
+ - Evidence file: `.qfai/evidence/spec-<spec-id>.md`
126
+ - Reviewer notes (PASS or concrete rework list)
127
+
92
128
  ## Hard Constraints (MUST)
93
129
 
94
130
  ### Atomicity / Granularity (quantitative)
@@ -167,6 +203,11 @@ The following order is mandatory and must not be parallelized or rearranged:
167
203
  - Any Open item remains in open-questions.md.
168
204
  - Decision Records are missing rejected items without explicit trivial-change justification.
169
205
 
206
+ ## Failure handling (mandatory)
207
+
208
+ - If blocked/unknown, stop and record a DR in delta.md (do not skip).
209
+ - If Open items remain, do not declare completion.
210
+
170
211
  ## Evidence (MANDATORY)
171
212
 
172
213
  Create and update: `.qfai/evidence/spec-<spec-id>.md`
@@ -38,6 +38,18 @@ When unsure, read inputs in this order:
38
38
  - P3: `.qfai/specs/<spec-id>/delta.md` (Decision Records; if no spec yet, state "not applicable")
39
39
  - P4: other artifacts (spec.md, scenario.feature, contracts, evidence)
40
40
 
41
+ ## Change Type (Mandatory)
42
+
43
+ Before updating `delta.md`, declare the Change Type and record it in:
44
+
45
+ - `delta.md` Change Log (latest CL entry)
46
+ - PR description (Change Type section)
47
+
48
+ Allowed values:
49
+
50
+ - Primary: `Initial | Behavior | Structural | Ops`
51
+ - Tags (optional): `@ui @api @db @nfr @docs @test`
52
+
41
53
  ## Delta Rejected Guard (Mandatory)
42
54
 
43
55
  - Do NOT reintroduce options marked as rejected in delta.md.
@@ -56,6 +68,13 @@ When unsure, read inputs in this order:
56
68
  - You MUST stop and escalate if runtime evidence or quality gates are missing.
57
69
  - Completion must be approved by a reviewer who did not implement the code.
58
70
 
71
+ ## Sub-agent policy (mandatory)
72
+
73
+ - If subagents are supported, Orchestrator MUST delegate: implementation (Frontend/Backend), QA, UI/UX review, Runtime Gatekeeper, Reviewer (non-edit).
74
+ - Orchestrator must not implement directly when delegation is available.
75
+ - Evidence must include work orders and reviewer notes.
76
+ - If subagents are not supported, simulate role separation with explicit role sections.
77
+
59
78
  ## Completion Contract (Shared)
60
79
 
61
80
  Before declaring completion, you MUST:
@@ -69,6 +88,18 @@ Before declaring completion, you MUST:
69
88
 
70
89
  Orchestrate production implementation according to spec + contracts + scenario so RED tests pass and the green quality gate is reached.
71
90
 
91
+ ## Non-goals
92
+
93
+ - Writing new tests (use `/qfai-tdd-red` or `/qfai-atdd`).
94
+ - Re-implementing rejected options without a RE-OPEN DR.
95
+
96
+ ## Mandatory Outputs
97
+
98
+ - Implementation changes that make RED tests pass
99
+ - Runtime Interaction Gate evidence
100
+ - Evidence file: `.qfai/evidence/tdd-green-<spec-id>.md`
101
+ - Reviewer notes (PASS or concrete rework list)
102
+
72
103
  ## Guardrails
73
104
 
74
105
  - You are the orchestrator. Do not implement directly; delegate to engineer roles.
@@ -89,7 +120,7 @@ Orchestrate production implementation according to spec + contracts + scenario s
89
120
 
90
121
  - Implementation matches the spec and contracts.
91
122
  - TDD tests pass (and ATDD tests pass when applicable).
92
- - Unit/Component Coverage Ledger shows `missing=0` (exceptions documented).
123
+ - Unit/Component Coverage Ledger shows 100% implemented (blocked/skipped require DR + approval).
93
124
  - Repo quality gates pass (lint/type/build/pack as applicable).
94
125
  - Verification evidence is recorded (commands + results).
95
126
  - Program is runnable; runtime evidence is recorded and meets project-type expectations.
@@ -108,10 +139,15 @@ Orchestrate production implementation according to spec + contracts + scenario s
108
139
  - "Tests passed" without runtime evidence.
109
140
  - Completion without reviewer sign-off.
110
141
 
142
+ ## Failure handling (mandatory)
143
+
144
+ - If blocked/unknown, stop and record a DR in delta.md (do not skip).
145
+ - If Runtime Interaction Gate fails, fix and re-run before declaring completion.
146
+
111
147
  ## Coverage Ledger continuity
112
148
 
113
149
  - Review the Unit/Component Coverage Ledger from `/qfai-tdd-red`.
114
- - Do not declare completion until `missing=0` and exceptions are documented.
150
+ - Do not declare completion until Coverage Ledger is 100% implemented (blocked/skipped require DR + approval).
115
151
 
116
152
  ## Non‑Negotiable Principles (QFAI Articles)
117
153
 
@@ -193,15 +229,15 @@ Simulate roles by running the same sequence yourself:
193
229
 
194
230
  You must not advance to the next phase until the current gate is PASS.
195
231
 
196
- | Phase | Owner | Gate output |
197
- | -------------------- | -------------------------------- | --------------------------------------------------------- |
198
- | P0: Scope Derivation | Orchestrator | Implementation Scope Table completed |
199
- | P1: Implementation | FrontendEngineer/BackendEngineer | Contract-to-implementation mapping with TODOs resolved |
200
- | P2: QA Review | QAEngineer | Coverage/gap check (missing=0 or explicit exceptions) |
201
- | P2.5: UI/UX Review | UIUXReviewer | Layout sanity check (guardrails satisfied) |
202
- | P3: Runtime Evidence | RuntimeGatekeeper | Boot + contract path run + UI interaction (if applicable) |
203
- | P4: Quality Gates | DevOpsCIEngineer | Repo-defined gates PASS |
204
- | P5: Completion | CodeReviewer | DoD PASS declared by non-implementer |
232
+ | Phase | Owner | Gate output |
233
+ | -------------------- | -------------------------------- | ---------------------------------------------------------------------------- |
234
+ | P0: Scope Derivation | Orchestrator | Implementation Scope Table completed |
235
+ | P1: Implementation | FrontendEngineer/BackendEngineer | Contract-to-implementation mapping with TODOs resolved |
236
+ | P2: QA Review | QAEngineer | Coverage/gap check (100% implemented; blocked/skipped require DR + approval) |
237
+ | P2.5: UI/UX Review | UIUXReviewer | Layout sanity check (guardrails satisfied) |
238
+ | P3: Runtime Evidence | RuntimeGatekeeper | Boot + contract path run + UI interaction (if applicable) |
239
+ | P4: Quality Gates | DevOpsCIEngineer | Repo-defined gates PASS |
240
+ | P5: Completion | CodeReviewer | DoD PASS declared by non-implementer |
205
241
 
206
242
  Optional (strongly recommended): run a Devil's Advocate check right before completion to look for hidden gaps.
207
243
 
@@ -507,7 +543,7 @@ Iterate until all gates pass, prioritizing:
507
543
 
508
544
  **Before declaring implementation complete, you MUST verify:**
509
545
 
510
- 1. Unit/Component Coverage Ledger shows `missing=0` (exceptions documented).
546
+ 1. Unit/Component Coverage Ledger shows 100% implemented (blocked/skipped require DR + approval).
511
547
 
512
548
  2. Runtime evidence commands executed and outcomes recorded.
513
549
 
@@ -38,6 +38,18 @@ When unsure, read inputs in this order:
38
38
  - P3: `.qfai/specs/<spec-id>/delta.md` (Decision Records; if no spec yet, state "not applicable")
39
39
  - P4: other artifacts (spec.md, scenario.feature, contracts, evidence)
40
40
 
41
+ ## Change Type (Mandatory)
42
+
43
+ Before updating `delta.md`, declare the Change Type and record it in:
44
+
45
+ - `delta.md` Change Log (latest CL entry)
46
+ - PR description (Change Type section)
47
+
48
+ Allowed values:
49
+
50
+ - Primary: `Initial | Behavior | Structural | Ops`
51
+ - Tags (optional): `@ui @api @db @nfr @docs @test`
52
+
41
53
  ## Delta Rejected Guard (Mandatory)
42
54
 
43
55
  - Do NOT reintroduce options marked as rejected in delta.md.
@@ -53,6 +65,13 @@ When unsure, read inputs in this order:
53
65
  - You MUST stop and escalate if RED is not reproducible.
54
66
  - Completion must be approved by a reviewer who did not implement the tests.
55
67
 
68
+ ## Sub-agent policy (mandatory)
69
+
70
+ - If subagents are supported, Orchestrator MUST delegate: Test Engineer, Unit Test Scope Enforcer, QA, Reviewer (non-edit).
71
+ - Orchestrator must not implement tests directly when delegation is available.
72
+ - Evidence must include work orders and reviewer notes.
73
+ - If subagents are not supported, simulate role separation with explicit role sections.
74
+
56
75
  ## Completion Contract (Shared)
57
76
 
58
77
  Before declaring completion, you MUST:
@@ -71,6 +90,18 @@ Implement fast tests (unit/component) that enforce the spec and provide reproduc
71
90
  - In scope: Unit and Component tests.
72
91
  - Out of scope: E2E/API/Integration (use `/qfai-atdd`).
73
92
 
93
+ ## Non-goals
94
+
95
+ - Production code changes beyond testability shims.
96
+ - Acceptance/E2E tests.
97
+
98
+ ## Mandatory Outputs
99
+
100
+ - Unit/Component Coverage Ledger
101
+ - Unit/Component test implementations (RED)
102
+ - Evidence file: `.qfai/evidence/tdd-red-<spec-id>.md`
103
+ - Reviewer notes (non-edit)
104
+
74
105
  ## Scope Guardrails (tests-only)
75
106
 
76
107
  ### Mandatory constraints (tests only)
@@ -119,7 +150,7 @@ If tests cannot proceed because implementation is missing:
119
150
  ## Success Criteria (Definition of Done)
120
151
 
121
152
  - Unit/Component tests exist, are deterministic, and runnable in CI.
122
- - Coverage Ledger for Unit/Component shows `missing=0` (exceptions documented).
153
+ - Coverage Ledger for Unit/Component shows 100% implemented (blocked/skipped require DR + approval).
123
154
  - Completion is based on executing the unit/component test suite and recording evidence.
124
155
  - Tests cover core logic and key edge cases derived from spec/scenario.
125
156
  - Tests fail meaningfully and the failing state is observed (RED evidence).
@@ -139,6 +170,11 @@ If tests cannot proceed because implementation is missing:
139
170
  - Tests added without mapping to requirements/contracts.
140
171
  - No reproducible RED.
141
172
 
173
+ ## Failure handling (mandatory)
174
+
175
+ - If blocked/unknown, stop and record a DR in delta.md (do not skip).
176
+ - If RED cannot be reproduced, fix the test setup or stop and report.
177
+
142
178
  ## TDD Coverage Ledger (Unit/Component)
143
179
 
144
180
  Create a ledger that lists every Scenario (SC) in Unit/Component scope:
@@ -146,7 +182,7 @@ Create a ledger that lists every Scenario (SC) in Unit/Component scope:
146
182
  - Inputs: `.qfai/specs/**/scenario.feature`
147
183
  - Scope: `@layer-unit`, `@layer-component`
148
184
  - Columns: SC ID / layer / target unit or component / test file / status (`done|missing|exception`)
149
- - Rule: **`missing=0` is required before completion.**
185
+ - Rule: **Coverage Ledger must be 100% implemented (blocked/skipped require DR + approval) before completion.**
150
186
 
151
187
  If a test is not automatable right now, record it as `exception` with a clear reason and a follow-up plan.
152
188
 
@@ -11,7 +11,7 @@ title: QFAI TDD Refactor (Improve structure safely)
11
11
  description: "Refactor code without behavior change after tests are green."
12
12
  argument-hint: "<spec-id> [--auto]"
13
13
  allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
- roles: [ArchitectReviewer, BackendEngineer, FrontendEngineer, QAEngineer, CodeReviewer]
14
+ roles: [ArchitectReviewer, BackendEngineer, FrontendEngineer, QAEngineer, RuntimeGatekeeper, CodeReviewer]
15
15
  mode: refactor
16
16
 
17
17
  ---
@@ -38,6 +38,18 @@ When unsure, read inputs in this order:
38
38
  - P3: `.qfai/specs/<spec-id>/delta.md` (Decision Records; if no spec yet, state "not applicable")
39
39
  - P4: other artifacts (spec.md, scenario.feature, contracts, evidence)
40
40
 
41
+ ## Change Type (Mandatory)
42
+
43
+ Before updating `delta.md`, declare the Change Type and record it in:
44
+
45
+ - `delta.md` Change Log (latest CL entry)
46
+ - PR description (Change Type section)
47
+
48
+ Allowed values:
49
+
50
+ - Primary: `Initial | Behavior | Structural | Ops`
51
+ - Tags (optional): `@ui @api @db @nfr @docs @test`
52
+
41
53
  ## Delta Rejected Guard (Mandatory)
42
54
 
43
55
  - Do NOT reintroduce options marked as rejected in delta.md.
@@ -50,10 +62,18 @@ When unsure, read inputs in this order:
50
62
  - You MUST produce the required evidence file: `.qfai/evidence/tdd-refactor-<spec-id>.md`.
51
63
  - `.qfai/evidence/` is intentionally NOT tracked by Git (it ships with a local `.gitignore`).
52
64
  - Do NOT commit evidence files; summarize key outcomes in the PR description instead.
65
+ - You MUST re-run the Runtime Gate (when applicable) and capture evidence.
53
66
  - You MUST run the mandatory checks listed below and record outcomes.
54
67
  - You MUST stop and escalate if refactor risks behavior changes.
55
68
  - Completion must be approved by a reviewer who did not implement the refactor.
56
69
 
70
+ ## Sub-agent policy (mandatory)
71
+
72
+ - If subagents are supported, Orchestrator MUST delegate: implementation (Engineers), QA, Runtime Gatekeeper, Reviewer (non-edit).
73
+ - Orchestrator must not implement directly when delegation is available.
74
+ - Evidence must include work orders and reviewer notes.
75
+ - If subagents are not supported, simulate role separation with explicit role sections.
76
+
57
77
  ## Completion Contract (Shared)
58
78
 
59
79
  Before declaring completion, you MUST:
@@ -67,6 +87,18 @@ Before declaring completion, you MUST:
67
87
 
68
88
  Refactor the codebase without behavior change after tests are green, preserving spec and contract intent.
69
89
 
90
+ ## Non-goals
91
+
92
+ - Adding new features or changing external behavior.
93
+ - Writing new tests (use TDD phases).
94
+
95
+ ## Mandatory Outputs
96
+
97
+ - Refactor diffs with behavior preserved
98
+ - Runtime Gate evidence (if applicable)
99
+ - Evidence file: `.qfai/evidence/tdd-refactor-<spec-id>.md`
100
+ - Reviewer notes (PASS or concrete rework list)
101
+
70
102
  ## Guardrails
71
103
 
72
104
  - Do not invent DB/API/infra. If missing, stop and raise Open Questions.
@@ -78,7 +110,7 @@ Refactor the codebase without behavior change after tests are green, preserving
78
110
 
79
111
  - Behavior remains unchanged and matches the spec and contracts.
80
112
  - TDD/ATDD tests remain green after refactor.
81
- - Unit/Component Coverage Ledger remains `missing=0` (exceptions documented).
113
+ - Unit/Component Coverage Ledger remains 100% implemented (blocked/skipped require DR + approval).
82
114
  - Repo quality gates pass (lint/type/build/pack as applicable).
83
115
  - Verification evidence is recorded (commands + results).
84
116
  - Evidence file exists: `.qfai/evidence/tdd-refactor-<spec-id>.md`.
@@ -94,6 +126,11 @@ Refactor the codebase without behavior change after tests are green, preserving
94
126
  - Behavior changes without spec update.
95
127
  - Tests not run after refactor.
96
128
 
129
+ ## Failure handling (mandatory)
130
+
131
+ - If blocked/unknown, stop and record a DR in delta.md (do not skip).
132
+ - If Runtime Gate fails, fix and re-run before declaring completion.
133
+
97
134
  ## Coverage Ledger continuity
98
135
 
99
136
  - Review the Unit/Component Coverage Ledger from `/qfai-tdd-red`.
@@ -431,7 +468,7 @@ Iterate until all gates pass, prioritizing:
431
468
 
432
469
  **Before declaring implementation complete, you MUST verify:**
433
470
 
434
- 1. Unit/Component Coverage Ledger shows `missing=0` (exceptions documented).
471
+ 1. Unit/Component Coverage Ledger shows 100% implemented (blocked/skipped require DR + approval).
435
472
 
436
473
  2. Runtime evidence commands executed and outcomes recorded.
437
474
 
@@ -20,7 +20,8 @@ Recommended approach:
20
20
 
21
21
  ## Naming
22
22
 
23
- - `.qfai/evidence/<prompt>-<run-id>.md`
23
+ - Summary file: `.qfai/evidence/<prompt>-<run-id>.md`
24
+ - Optional artifacts: `.qfai/evidence/<prompt>/<YYYY-MM-DD>/<run-id>/...`
24
25
  - `<run-id>`: prefer `spec-XXXX` when applicable.
25
26
 
26
27
  ## Minimal content template
@@ -41,7 +41,7 @@ specs/
41
41
  - `CASE-XXXX-YYYY` (test case)
42
42
  - `SC-XXXX-YYYY` (scenario tag in feature file)
43
43
  - Traceability must be consistent:
44
- - `traceability-matrix.md` maps **REQ → BR → AC → CASE → SC → Contracts**.
44
+ - `traceability-matrix.md` maps **REQ → BR → AC → CASE → SC → Status → Contracts**.
45
45
  - `scenario.feature` may contain multiple Scenarios/Outlines (standard Gherkin style).
46
46
  - Layer/size tags:
47
47
  - Each Scenario SHOULD declare `@layer:<...>` and `@size:<...>` once the project opts in.
@@ -185,6 +185,9 @@ specs/
185
185
 
186
186
  - date: <YYYY-MM-DD>
187
187
  - author: <AI/role or human>
188
+ - change_type_primary: Initial | Behavior | Structural | Ops
189
+ - change_type_tags: <space-separated tags or empty>
190
+ - example: @api @db
188
191
  - scope: <files/areas>
189
192
  - change: <what changed>
190
193
  - reason: <why it changed>
@@ -204,6 +207,8 @@ specs/
204
207
  - selected: <option>
205
208
  - rejected:
206
209
  - <option> — <reason>
210
+ - do_not: <what must not be reintroduced>
211
+ - temptation: <why it may be tempting to reintroduce>
207
212
  - impact: <downstream impact>
208
213
  - followups: <todos>
209
214
  - related_contracts: <QFAI-CONTRACT-REF or IDs>
@@ -336,11 +341,18 @@ Explain why the case set is “enough”:
336
341
  | Created | <YYYY-MM-DD> |
337
342
  | Updated | <YYYY-MM-DD> |
338
343
 
339
- ## Full chain (REQ → BR → AC → CASE → SC → Contracts)
344
+ ## Full chain (REQ → BR → AC → CASE → SC → Status → Contracts)
340
345
 
341
- | REQ | BR | AC | CASE | SC | Contracts |
342
- | ------------- | -------------- | -------------- | ---------------- | -------------- | -------------------------- |
343
- | REQ-FUNC-0010 | BR-<XXXX>-0001 | AC-<XXXX>-0001 | CASE-<XXXX>-0001 | SC-<XXXX>-0001 | UI-0001, API-0002, DB-0003 |
346
+ | REQ | BR | AC | CASE | SC | Status | Contracts |
347
+ | ------------- | -------------- | -------------- | ---------------- | -------------- | ----------- | -------------------------- |
348
+ | REQ-FUNC-0010 | BR-<XXXX>-0001 | AC-<XXXX>-0001 | CASE-<XXXX>-0001 | SC-<XXXX>-0001 | implemented | UI-0001, API-0002, DB-0003 |
349
+
350
+ Status values:
351
+
352
+ - `implemented` | `planned` (default: implemented if omitted)
353
+ - Use `planned` for Unit/Component during ATDD phase; promote to `implemented` in TDD/full.
354
+
355
+ Note: The Status column is optional. If omitted, all rows are treated as `implemented` for backward compatibility.
344
356
 
345
357
  ## Coverage summary
346
358
 
@@ -0,0 +1,17 @@
1
+ # ATDD API Implementer (Claude Code wrapper)
2
+
3
+ ## Purpose
4
+
5
+ This is a thin wrapper for Claude Code agents. The canonical role card lives in .qfai/assistant/agents/atdd-api-implementer.md.
6
+
7
+ ## Rules
8
+
9
+ - Always follow the .qfai role card and instructions first.
10
+ - If this file conflicts with .qfai, the .qfai content wins.
11
+ - Do not proceed without reading the role card.
12
+
13
+ ## Minimal steps
14
+
15
+ 1. Read .qfai/assistant/agents/atdd-api-implementer.md and follow its output format.
16
+ 2. Use .qfai/assistant/steering/ and .qfai/assistant/instructions/ as required context.
17
+ 3. List unknowns as Open Questions; do not mix them with decisions.
@@ -0,0 +1,17 @@
1
+ # ATDD E2E Implementer (Claude Code wrapper)
2
+
3
+ ## Purpose
4
+
5
+ This is a thin wrapper for Claude Code agents. The canonical role card lives in .qfai/assistant/agents/atdd-e2e-implementer.md.
6
+
7
+ ## Rules
8
+
9
+ - Always follow the .qfai role card and instructions first.
10
+ - If this file conflicts with .qfai, the .qfai content wins.
11
+ - Do not proceed without reading the role card.
12
+
13
+ ## Minimal steps
14
+
15
+ 1. Read .qfai/assistant/agents/atdd-e2e-implementer.md and follow its output format.
16
+ 2. Use .qfai/assistant/steering/ and .qfai/assistant/instructions/ as required context.
17
+ 3. List unknowns as Open Questions; do not mix them with decisions.
@@ -0,0 +1,17 @@
1
+ # ATDD Integration Implementer (Claude Code wrapper)
2
+
3
+ ## Purpose
4
+
5
+ This is a thin wrapper for Claude Code agents. The canonical role card lives in .qfai/assistant/agents/atdd-integration-implementer.md.
6
+
7
+ ## Rules
8
+
9
+ - Always follow the .qfai role card and instructions first.
10
+ - If this file conflicts with .qfai, the .qfai content wins.
11
+ - Do not proceed without reading the role card.
12
+
13
+ ## Minimal steps
14
+
15
+ 1. Read .qfai/assistant/agents/atdd-integration-implementer.md and follow its output format.
16
+ 2. Use .qfai/assistant/steering/ and .qfai/assistant/instructions/ as required context.
17
+ 3. List unknowns as Open Questions; do not mix them with decisions.
@@ -0,0 +1,17 @@
1
+ # Doc Steward (Claude Code wrapper)
2
+
3
+ ## Purpose
4
+
5
+ This is a thin wrapper for Claude Code agents. The canonical role card lives in .qfai/assistant/agents/doc-steward.md.
6
+
7
+ ## Rules
8
+
9
+ - Always follow the .qfai role card and instructions first.
10
+ - If this file conflicts with .qfai, the .qfai content wins.
11
+ - Do not proceed without reading the role card.
12
+
13
+ ## Minimal steps
14
+
15
+ 1. Read .qfai/assistant/agents/doc-steward.md and follow its output format.
16
+ 2. Use .qfai/assistant/steering/ and .qfai/assistant/instructions/ as required context.
17
+ 3. List unknowns as Open Questions; do not mix them with decisions.
@@ -0,0 +1,17 @@
1
+ # Orchestrator (Claude Code wrapper)
2
+
3
+ ## Purpose
4
+
5
+ This is a thin wrapper for Claude Code agents. The canonical role card lives in .qfai/assistant/agents/orchestrator.md.
6
+
7
+ ## Rules
8
+
9
+ - Always follow the .qfai role card and instructions first.
10
+ - If this file conflicts with .qfai, the .qfai content wins.
11
+ - Do not proceed without reading the role card.
12
+
13
+ ## Minimal steps
14
+
15
+ 1. Read .qfai/assistant/agents/orchestrator.md and follow its output format.
16
+ 2. Use .qfai/assistant/steering/ and .qfai/assistant/instructions/ as required context.
17
+ 3. List unknowns as Open Questions; do not mix them with decisions.