@drafthq/draft 2.7.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 (158) hide show
  1. package/.claude-plugin/marketplace.json +38 -0
  2. package/.claude-plugin/plugin.json +26 -0
  3. package/LICENSE +21 -0
  4. package/README.md +272 -0
  5. package/bin/README.md +49 -0
  6. package/cli/bin/draft.js +13 -0
  7. package/cli/src/cli.js +113 -0
  8. package/cli/src/hosts/claude-code.js +46 -0
  9. package/cli/src/hosts/codex.js +33 -0
  10. package/cli/src/hosts/cursor.js +50 -0
  11. package/cli/src/hosts/index.js +24 -0
  12. package/cli/src/hosts/opencode.js +39 -0
  13. package/cli/src/installer.js +61 -0
  14. package/cli/src/lib/fsx.js +34 -0
  15. package/cli/src/lib/graph.js +23 -0
  16. package/cli/src/lib/log.js +32 -0
  17. package/cli/src/lib/paths.js +14 -0
  18. package/core/agents/architect.md +338 -0
  19. package/core/agents/debugger.md +193 -0
  20. package/core/agents/ops.md +104 -0
  21. package/core/agents/planner.md +158 -0
  22. package/core/agents/rca.md +314 -0
  23. package/core/agents/reviewer.md +256 -0
  24. package/core/agents/writer.md +110 -0
  25. package/core/guardrails/README.md +4 -0
  26. package/core/guardrails/code-quality.md +4 -0
  27. package/core/guardrails/dependency-triage.md +4 -0
  28. package/core/guardrails/design-norms.md +4 -0
  29. package/core/guardrails/language-standards.md +4 -0
  30. package/core/guardrails/review-checks.md +4 -0
  31. package/core/guardrails/secure-patterns.md +4 -0
  32. package/core/guardrails/security.md +4 -0
  33. package/core/guardrails.md +22 -0
  34. package/core/knowledge-base.md +127 -0
  35. package/core/methodology.md +1221 -0
  36. package/core/shared/condensation.md +224 -0
  37. package/core/shared/context-verify.md +44 -0
  38. package/core/shared/cross-skill-dispatch.md +127 -0
  39. package/core/shared/discovery-schema.md +75 -0
  40. package/core/shared/draft-context-loading.md +282 -0
  41. package/core/shared/git-report-metadata.md +106 -0
  42. package/core/shared/graph-query.md +239 -0
  43. package/core/shared/graph-usage-report.md +22 -0
  44. package/core/shared/jira-sync.md +170 -0
  45. package/core/shared/parallel-analysis.md +386 -0
  46. package/core/shared/parallel-fanout.md +10 -0
  47. package/core/shared/pattern-learning.md +146 -0
  48. package/core/shared/red-flags.md +58 -0
  49. package/core/shared/template-contract.md +22 -0
  50. package/core/shared/template-hygiene.md +10 -0
  51. package/core/shared/tool-resolver.md +10 -0
  52. package/core/shared/vcs-commands.md +97 -0
  53. package/core/shared/verification-gates.md +47 -0
  54. package/core/templates/CHANGELOG.md +70 -0
  55. package/core/templates/ai-context-export.md +8 -0
  56. package/core/templates/ai-context.md +270 -0
  57. package/core/templates/ai-profile.md +41 -0
  58. package/core/templates/architecture.md +203 -0
  59. package/core/templates/dependency-graph.md +103 -0
  60. package/core/templates/discovery.md +79 -0
  61. package/core/templates/guardrails.md +143 -0
  62. package/core/templates/hld.md +327 -0
  63. package/core/templates/intake-questions.md +403 -0
  64. package/core/templates/jira.md +119 -0
  65. package/core/templates/lld.md +283 -0
  66. package/core/templates/metadata.json +66 -0
  67. package/core/templates/plan.md +130 -0
  68. package/core/templates/product.md +110 -0
  69. package/core/templates/rca.md +86 -0
  70. package/core/templates/root-architecture.md +127 -0
  71. package/core/templates/root-product.md +53 -0
  72. package/core/templates/root-tech-stack.md +117 -0
  73. package/core/templates/service-index.md +55 -0
  74. package/core/templates/session-summary.md +8 -0
  75. package/core/templates/spec.md +165 -0
  76. package/core/templates/tech-matrix.md +101 -0
  77. package/core/templates/tech-stack.md +169 -0
  78. package/core/templates/track-architecture.md +311 -0
  79. package/core/templates/workflow.md +187 -0
  80. package/integrations/agents/AGENTS.md +24384 -0
  81. package/integrations/copilot/.github/copilot-instructions.md +24384 -0
  82. package/integrations/gemini/.gemini.md +26 -0
  83. package/package.json +53 -0
  84. package/scripts/fetch-memory-engine.sh +116 -0
  85. package/scripts/lib.sh +256 -0
  86. package/scripts/tools/_lib.sh +220 -0
  87. package/scripts/tools/adr-index.sh +117 -0
  88. package/scripts/tools/check-graph-usage-report.sh +95 -0
  89. package/scripts/tools/check-scope-conflicts.sh +139 -0
  90. package/scripts/tools/check-skill-line-caps.sh +115 -0
  91. package/scripts/tools/check-template-noop.sh +87 -0
  92. package/scripts/tools/check-track-hygiene.sh +230 -0
  93. package/scripts/tools/classify-files.sh +231 -0
  94. package/scripts/tools/cycle-detect.sh +75 -0
  95. package/scripts/tools/detect-test-framework.sh +135 -0
  96. package/scripts/tools/diff-templates-vs-tracks.sh +176 -0
  97. package/scripts/tools/emit-skill-metrics.sh +71 -0
  98. package/scripts/tools/fix-whitespace.sh +192 -0
  99. package/scripts/tools/freshness-check.sh +143 -0
  100. package/scripts/tools/git-metadata.sh +203 -0
  101. package/scripts/tools/graph-callers.sh +74 -0
  102. package/scripts/tools/graph-impact.sh +93 -0
  103. package/scripts/tools/graph-snapshot.sh +102 -0
  104. package/scripts/tools/hotspot-rank.sh +75 -0
  105. package/scripts/tools/manage-symlinks.sh +85 -0
  106. package/scripts/tools/mermaid-from-graph.sh +92 -0
  107. package/scripts/tools/migrate-track-frontmatter.sh +241 -0
  108. package/scripts/tools/parse-git-log.sh +135 -0
  109. package/scripts/tools/parse-reports.sh +114 -0
  110. package/scripts/tools/render-track.sh +145 -0
  111. package/scripts/tools/run-coverage.sh +153 -0
  112. package/scripts/tools/scan-markers.sh +144 -0
  113. package/scripts/tools/skill-caps.conf +24 -0
  114. package/scripts/tools/validate-frontmatter.sh +125 -0
  115. package/scripts/tools/verify-citations.sh +250 -0
  116. package/scripts/tools/verify-doc-anchors.sh +204 -0
  117. package/scripts/tools/verify-graph-binary.sh +154 -0
  118. package/skills/GRAPH.md +332 -0
  119. package/skills/adr/SKILL.md +374 -0
  120. package/skills/assist-review/SKILL.md +49 -0
  121. package/skills/bughunt/SKILL.md +668 -0
  122. package/skills/bughunt/references/regression-tests.md +399 -0
  123. package/skills/change/SKILL.md +267 -0
  124. package/skills/coverage/SKILL.md +336 -0
  125. package/skills/debug/SKILL.md +201 -0
  126. package/skills/decompose/SKILL.md +656 -0
  127. package/skills/deep-review/SKILL.md +326 -0
  128. package/skills/deploy-checklist/SKILL.md +254 -0
  129. package/skills/discover/SKILL.md +66 -0
  130. package/skills/docs/SKILL.md +42 -0
  131. package/skills/documentation/SKILL.md +197 -0
  132. package/skills/draft/SKILL.md +177 -0
  133. package/skills/draft/context-files.md +57 -0
  134. package/skills/draft/intent-mapping.md +37 -0
  135. package/skills/draft/quality-guide.md +51 -0
  136. package/skills/graph/SKILL.md +107 -0
  137. package/skills/impact/SKILL.md +86 -0
  138. package/skills/implement/SKILL.md +794 -0
  139. package/skills/incident-response/SKILL.md +245 -0
  140. package/skills/index/SKILL.md +848 -0
  141. package/skills/init/SKILL.md +1784 -0
  142. package/skills/init/references/architecture-spec.md +1259 -0
  143. package/skills/integrations/SKILL.md +53 -0
  144. package/skills/jira/SKILL.md +577 -0
  145. package/skills/jira/references/review.md +1322 -0
  146. package/skills/learn/SKILL.md +478 -0
  147. package/skills/new-track/SKILL.md +841 -0
  148. package/skills/ops/SKILL.md +57 -0
  149. package/skills/plan/SKILL.md +60 -0
  150. package/skills/quick-review/SKILL.md +216 -0
  151. package/skills/revert/SKILL.md +178 -0
  152. package/skills/review/SKILL.md +1114 -0
  153. package/skills/standup/SKILL.md +183 -0
  154. package/skills/status/SKILL.md +183 -0
  155. package/skills/tech-debt/SKILL.md +318 -0
  156. package/skills/testing-strategy/SKILL.md +195 -0
  157. package/skills/tour/SKILL.md +38 -0
  158. package/skills/upload/SKILL.md +117 -0
@@ -0,0 +1,1322 @@
1
+ ---
2
+ shared: jira:review
3
+ applies_to: /draft:jira review <JIRA_ID>
4
+ ---
5
+
6
+ # Jira Review Pipeline
7
+
8
+ Qualify any Jira ticket — Epic, Story, Bug, or Sub-task — by running a mandatory pipeline: collect Jira data, fetch documents (design doc, test plan), gather code changes (Gerrit/GitHub/GitLab), audit quality via Draft commands, analyze test coverage, and produce a gap-analysis report with qualification verdict.
9
+
10
+ **Input:** `$ARGUMENTS` = Jira ID (e.g., `ENG-446236`, `PROJ-1234`).
11
+
12
+ **Invoked via:** `/draft:jira review <JIRA_ID>`. The router in [SKILL.md](SKILL.md) dispatches here.
13
+
14
+ ## Red Flags — STOP if you're:
15
+
16
+ - Skipping Phase 0 prerequisites — MCP servers and `draft/` context are **required**.
17
+ - Treating `context.md` as the final report — it's intermediate input for quality analysis.
18
+ - Running `draft:deep-review` or `draft:bughunt` without `draft/` context existing.
19
+ - Reporting a verdict without synthesizing deep-review AND bughunt AND test gap findings.
20
+ - Ignoring unresolved stories or stories without code changes.
21
+ - Skipping document collection — design docs and test plans are qualification inputs.
22
+ - Generating the report via `draft:new-track` — write the report **directly** using the inline templates.
23
+ - Omitting YAML metadata headers from generated files — every file in `draft/` requires them.
24
+
25
+ ---
26
+
27
+ ## Issue Type Adaptation
28
+
29
+ This pipeline runs against any Jira ticket. Behavior adapts based on `issuetype` fetched in Phase 0:
30
+
31
+ | Issue Type | Phase 1 Fan-Out | Scope | Verdict Wording |
32
+ |------------|----------------|-------|-----------------|
33
+ | **Epic** | Yes — discover child stories via `Epic Link` / `parent` JQL | Multi-story qualification | "All code stories resolved" |
34
+ | **Story** | No — treat the story itself as the only "story" record | Single-story qualification | "Story resolved" |
35
+ | **Bug** | No — treat the bug itself as the only "story" record | Single-bug qualification (fix code changes, regression test) | "Bug resolved with regression test" |
36
+ | **Sub-task** | No — fetch parent for context, but qualify the sub-task scope | Sub-task qualification (note parent in report) | "Sub-task resolved" |
37
+ | **Task** (non-code) | No fan-out, no code analysis | Minimal report explaining qualification doesn't apply to non-code tasks | "Non-code task — qualification N/A" |
38
+
39
+ Throughout the rest of this document, "story" means "child story (epic mode) OR self (non-epic mode)" — the data model is the same.
40
+
41
+ ---
42
+
43
+ ## Pipeline Overview
44
+
45
+ ```
46
+ Phase 0: Prerequisites & MCP Discovery ← fail-fast, verify ALL MCPs, branch on issuetype
47
+ Phase 1: Issue & Story Collection (Jira MCP) — fan-out for Epic, self-only otherwise
48
+ Phase 2: Document Collection & Synthesis (WebFetch / configured MCPs)
49
+ Phase 3: Code Change Collection (Gerrit/GitHub/GitLab MCP)
50
+ Phase 4: Context Synthesis (generate context.md)
51
+ Phase 5: Quality Analysis (draft:deep-review, draft:bughunt, draft:coverage)
52
+ Phase 6: Test Gap Analysis (TestRail + coverage + acceptance criteria)
53
+ Phase 7: Report Generation (qualification-report.md + remediation-plan.md)
54
+ ```
55
+
56
+ Every phase is mandatory. Each consumes output from previous phases.
57
+
58
+ ---
59
+
60
+ ## File Metadata Convention
61
+
62
+ **Every generated file** under `draft/jira-review/<JIRA_ID>/` must include this YAML frontmatter:
63
+
64
+ ```yaml
65
+ ---
66
+ project: "{PROJECT_NAME}"
67
+ jira_id: "{JIRA_ID}"
68
+ issue_type: "{Epic | Story | Bug | Sub-task | Task}"
69
+ generated_by: "draft:jira:review"
70
+ generated_at: "{ISO_TIMESTAMP}"
71
+ phase: "{phase number that generated this file}"
72
+ mcp_servers:
73
+ jira: true
74
+ code_review: "{gerrit|github|gitlab|none}"
75
+ testrail: {true|false}
76
+ previous_run: "{path to previous qualification-report.md or null}"
77
+ ---
78
+ ```
79
+
80
+ Git state (branch, commit, dirty, synced_to_commit) is read from `draft/metadata.json` — include a human-readable summary table in the report body but do not embed git fields in frontmatter.
81
+
82
+ Gather git metadata at pipeline start from `draft/metadata.json`:
83
+ ```bash
84
+ python3 -c "import json; d=json.load(open('draft/metadata.json')); print(d['git']['branch'], d['git']['commit_short'], d['synced_to_commit'])"
85
+ ```
86
+ Fallback if `draft/metadata.json` absent:
87
+ ```bash
88
+ git branch --show-current
89
+ git rev-parse HEAD
90
+ git rev-parse --short HEAD
91
+ git log -1 --format="%ci"
92
+ git status --porcelain | head -1
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Phase 0: Prerequisites & MCP Discovery
98
+
99
+ ### 0.1 Validate Input
100
+
101
+ Parse `$ARGUMENTS` as a Jira issue key:
102
+ - If matches `<PROJECT>-<NUMBER>` (e.g., `ENG-446236`, `PROJ-1234`): use as-is.
103
+ - If numeric-only (e.g., `446236`): prompt user for project prefix — do NOT assume.
104
+ - If invalid format: **STOP** with usage example.
105
+
106
+ ### 0.2 MCP Server Verification
107
+
108
+ Verify all required servers upfront:
109
+
110
+ | Server | Required? | Verification Call | On Failure |
111
+ |--------|-----------|-------------------|------------|
112
+ | Jira MCP | **Required** | `get_issue(key=<JIRA_ID>, prune_mode="minimal")` | **STOP**: "Jira MCP required." |
113
+ | Code Review MCP | **Required** | See detection table below | **DEGRADE**: skip Phase 3 code review checks, cap verdict at PARTIALLY QUALIFIED |
114
+ | TestRail MCP | Optional | Check if TestRail tools exist in environment | **DEGRADE**: flag as gap |
115
+ | Other MCPs | Optional | Discovered per-URL in Phase 2 | **DEGRADE**: fall back to WebFetch |
116
+
117
+ **Code Review MCP Detection** — try in order, use the first that responds:
118
+
119
+ | MCP | Detection Call | Confirms |
120
+ |-----|---------------|----------|
121
+ | Gerrit MCP | `get_change_details("1", options=[])` — expect error, confirms server responds | Gerrit code review |
122
+ | GitHub MCP | Check for GitHub tools (e.g., `get_pull_request`) in environment | GitHub PRs |
123
+ | GitLab MCP | Check for GitLab tools (e.g., `get_merge_request`) in environment | GitLab MRs |
124
+
125
+ Record the detected Code Review MCP type — Phase 3 adapts its calls accordingly. If none detected, Phase 3 collects file changes from Jira comments and direct codebase access only (no review quality metrics).
126
+
127
+ ### 0.3 Draft Context Verification
128
+
129
+ The working directory **must** have Draft context. `draft:deep-review`, `draft:bughunt`, and `draft:coverage` depend on it.
130
+
131
+ ```
132
+ IF draft/.ai-context.md AND draft/architecture.md exist:
133
+ → Use existing context
134
+ → Read synced_to_commit from draft/metadata.json (fallback: draft/.ai-context.md YAML frontmatter for pre-migration installs)
135
+ → Compare to current HEAD: git log --oneline <synced_to_commit>..HEAD -- . ':!draft/'
136
+ → If >20 commits since sync: warn "Draft context may be stale — consider draft:init refresh"
137
+
138
+ ELSE:
139
+ → Run draft:init to establish full project context
140
+ → Wait for init to complete before proceeding — this is blocking
141
+ ```
142
+
143
+ ### 0.4 Issue Type Detection & Branching
144
+
145
+ After validating input and verifying MCPs, fetch the issue's type:
146
+
147
+ ```
148
+ get_issue(key=<JIRA_ID>, prune_mode="minimal")
149
+ → record issue_type, parent (for sub-tasks)
150
+ ```
151
+
152
+ Branch based on `issue_type`:
153
+ - **Epic** → enable Phase 1.3 fan-out (collect child stories).
154
+ - **Story / Bug** → skip Phase 1.3 fan-out; treat self as the only story record.
155
+ - **Sub-task** → skip Phase 1.3 fan-out; treat self as the only story record; fetch parent for context.
156
+ - **Task** → if labels/description suggest non-code (documentation, design, config, process), produce minimal report at Phase 7 (skip code-analysis phases). Otherwise treat as Story.
157
+
158
+ Announce: "Reviewing {issue_type} `<JIRA_ID>` — {fan-out enabled | self-only scope}"
159
+
160
+ ### 0.5 Check for Previous Runs
161
+
162
+ ```bash
163
+ ls draft/jira-review/<JIRA_ID>/qualification-report.md 2>/dev/null
164
+ ```
165
+
166
+ If a previous run exists:
167
+ - Note its `generated_at` timestamp for delta comparison in Phase 7.
168
+ - Do NOT delete — the new run overwrites.
169
+
170
+ ### 0.6 Create Output Directory
171
+
172
+ ```bash
173
+ mkdir -p draft/jira-review/<JIRA_ID>
174
+ ```
175
+
176
+ Announce: "Starting Jira Review Pipeline for `<JIRA_ID>`"
177
+
178
+ ---
179
+
180
+ ## Phase 1: Issue & Story Collection
181
+
182
+ ### 1.1 Issue Metadata
183
+
184
+ ```
185
+ get_issue(key=<JIRA_ID>, prune_mode="full")
186
+ get_issue_description(issue_key=<JIRA_ID>)
187
+ get_issue_comments(issue_key=<JIRA_ID>, prune_mode="default")
188
+ ```
189
+
190
+ From the full issue, extract and store: key, summary, status, assignee, priority, type, created, updated, labels, components, fix versions.
191
+
192
+ For **Sub-task** type, also fetch the parent:
193
+ ```
194
+ get_issue(key=<PARENT_KEY>, prune_mode="minimal")
195
+ ```
196
+ Record parent key and summary — included in the report for context, not qualified itself.
197
+
198
+ ### 1.2 Extract Artifact Links
199
+
200
+ Scan issue description, custom fields, and comments for:
201
+
202
+ | Artifact | URL Patterns | Jira Field Names to Check |
203
+ |----------|-------------|---------------------------|
204
+ | Design Doc | `docs.google.com`, `confluence`, `sharepoint`, `notion`, `*.docx` attachments | "Design Doc Link", "Design Document", "Design Spec" |
205
+ | Test Plan | `testrail`, `confluence/test`, `testplan` | "Test Plan Link", "QA Plan", "Test Plan", "Validation Plan" |
206
+ | TestRail Results | TestRail URLs, embedded pass/fail data | "TestRail: Results", "Test Results", "QA Results" |
207
+
208
+ Also check:
209
+ - `get_linked_issues(issue_key=<JIRA_ID>)` for documentation-type tickets.
210
+ - Jira attachments (design docs uploaded directly to the issue).
211
+
212
+ For each artifact: record URL, type, and hold for Phase 2.
213
+
214
+ ### 1.3 Story Discovery (Epic only)
215
+
216
+ **Skip this step for Story / Bug / Sub-task / Task** — the issue itself is the single "story" record. Proceed to 1.4 with `stories = [self]`.
217
+
218
+ For **Epic**:
219
+
220
+ ```
221
+ get_issues(jql="\"Epic Link\" = <JIRA_ID>", max_results=100, prune_mode="default")
222
+ ```
223
+
224
+ **Pagination:** If `truncated: true`, increase `max_results` or make follow-up calls. Do not silently drop stories.
225
+
226
+ **Fallbacks** (try in order, stop when results found):
227
+ 1. `get_issues(jql="parent = <JIRA_ID>", max_results=100)` — Jira Cloud uses `parent` instead of `Epic Link`.
228
+ 2. `get_linked_issues(issue_key=<JIRA_ID>, relationship_type="epic child")`.
229
+ 3. `get_linked_issues(issue_key=<JIRA_ID>)` — all links, filter child/subtask types.
230
+
231
+ If all return zero: flag "no stories found", produce minimal report.
232
+
233
+ ### 1.4 Story Enrichment
234
+
235
+ Per story (or per the single self-record for non-Epic):
236
+ ```
237
+ get_issue(key=<STORY_ID>, prune_mode="default")
238
+ get_issue_comments(issue_key=<STORY_ID>, prune_mode="default")
239
+ ```
240
+
241
+ Collect: key, summary, status, type, assignee, priority, created, updated, labels.
242
+ Extract from description: acceptance criteria (numbered list).
243
+ Extract from comments: code-review URLs / change IDs (see Phase 3.1 for patterns).
244
+ Extract from fields: "TestRail: Results" if present.
245
+
246
+ ### 1.5 Sub-Task Collection
247
+
248
+ Per story, check for sub-tasks:
249
+ ```
250
+ get_linked_issues(issue_key=<STORY_ID>, relationship_type="subtask")
251
+ ```
252
+
253
+ Or parse the `subtasks` field from `get_issue(key=<STORY_ID>, prune_mode="full")`.
254
+
255
+ For each sub-task:
256
+ - Collect its code-review links from comments (same extraction as stories).
257
+ - Roll up sub-task code changes into the parent story's change set.
258
+ - Do NOT treat sub-tasks as independent stories for gap analysis.
259
+
260
+ ### 1.6 Story Classification
261
+
262
+ | Classification | Criteria | Code Changes Expected? |
263
+ |----------------|----------|--------------------------|
264
+ | Code-deliverable | Default for Story/Bug types | Yes |
265
+ | Non-code | Type=Task AND (labels contain "documentation"/"design"/"config-only"/"process" OR description states no code change) | No |
266
+ | Excluded | Status ∈ {Won't Do, Duplicate, Won't Fix, Cancelled}; or explicitly moved to different epic | No — excluded from gap analysis |
267
+
268
+ ### 1.7 Verify Resolution
269
+
270
+ Check each code-deliverable story status:
271
+
272
+ | Status Category | Statuses | Flag |
273
+ |-----------------|----------|------|
274
+ | Resolved | Resolved, Done, Closed | None — passing |
275
+ | In Progress | In Progress, In Review, In QA | "IN PROGRESS — partial implementation, verify code changes" |
276
+ | Unresolved | Open, New, To Do, Reopened, Backlog | "UNRESOLVED — gap" |
277
+ | Blocked | Blocked, Impediment | "BLOCKED — escalation needed" |
278
+
279
+ Additional flags:
280
+ - No description or acceptance criteria → "INCOMPLETE SPEC — gap".
281
+ - Code-deliverable + no code-review links in comments → "NO CODE CHANGES — verify in Phase 3".
282
+
283
+ ---
284
+
285
+ ## Phase 2: Document Collection & Synthesis
286
+
287
+ ### 2.1 Design Document
288
+
289
+ **Access strategy** (try in order, stop on first success — local-first):
290
+
291
+ 1. **Local Draft artifacts (preferred):** For each story, check whether the corresponding track has `draft/tracks/<track_id>/hld.md` (and `lld.md`). When present, treat these as the canonical design doc for that story. Story → track mapping comes from spec.md frontmatter `track_id` or from a comment on the Jira story linking to the track. Multiple stories can share one HLD.
292
+ 2. Google Doc + Google Drive MCP available → use MCP.
293
+ 3. Confluence page + Confluence MCP available → use MCP.
294
+ 4. WebFetch with the URL.
295
+ 5. Jira attachment → download via Jira MCP if supported.
296
+ 6. All fail → record URL + "could not access" + flag as process gap.
297
+
298
+ **If content retrieved from local Draft artifacts**, synthesis pulls directly:
299
+ - §Background → Goals and scope.
300
+ - §High Level Design (Architecture, Key Design Decisions, Alternatives Considered) → Architecture / design decisions, key trade-offs.
301
+ - §Detailed Design → API changes.
302
+ - LLD §Data Model → data model changes.
303
+ - §Checklist → Non-functional requirements (Performance, Scale, Security, Resiliency, Multi-tenancy).
304
+ - §Approvals signed/unsigned → process compliance signal.
305
+
306
+ **If content retrieved from external doc**, synthesize and write to `draft/jira-review/<JIRA_ID>/design-doc-synthesis.md` (with metadata header):
307
+ - Goals and scope.
308
+ - Architecture / design decisions.
309
+ - API changes, data model changes.
310
+ - Key trade-offs and alternatives considered.
311
+ - Non-functional requirements (performance, security, scalability).
312
+
313
+ **Process gap signals** to flag:
314
+ - Track exists in `draft/tracks/` but no `hld.md` AND no external design doc — qualification gap.
315
+ - HLD exists but Approvals table fully unsigned — review-process gap (track was implemented without sign-off).
316
+ - HLD `synced_to_commit` is older than the latest merged code change for the track — drift gap (design and code diverged).
317
+
318
+ ### 2.2 Test Plan & TestRail Data
319
+
320
+ **Test Plan document** — same access strategy as 2.1. Synthesize test strategy and coverage goals.
321
+
322
+ **TestRail integration** (if TestRail MCP available):
323
+ - Extract test suite/run IDs from: Test Plan URL path segments, Jira "TestRail: Results" field, or story-level TestRail references.
324
+ - Fetch: test case ID, title, status (passed/failed/blocked/untested), mapped story.
325
+ - Fetch: test run results, pass rate summary.
326
+
327
+ **If TestRail MCP not available:**
328
+ - WebFetch on TestRail URLs.
329
+ - Parse "TestRail: Results" Jira field for embedded data (pass/fail counts, test case references).
330
+
331
+ **Write to** `draft/jira-review/<JIRA_ID>/test-data-synthesis.md` (with metadata header):
332
+ - Total test cases with pass/fail/blocked/untested counts.
333
+ - Test cases mapped to specific stories.
334
+ - Stories without test cases (test gaps).
335
+
336
+ ---
337
+
338
+ ## Phase 3: Code Change Collection
339
+
340
+ ### 3.1 Extract Code-Review Change IDs
341
+
342
+ From story and sub-task comments (Phase 1.4, 1.5), extract code-review identifiers. Patterns depend on the MCP detected in Phase 0.2:
343
+
344
+ **Gerrit patterns:**
345
+
346
+ | Pattern | Example | Extract |
347
+ |---------|---------|---------|
348
+ | Full Gerrit URL | `https://gerrit.example.com/c/project/+/12345` | `12345` |
349
+ | Legacy Gerrit URL | `https://gerrit.example.com/#/c/12345/` | `12345` |
350
+ | Short Gerrit URL | `https://gerrit.example.com/12345` | `12345` |
351
+ | Change-Id in text | `Change-Id: I8473b95a1f...` | `I8473b95a1f...` |
352
+ | Gerrit link markdown | `[Gerrit](https://gerrit.example.com/c/project/+/12345)` | `12345` |
353
+
354
+ **GitHub patterns:**
355
+
356
+ | Pattern | Example | Extract |
357
+ |---------|---------|---------|
358
+ | Full PR URL | `https://github.com/<org>/<repo>/pull/123` | `123` (with repo) |
359
+ | Short PR ref | `#123` (when issue references repo via Jira project mapping) | `123` |
360
+
361
+ **GitLab patterns:**
362
+
363
+ | Pattern | Example | Extract |
364
+ |---------|---------|---------|
365
+ | Full MR URL | `https://gitlab.com/<org>/<repo>/-/merge_requests/45` | `45` (with repo) |
366
+
367
+ **Extraction approach:** scan comment bodies for URLs containing the configured code-review host domain. Extract numeric IDs. Also scan for `Change-Id:` patterns in commit-formatted comments.
368
+
369
+ Group result: `{STORY_ID: [change_id_1, change_id_2, ...]}`. Include sub-task changes rolled up under the parent story.
370
+
371
+ ### 3.2 Code-Review MCP Per Change
372
+
373
+ For each change ID (Gerrit example shown; adapt calls for GitHub/GitLab):
374
+
375
+ ```
376
+ get_change_details(change_id, options=["ALL_REVISIONS", "MESSAGES", "REVIEWERS"])
377
+ → status (NEW/MERGED/ABANDONED), owner, reviewers, labels, branch,
378
+ insertions/deletions, patchset count (_number from revisions)
379
+
380
+ list_change_files(change_id, revision_id="current")
381
+ → file paths, status (ADDED/MODIFIED/DELETED/RENAMED), lines_inserted, lines_deleted
382
+
383
+ get_commit_message(change_id, revision_id="current")
384
+ → subject, body, author {name, email, date}, committer {name, email, date}
385
+
386
+ list_change_comments(change_id)
387
+ → per-file comments with: message, author, unresolved (boolean), patch_set
388
+ ```
389
+
390
+ For GitHub/GitLab the equivalents are `get_pull_request`, `list_pr_files`, `get_pr_commits`, `list_pr_review_comments` and analogous calls.
391
+
392
+ ### 3.3 Verification Checks
393
+
394
+ Per code change, evaluate:
395
+
396
+ | Check | Pass | Fail (= gap) | Severity |
397
+ |-------|------|---------------|----------|
398
+ | Change status | MERGED | NEW → "not merged"; ABANDONED → "abandoned" | Critical |
399
+ | Code-Review approval | +2 (Gerrit) / Approved (GitHub/GitLab) | None, or -1/-2 / Changes Requested | High |
400
+ | Verified / CI label | +1 / Green | Missing or red | High |
401
+ | Unresolved comments | Zero | Count > 0 | Medium |
402
+ | Patchset count | Informational | >5 = risk signal (note, not auto-fail) | Low |
403
+
404
+ ### 3.4 Consolidated Change Set
405
+
406
+ After all stories + sub-tasks processed:
407
+
408
+ - **Deduplicated file list** grouped by top-level module/directory, with per-file change status (ADDED/MODIFIED/DELETED).
409
+ - **All code changes** with story attribution (one change may map to multiple stories via sub-tasks).
410
+ - **Unique authors** and **unique reviewers**.
411
+ - **Review quality summary**: total changes, count MERGED with approval, count without approval, count with unresolved comments, average patchset count.
412
+ - **Scope metrics**: total files changed, total insertions, total deletions.
413
+ - **Test file classification**: classify every file in the change set as **test** or **production**:
414
+
415
+ | Language | Test File Patterns |
416
+ |----------|--------------------|
417
+ | Go | `*_test.go` |
418
+ | Python | `test_*.py`, `*_test.py`, files under `tests/` |
419
+ | Java/Kotlin | `*Test.java`, `*Tests.java`, `*Spec.kt`, files under `src/test/` |
420
+ | JavaScript/TypeScript | `*.test.ts`, `*.spec.ts`, `*.test.js`, `*.spec.js`, files under `__tests__/` |
421
+ | C/C++ | `*_test.cc`, `*_test.cpp`, `*_unittest.cc`, files under `test/` or `tests/` |
422
+ | Rust | `#[cfg(test)]` modules, files under `tests/` |
423
+ | General | Files under directories named `test/`, `tests/`, `testing/`, `spec/` |
424
+
425
+ Also check `draft/tech-stack.md` for project-specific test conventions that override defaults.
426
+
427
+ Per story, record:
428
+ - Count of production files changed.
429
+ - Count of test files changed.
430
+ - **Test file ratio**: test files / total files (0% = no tests shipped with code).
431
+
432
+ ### 3.5 Issue-Level Changes (Epic mode only)
433
+
434
+ Extract code-review links from **issue-level comments** (Phase 1.1). These are changes referencing the epic directly, not a specific story. Reconcile with per-story results — flag any issue-level changes not attributed to a story.
435
+
436
+ ### 3.6 No Changes for Code Story
437
+
438
+ If a code-deliverable story has **no code changes** (including sub-tasks):
439
+ - Check issue-level changes for commit messages mentioning the story ID.
440
+ - If still none: flag "implementation gap — no code changes found".
441
+
442
+ ---
443
+
444
+ ## Phase 4: Context Synthesis
445
+
446
+ Generate `draft/jira-review/<JIRA_ID>/context.md` (with metadata header) combining all data from Phases 1-3.
447
+
448
+ ### Context Document Structure
449
+
450
+ ```markdown
451
+ # Jira Review Context: <JIRA_ID> — <Summary>
452
+
453
+ ## Pipeline Execution
454
+ | Field | Value |
455
+ |-------|-------|
456
+ | Qualification Date | <ISO timestamp> |
457
+ | Issue Type | <Epic | Story | Bug | Sub-task | Task> |
458
+ | Scope | <fan-out | self-only> |
459
+ | Git Branch | <branch> |
460
+ | Git Commit | <short SHA> |
461
+ | Jira MCP | Available |
462
+ | Code Review MCP | <gerrit|github|gitlab|none> |
463
+ | TestRail MCP | Available / Not Available |
464
+ | Previous Run | <timestamp or "First run"> |
465
+
466
+ ## Issue Metadata
467
+ | Field | Value |
468
+ |-------|-------|
469
+ | Jira ID | <JIRA_ID> |
470
+ | Issue Type | <type> |
471
+ | Parent | <parent key + summary, if sub-task> |
472
+ | Summary | <summary> |
473
+ | Status | <status> |
474
+ | Assignee | <name> |
475
+ | Priority | <priority> |
476
+ | Created | <date> |
477
+ | Updated | <date> |
478
+ | Labels | <labels> |
479
+ | Components | <components> |
480
+
481
+ ## Artifacts
482
+ | Artifact | URL | Access Method | Accessible | Synthesis File |
483
+ |----------|-----|---------------|------------|----------------|
484
+ | Design Doc | <URL or "Not found"> | <MCP name / WebFetch / N/A> | Yes / No | design-doc-synthesis.md |
485
+ | Test Plan | <URL or "Not found"> | <method> | Yes / No | test-data-synthesis.md |
486
+ | TestRail | <URL or field data> | <method> | Yes / No | test-data-synthesis.md |
487
+
488
+ ## Design Document Synthesis
489
+ (Inline from design-doc-synthesis.md: goals, architecture, API changes, trade-offs.
490
+ If not accessible: "Design doc not accessible — <URL>. Flagged as process gap.")
491
+
492
+ ## Test Plan Summary
493
+ (Inline from test-data-synthesis.md: strategy, coverage goals.
494
+ TestRail summary if available:)
495
+
496
+ | Metric | Count |
497
+ |--------|-------|
498
+ | Total Test Cases | <N> |
499
+ | Passed | <N> |
500
+ | Failed | <N> |
501
+ | Blocked | <N> |
502
+ | Untested | <N> |
503
+
504
+ ## WH Analysis
505
+
506
+ ### What — Goal and Scope
507
+ (What problem, what deliverable, what scope boundary — from description + design doc)
508
+
509
+ ### Why — Motivation and Business Need
510
+ (Why needed, why now, business impact if not done — from description + comments)
511
+
512
+ ### Who — People
513
+ | Role | Names |
514
+ |------|-------|
515
+ | Issue Owner | <name> |
516
+ | Story Assignees | <names> |
517
+ | Code Authors | <names from code review> |
518
+ | Code Reviewers | <names from code review> |
519
+
520
+ ### When — Timeline
521
+ | Milestone | Date |
522
+ |-----------|------|
523
+ | Issue Created | <date> |
524
+ | First Story Resolved | <date> |
525
+ | Last Story Resolved | <date> |
526
+ | First Code Change Merged | <date> |
527
+ | Last Code Change Merged | <date> |
528
+
529
+ ### Where — Codebase Impact
530
+ (Files grouped by module from consolidated change set:)
531
+ ```
532
+ module_a/ (N files)
533
+ - file1.cc (MODIFIED)
534
+ - file2.h (ADDED)
535
+ module_b/ (N files)
536
+ - file3.py (MODIFIED)
537
+ ```
538
+
539
+ ### How — Technical Approach
540
+ (Per-module: 2-3 sentences summarizing what the code changes do. Derived from commit
541
+ subjects and design doc, not just "files were changed".)
542
+
543
+ ## Stories Status
544
+ | # | Story ID | Summary | Type | Classification | Status | Assignee | Code Changes | Sub-Tasks | Tests | Resolved |
545
+ |----|----------|---------|------|----------------|--------|----------|--------------|-----------|-------|----------|
546
+ | 1 | <ID> | <summary> | Story | Code | Done | <name> | 3 | 1 | 5 | Yes |
547
+ | 2 | <ID> | <summary> | Bug | Code | In Progress | <name> | 1 | 0 | 0 | No |
548
+
549
+ **Totals**: <N> stories, <M> resolved, <K> in progress, <J> code-deliverable,
550
+ <L> with code changes, <P> with test cases
551
+
552
+ ### Story Classification Summary
553
+ | Classification | Count | Description |
554
+ |----------------|-------|-------------|
555
+ | Code-deliverable | <N> | Stories/Bugs with expected code changes |
556
+ | Non-code | <N> | Tasks: documentation, design, config, process |
557
+ | Excluded | <N> | Won't Do, Duplicate, moved to other epic |
558
+
559
+ ### Unresolved Stories
560
+ (Each unresolved code-deliverable story: ID, summary, current status, why it matters)
561
+
562
+ ### In Progress Stories
563
+ (Each in-progress code-deliverable story: ID, summary, code change status, what remains)
564
+
565
+ ### Stories Without Code Changes
566
+ (Each code-deliverable story with no code changes. Note: expected for non-code, gap for code)
567
+
568
+ ### Stories Without Test Cases
569
+ (Stories with no TestRail test cases mapped)
570
+ ```
571
+
572
+ ### Per-Story Detail
573
+
574
+ For each story, include under `## Per-Story Detail`:
575
+
576
+ ```markdown
577
+ ### <STORY_ID>: <Summary>
578
+
579
+ #### Story Info
580
+ | Field | Value |
581
+ |-------|-------|
582
+ | Type | Story / Bug / Task |
583
+ | Classification | Code / Non-code / Excluded |
584
+ | Status | <status> |
585
+ | Assignee | <name> |
586
+ | Priority | <priority> |
587
+ | Created | <date> |
588
+ | Updated | <date> |
589
+ | Sub-Tasks | <count> |
590
+
591
+ #### Acceptance Criteria
592
+ 1. <criterion from description>
593
+ 2. <criterion from description>
594
+
595
+ #### Story Learnings
596
+ ```
597
+
598
+ ### Learnings Narrative Per Story
599
+
600
+ For **bug-fix stories** (5 sections):
601
+ 1. **What was the issue** — symptoms, scope, observables, impact. Generalize using patterns rather than raw ticket IDs.
602
+ 2. **RCA** — primary cause, contributing factors. Incorporate code-review insights from `list_change_comments` if relevant.
603
+ 3. **Resolution** — fix type, change ID, branch, merge status, who reviewed. Reference patchset count.
604
+ 4. **Journey** — timeline: triage → investigation → fix → review iterations → merge → verification.
605
+ 5. **Learnings** — technical, operational, process takeaways. Test gaps.
606
+
607
+ For **feature stories** (5 sections):
608
+ 1. **What was the requirement** — goal, user need, scope, acceptance criteria. Cross-reference design doc synthesis.
609
+ 2. **Technical approach** — design decisions, patterns, integration points.
610
+ 3. **Implementation** — key files from `list_change_files`, change scope (insertions/deletions).
611
+ 4. **Journey** — dev timeline, patchset iteration count, review feedback themes, testing.
612
+ 5. **Learnings** — reusable patterns, pitfalls, test coverage observations.
613
+
614
+ **Data sources:**
615
+
616
+ | Section | Primary | Supporting |
617
+ |---------|---------|-----------|
618
+ | What/requirement | `get_issue_description` | Design doc synthesis |
619
+ | RCA/approach | Pinned Jira comments, `get_linked_issues` | `list_change_comments` |
620
+ | Resolution/implementation | `list_change_files`, `get_commit_message` | Jira resolution field |
621
+ | Journey | Jira comments + code-review patchset history | TestRail execution timeline |
622
+ | Learnings | Derived from all above | Reviewer feedback, test gaps |
623
+
624
+ ### Per-Story Detail (continued)
625
+
626
+ ```markdown
627
+ #### Story Code Changes
628
+ | # | Change ID | Subject | Author | Branch | Status | Approval | Files | +Lines | -Lines |
629
+ |----|-----------|---------|--------|--------|--------|----------|-------|--------|--------|
630
+ | 1 | <ID> | <subject> | <name> | <branch> | MERGED | +2 | 5 | 120 | 30 |
631
+
632
+ Files changed:
633
+ - path/to/file (MODIFIED, +10 -5)
634
+ - path/to/new_file (ADDED, +50)
635
+
636
+ Review quality:
637
+ - Reviewers: <names>
638
+ - Unresolved comments: <count>
639
+ - Patchset iterations: <count>
640
+
641
+ #### Story Sub-Task Changes
642
+ (If sub-tasks exist: same code change table, rolled up from sub-tasks)
643
+
644
+ #### Story Test Cases (if TestRail available)
645
+ | Test Case ID | Title | Status | Last Run |
646
+ |-------------|-------|--------|----------|
647
+ | TC-1001 | <title> | Passed | <date> |
648
+ ```
649
+
650
+ ### Consolidated Changes
651
+
652
+ ```markdown
653
+ ## Consolidated Changes
654
+
655
+ ### All Files Changed
656
+ | Module | File | Status | Stories | Insertions | Deletions |
657
+ |--------|------|--------|---------|------------|-----------|
658
+ | module_a | file1.cc | MODIFIED | ENG-111, ENG-222 | 45 | 12 |
659
+
660
+ ### All Code Changes (Chronological)
661
+ | # | Change ID | Subject | Author | Date | Story | Branch | Status | Approval | Link |
662
+ |----|-----------|---------|--------|------|-------|--------|--------|----------|------|
663
+
664
+ ### All Authors and Reviewers
665
+ | Role | Name | Story Count | Change Count |
666
+ |------|------|-------------|-------------|
667
+
668
+ ### Review Quality Summary
669
+ | Metric | Value |
670
+ |--------|-------|
671
+ | Total Code Changes | <N> |
672
+ | MERGED with Approval | <N> |
673
+ | Without Approval | <N> |
674
+ | With Unresolved Comments | <N> |
675
+ | Average Patchset Count | <N> |
676
+
677
+ ## Preliminary Gap Indicators
678
+ | Gap Type | Count | IDs |
679
+ |----------|-------|-----|
680
+ | Unresolved code stories | <N> | <IDs> |
681
+ | In Progress code stories | <N> | <IDs> |
682
+ | Code stories without code changes | <N> | <IDs> |
683
+ | Code changes NOT MERGED | <N> | <change IDs> |
684
+ | Changes without approval | <N> | <change IDs> |
685
+ | Changes with unresolved comments | <N> | <change IDs> |
686
+ | Missing design doc | Yes/No | |
687
+ | Missing test plan | Yes/No | |
688
+ | Stories without test cases | <N> | <IDs> |
689
+ ```
690
+
691
+ ---
692
+
693
+ ## Phase 5: Quality Analysis
694
+
695
+ All three commands use the `draft/` context established in Phase 0.
696
+
697
+ ### 5.1 /draft:deep-review
698
+
699
+ Run per changed module. Module selection follows deep-review's own priority:
700
+ 1. Check `draft/.ai-context.md` for `## Modules` or `## Module Catalog` — match against modules from the consolidated change set.
701
+ 2. If no module catalog: use top-level directories from the consolidated file list.
702
+ 3. Run once per affected module:
703
+
704
+ ```
705
+ draft:deep-review <module-name-or-directory>
706
+ ```
707
+
708
+ **Output**: `draft/deep-review-reports/<module-name>.md` (deep-review manages its own output path).
709
+
710
+ **Reads**: `draft/.ai-context.md`, `draft/product.md`, `draft/tech-stack.md`.
711
+
712
+ Produces per-module: ACID compliance, resilience, observability, configuration assessment with per-finding severity and file:line references.
713
+
714
+ ### 5.2 /draft:bughunt
715
+
716
+ Run scoped to specific file paths from the consolidated change set.
717
+
718
+ **Invocation protocol:** bughunt prompts for scope type when invoked. Pre-answer the prompt:
719
+ 1. Select **"Specific paths"** when bughunt asks for scope.
720
+ 2. Supply the consolidated file list from Phase 3.4 as the target paths.
721
+ 3. If bughunt asks for track context, respond: "No track — running as part of /draft:jira review pipeline".
722
+
723
+ ```
724
+ /draft:bughunt
725
+ → (scope prompt) → "Specific paths"
726
+ → (paths prompt) → <consolidated file list from Phase 3.4>
727
+ ```
728
+
729
+ **Output**: `draft/bughunt-report-latest.md` (bughunt manages its own output path).
730
+
731
+ **Reads**: `draft/.ai-context.md`, `draft/tech-stack.md`, `draft/product.md`, `draft/workflow.md`.
732
+
733
+ Produces: severity-ranked bug list (Critical/High/Medium/Low) with code evidence, data flow traces, and optional regression tests.
734
+
735
+ ### 5.3 /draft:coverage
736
+
737
+ Run with explicit path argument per changed module:
738
+
739
+ ```
740
+ /draft:coverage <module-directory>
741
+ ```
742
+
743
+ Coverage reads `coverage_target` from `draft/workflow.md` (default: **95%** if absent).
744
+
745
+ **Track requirement workaround:** `/draft:coverage` expects an active track and writes to `draft/tracks/<id>/coverage-report.md`. Since `jira review` does not create a track:
746
+ 1. Coverage will look for an active track from `draft/tracks.md` — if none exists, it will warn.
747
+ 2. Capture coverage output directly from the tool's console/response text.
748
+ 3. Record the coverage percentages, gap analysis, and uncovered files in the review context document (Phase 4).
749
+ 4. Reference coverage results by captured output, not by file path.
750
+
751
+ **If no test framework is detected:** coverage will report this. Record "No test framework detected" in the report — this itself is a gap finding.
752
+
753
+ ### 5.4 Partial Completion Handling
754
+
755
+ If any Phase 5 command fails:
756
+ - Record which commands completed and which failed.
757
+ - Continue with remaining commands — do NOT abort the pipeline.
758
+ - In Phase 7, note failed analyses: "draft:coverage — FAILED: no test framework detected" etc.
759
+ - Verdict must account for missing data: if bughunt failed, verdict cannot be QUALIFIED (insufficient evidence).
760
+
761
+ ---
762
+
763
+ ## Phase 6: Test Gap Analysis & Test Suggestions
764
+
765
+ Testing is a **first-class qualification signal**. This phase combines codebase test discovery, coverage analysis, and bughunt findings to identify every gap — then produces actionable, framework-specific test suggestions.
766
+
767
+ ### 6.1 Codebase Test Discovery
768
+
769
+ For each changed **production** file from the consolidated change set (Phase 3.4):
770
+
771
+ 1. **Find companion test files** in the codebase using conventions from `draft/tech-stack.md` and the patterns in Phase 3.4.
772
+ - Example: `src/handler.go` → look for `src/handler_test.go`.
773
+ - Example: `src/utils/parser.ts` → look for `src/utils/parser.test.ts`, `src/utils/parser.spec.ts`, `src/utils/__tests__/parser.test.ts`.
774
+
775
+ 2. **If companion test file exists:** read it. Record:
776
+ - Number of test functions/cases.
777
+ - What behaviors are tested (function names, describe blocks, test names).
778
+ - Whether changed functions/methods have corresponding test cases.
779
+ - Last modified date (via code-review or git log) — stale tests are a signal.
780
+
781
+ 3. **If no companion test file exists:** flag `"NO TEST FILE — <production_file>"`.
782
+
783
+ 4. **Cross-module test files:** some tests live in separate directories (e.g., `integration_tests/`, `e2e/`). Scan for test files that import or reference changed production files.
784
+
785
+ Build a **test inventory** per story:
786
+
787
+ | Production File | Companion Test File | Test Functions | Changed Functions Covered | Gap |
788
+ |----------------|--------------------|--------------:|:-------------------------:|-----|
789
+ | src/handler.go | src/handler_test.go | 8 | 3/5 | 2 uncovered |
790
+ | src/parser.go | — | — | — | No test file |
791
+
792
+ ### 6.2 Test Presence in Code Changes
793
+
794
+ From Phase 3.4 test file classification:
795
+
796
+ | Signal | Meaning |
797
+ |--------|---------|
798
+ | Story ships test files + production files | Developer tested their changes — positive |
799
+ | Story ships only production files, companion tests exist unchanged | Developer modified code but didn't update tests — **stale test risk** |
800
+ | Story ships only production files, no companion tests in codebase | No tests at all — **critical gap** |
801
+ | Story ships only test files | Test-only change (backfill, refactor) — positive signal |
802
+
803
+ Per story, assign a **Test Shipping Status**:
804
+ - **TESTED**: code changes include test files covering the production changes.
805
+ - **PARTIALLY TESTED**: some production files have companion tests (unchanged or in different changes).
806
+ - **UNTESTED**: no test files shipped, no companion tests in codebase.
807
+ - **TEST BACKFILL**: test-only changes (positive).
808
+
809
+ ### 6.3 Acceptance Criteria → Test Mapping
810
+
811
+ Per code-deliverable story:
812
+ 1. Extract acceptance criteria (from Phase 1.4).
813
+ 2. Map to **codebase tests** discovered in 6.1 (test function names that exercise the criterion).
814
+ 3. Map to **TestRail test cases** (from Phase 2.2, if available) — if TestRail unavailable, leave column blank and weight codebase tests + coverage higher.
815
+ 4. Map to **bughunt findings** that exercise the same code path.
816
+ 5. Identify criteria with **no test coverage at all** — these are the highest-priority gaps.
817
+
818
+ **Without TestRail:** AC → test mapping relies entirely on codebase test discovery (6.1) and coverage data (5.3). This is still valid — many enterprise teams have comprehensive unit/integration tests that never appear in TestRail. The TestRail column becomes N/A in all tables.
819
+
820
+ | # | Story | Acceptance Criterion | Codebase Tests | TestRail Cases | Bughunt Overlap | Status |
821
+ |----|-------|---------------------|:--------------:|:--------------:|:---------------:|--------|
822
+ | 1 | ENG-111 | "User can reset password" | 2 tests | TC-1001 | — | Covered |
823
+ | 2 | ENG-111 | "Email sent within 30s" | 0 | — | — | **GAP** |
824
+
825
+ ### 6.4 Code Coverage Gap Identification
826
+
827
+ From draft:coverage (Phase 5.3) and codebase discovery (6.1):
828
+
829
+ 1. **Changed files below coverage target** (from `draft/workflow.md`, default 95%).
830
+ 2. **Newly ADDED files** (status: ADDED) with zero or no test coverage.
831
+ 3. **Critical modules** flagged by deep-review that also have low coverage — highest severity.
832
+ 4. **Production files with no companion test file** at all in the codebase (from 6.1).
833
+ 5. **Changed functions without test coverage** — map specific function/method changes (from code-review diff) to test function inventory.
834
+
835
+ ### 6.5 Regression Tests from Bughunt Findings
836
+
837
+ For **each Critical and High severity finding** from draft:bughunt (Phase 5.2):
838
+
839
+ 1. Identify the vulnerable code path and entry points.
840
+ 2. Determine what input/state triggers the bug.
841
+ 3. Design a regression test that:
842
+ - Reproduces the exact scenario that would trigger the bug.
843
+ - Asserts the correct behavior after the fix.
844
+ - Includes negative cases (malformed input, boundary values, race conditions).
845
+
846
+ This ensures bugs found by bughunt don't ship — and if they're already in code, they get caught on the next change.
847
+
848
+ ### 6.6 Test Suggestions
849
+
850
+ Read `draft/tech-stack.md` for: test framework, assertion library, mocking patterns, test directory conventions.
851
+ Read `draft/workflow.md` for: TDD preferences, coverage targets, test execution commands.
852
+ Read `draft/.ai-context.md` for: existing test patterns, module boundaries, data flows.
853
+
854
+ Generate **framework-specific, copy-pasteable test suggestions** for every identified gap.
855
+
856
+ #### Unit Tests — for uncovered production code
857
+
858
+ For each production file/function without adequate test coverage:
859
+
860
+ ```
861
+ Test: <descriptive_test_function_name>
862
+ Type: Unit
863
+ Priority: Critical / High / Medium
864
+ Story: <STORY_ID>
865
+ Gap: <what's untested — specific function, branch, error path>
866
+ File: <target test file path — companion location>
867
+ Tests: <what behavior/scenario this validates>
868
+ Why: <which gap from 6.1/6.3/6.4 this closes>
869
+
870
+ Sketch:
871
+ ```<language>
872
+ <actual test function using project's framework, assertion library, and conventions>
873
+ <include setup/teardown if needed>
874
+ <test the specific changed function with meaningful assertions>
875
+ ```
876
+ ```
877
+
878
+ **Focus areas** (in priority order):
879
+ 1. Changed functions with zero test coverage.
880
+ 2. Error handling paths — every error return/throw in changed code needs a test.
881
+ 3. Boundary conditions — nil/null, empty, max values, off-by-one.
882
+ 4. Concurrency paths flagged by deep-review (race conditions, deadlocks).
883
+ 5. Input validation — changed code that processes external input.
884
+
885
+ #### Regression Tests — for bughunt findings
886
+
887
+ For each Critical/High bughunt finding (from 6.5):
888
+
889
+ ```
890
+ Test: regression_<bug_description>
891
+ Type: Regression
892
+ Priority: Critical (matches bughunt severity)
893
+ Story: <STORY_ID>
894
+ Bug: <bughunt finding reference>
895
+ File: <target test file path>
896
+ Tests: <reproduces the exact bug scenario>
897
+ Why: Prevents regression of <bughunt finding>
898
+
899
+ Sketch:
900
+ ```<language>
901
+ <test that sets up the vulnerable state>
902
+ <triggers the code path that had the bug>
903
+ <asserts correct behavior — the bug does NOT manifest>
904
+ ```
905
+ ```
906
+
907
+ #### Integration Tests — for cross-module changes
908
+
909
+ When code changes span multiple modules (from Phase 3.4 consolidated change set):
910
+
911
+ ```
912
+ Test: integration_<module_a>_<module_b>_<scenario>
913
+ Type: Integration
914
+ Priority: High
915
+ Stories: <STORY_IDs that touch both modules>
916
+ File: <integration test directory>/test_<scenario>.<ext>
917
+ Tests: <interaction between modules — data flow, API contract, event handling>
918
+ Why: Cross-module changes risk breaking integration points
919
+
920
+ Sketch:
921
+ ```<language>
922
+ <set up both modules with test fixtures>
923
+ <exercise the integration point changed by the issue>
924
+ <assert end-to-end behavior across module boundary>
925
+ ```
926
+ ```
927
+
928
+ **Trigger conditions** for integration test suggestions:
929
+ - Stories whose code changes touch files in 2+ modules.
930
+ - Changes to interface/API boundary files identified in `draft/.ai-context.md`.
931
+ - Data model changes that propagate across modules.
932
+ - Event/message producer-consumer pairs where both sides changed.
933
+
934
+ ### 6.7 Test Adequacy Score
935
+
936
+ Compute a composite score from all discovery and analysis:
937
+
938
+ | Metric | Value | Weight | Score |
939
+ |--------|-------|--------|-------|
940
+ | Stories with test files in code changes | X/Y | 25% | |
941
+ | Production files with companion test files | X/Y | 20% | |
942
+ | Acceptance criteria with test coverage | X/Y | 20% | |
943
+ | Code coverage vs target | X% vs Y% | 15% | |
944
+ | Bughunt Critical/High with regression tests | X/Y | 10% | |
945
+ | New files (ADDED) with test coverage | X/Y | 10% | |
946
+
947
+ **Test Adequacy = weighted sum (0-100%)**
948
+
949
+ | Rating | Range | Meaning |
950
+ |--------|-------|---------|
951
+ | **Strong** | ≥80% | Tests ship with code, high coverage, gaps are minor |
952
+ | **Adequate** | 60-79% | Most code tested, some gaps in new/changed code |
953
+ | **Weak** | 40-59% | Significant test gaps — many stories without tests |
954
+ | **Critical Gap** | <40% | Insufficient testing — blocks qualification |
955
+
956
+ ---
957
+
958
+ ## Phase 7: Report Generation
959
+
960
+ Generate outputs **directly** to `draft/jira-review/<JIRA_ID>/`. Do NOT use `draft:new-track`.
961
+
962
+ ### 7.1 Verdict Logic
963
+
964
+ The verdict criteria are the same regardless of issue type — for single-story scopes (Story/Bug/Sub-task) the "all code stories" criterion collapses to "the single story is resolved" (N=1).
965
+
966
+ | Verdict | Criteria |
967
+ |---------|----------|
968
+ | **QUALIFIED** | All code stories ∈ {Resolved, Done, Closed} + all code changes MERGED with Approval + zero Critical/High bugs + design doc accessible (local hld.md preferred, external fallback) + HLD Approvals table signed for tracks with `criticality ≥ standard` + test plan accessible + zero unresolved review comments on critical changes + coverage at target + Test Adequacy ≥80% (Strong) |
969
+ | **PARTIALLY QUALIFIED** | Minor gaps: Medium bugs only, non-critical artifacts missing, 1-2 stories In Progress with merged changes, some unresolved comments, coverage below target but >70%, Test Adequacy 40-79% (Adequate/Weak) |
970
+ | **NOT QUALIFIED** | Any: unresolved code stories with no changes, code changes not merged, Critical bugs, missing design doc AND test plan, requirements not traced to code, critical module FAIL in deep-review, Phase 5 commands failed, Test Adequacy <40% (Critical Gap) |
971
+
972
+ **If Phase 5 partially failed:** verdict cannot exceed PARTIALLY QUALIFIED due to insufficient evidence.
973
+
974
+ **Non-code Task verdict:** for non-code Task issue types (Phase 0.4 branch), Phase 5–7 do not apply. Report records type as `Non-code Task — qualification N/A` and stops after Phase 2 (artifact collection).
975
+
976
+ ### 7.2 Qualification Report
977
+
978
+ Write `draft/jira-review/<JIRA_ID>/qualification-report.md` (with metadata header):
979
+
980
+ ```markdown
981
+ # Jira Review Report: <JIRA_ID> — <Summary>
982
+
983
+ ## Qualification Verdict
984
+
985
+ | Field | Value |
986
+ |-------|-------|
987
+ | Verdict | QUALIFIED / PARTIALLY QUALIFIED / NOT QUALIFIED |
988
+ | Date | <ISO timestamp> |
989
+ | Issue | <JIRA_ID> — <Summary> |
990
+ | Issue Type | <Epic | Story | Bug | Sub-task | Task> |
991
+ | Pipeline | Jira → Documents → Code Review → deep-review → bughunt → coverage → gap analysis |
992
+ | MCP Servers | Jira (yes), Code Review (<type> yes/no), TestRail (yes/no) |
993
+ | Git State | <branch> @ <short SHA> |
994
+ | Previous Run | <date or "First qualification"> |
995
+
996
+ ### Verdict Criteria Checklist
997
+
998
+ | # | Criterion | Status | Source | Detail |
999
+ |----|-----------|--------|--------|--------|
1000
+ | 1 | All code stories resolved | PASS/FAIL | Jira | <N>/<M> resolved |
1001
+ | 2 | All code changes MERGED | PASS/FAIL | Code Review | <N>/<M> merged |
1002
+ | 3 | Approval on all changes | PASS/FAIL | Code Review | <N> without approval |
1003
+ | 4 | No unresolved review comments | PASS/FAIL | Code Review | <N> unresolved |
1004
+ | 5 | No Critical/High bugs | PASS/FAIL | bughunt | <N> Critical, <M> High |
1005
+ | 6 | Module quality | PASS/FAIL | deep-review | <N> modules FAIL |
1006
+ | 7 | Test coverage at target | PASS/FAIL | coverage | <X>% vs <Y>% target |
1007
+ | 8 | Test adequacy | PASS/FAIL | Phase 6 | <X>% — <Rating> |
1008
+ | 9 | Design doc accessible | PASS/FAIL | Phase 2 | <status> |
1009
+ | 10 | Test plan accessible | PASS/FAIL | Phase 2 | <status> |
1010
+
1011
+ ## Executive Summary
1012
+ (2-3 paragraphs: what the issue aimed to achieve, what was delivered, qualification status
1013
+ and key findings. Reference design doc synthesis where applicable.)
1014
+
1015
+ ## Requirements Traceability Matrix
1016
+ | # | Requirement | Story | Code Changes | Key Files | Deep-Review | Bughunt | Tests | Status |
1017
+ |----|-------------|-------|--------------|-----------|-------------|---------|-------|--------|
1018
+ | 1 | <text> | ENG-111 | 12345, 12346 | file.cc | PASS | Clean | 3 pass | Covered |
1019
+ | 2 | <text> | ENG-222 | — | — | — | — | 0 | Gap |
1020
+
1021
+ Coverage: <X>/<Y> requirements traced to code changes (<Z>%)
1022
+
1023
+ ## WH Summary
1024
+ (What achieved, Why matters, Who contributed, When delivered, Where landed, How implemented
1025
+ — full tables as specified in Phase 4 context document)
1026
+
1027
+ ## Design Document Summary
1028
+ | Field | Value |
1029
+ |-------|-------|
1030
+ | URL | <URL or "Not found"> |
1031
+ | Accessible | Yes / No |
1032
+ | Access Method | <MCP name / WebFetch / N/A> |
1033
+
1034
+ Key Findings: (goals, architecture decisions, API changes, trade-offs — from synthesis)
1035
+
1036
+ ## Quality Assessment (from draft:deep-review)
1037
+ | Module | ACID | Resilience | Observability | Config | Verdict |
1038
+ |--------|------|------------|---------------|--------|---------|
1039
+ | <name> | PASS | PASS | ISSUE | PASS | CONDITIONAL PASS |
1040
+
1041
+ ### Critical Findings
1042
+ (Each Critical/Important issue: file:line, description, recommended fix)
1043
+
1044
+ ## Bug Assessment (from draft:bughunt)
1045
+ | Severity | Count |
1046
+ |----------|-------|
1047
+ | Critical | <N> |
1048
+ | High | <N> |
1049
+ | Medium | <N> |
1050
+ | Low | <N> |
1051
+
1052
+ ### Critical/High Bugs
1053
+ (Each: location file:line, issue, impact, suggested fix, confidence level)
1054
+
1055
+ ### Bug Distribution by Module
1056
+ | Module | Critical | High | Medium | Low |
1057
+ |--------|----------|------|--------|-----|
1058
+
1059
+ ## Code Review Quality
1060
+ | Metric | Value |
1061
+ |--------|-------|
1062
+ | Total Code Changes | <N> |
1063
+ | MERGED with Approval | <N> |
1064
+ | Without Approval | <N> |
1065
+ | With Unresolved Comments | <N> |
1066
+ | Average Patchset Count | <N.N> |
1067
+ | Changes >5 Patchsets | <N> |
1068
+
1069
+ ### Unresolved Review Comments
1070
+ | Change ID | Story | File | Comment | Author |
1071
+ |-----------|-------|------|---------|--------|
1072
+
1073
+ ### Unreviewed Changes
1074
+ | Change ID | Story | Subject | Author | Status |
1075
+ |-----------|-------|---------|--------|--------|
1076
+
1077
+ ## Test Assessment
1078
+
1079
+ ### Test Adequacy Score
1080
+ | Metric | Value | Weight | Score |
1081
+ |--------|-------|--------|-------|
1082
+ | Stories with test files in code changes | X/Y | 25% | |
1083
+ | Production files with companion test files | X/Y | 20% | |
1084
+ | Acceptance criteria with test coverage | X/Y | 20% | |
1085
+ | Code coverage vs target | X% vs Y% | 15% | |
1086
+ | Bughunt Critical/High with regression tests | X/Y | 10% | |
1087
+ | New files (ADDED) with test coverage | X/Y | 10% | |
1088
+ | **Test Adequacy** | | | **X% — <Rating>** |
1089
+
1090
+ ### Test Shipping Status by Story
1091
+ | Story ID | Summary | Code-Change Test Files | Companion Tests | Test Shipping Status |
1092
+ |----------|---------|:----------------------:|:---------------:|---------------------|
1093
+ | <ID> | <summary> | 2 | 5 | TESTED |
1094
+ | <ID> | <summary> | 0 | 0 | UNTESTED |
1095
+
1096
+ ### Code Coverage (from draft:coverage)
1097
+ | Module | Line Coverage | Target | Status |
1098
+ |--------|-------------|--------|--------|
1099
+ | <module> | <X>% | <Y>% | PASS / BELOW TARGET |
1100
+
1101
+ ### Codebase Test Inventory
1102
+ | Production File | Companion Test File | Test Functions | Changed Functions Covered | Gap |
1103
+ |----------------|--------------------|--------------:|:-------------------------:|-----|
1104
+ | src/handler.go | src/handler_test.go | 8 | 3/5 | 2 uncovered |
1105
+ | src/parser.go | — | — | — | No test file |
1106
+
1107
+ ### TestRail Results (if available)
1108
+ | Metric | Count |
1109
+ |--------|-------|
1110
+ | Total Test Cases | <N> |
1111
+ | Passed | <N> |
1112
+ | Failed | <N> |
1113
+ | Blocked | <N> |
1114
+ | Untested | <N> |
1115
+ | Pass Rate | <X>% |
1116
+
1117
+ ## Test Gap Analysis
1118
+
1119
+ ### Untested Acceptance Criteria
1120
+ | # | Story | Acceptance Criterion | Codebase Tests | TestRail Cases | Status |
1121
+ |----|-------|---------------------|:--------------:|:--------------:|--------|
1122
+ | 1 | <ID> | <criterion> | 0 | — | **GAP** |
1123
+
1124
+ ### Production Files Without Tests
1125
+ | # | File | Change Type | Story | Module | Lines Changed |
1126
+ |----|------|-------------|-------|--------|--------------|
1127
+ | 1 | src/parser.go | ADDED | <ID> | module_a | +250 |
1128
+
1129
+ ### Stale Tests (code changed, tests not updated)
1130
+ | # | Production File | Test File | Last Test Update | Production Changed In |
1131
+ |----|----------------|-----------|------------------|----------------------|
1132
+ | 1 | src/handler.go | src/handler_test.go | 6 months ago | Change 12345 |
1133
+
1134
+ ## Suggested Tests
1135
+
1136
+ ### Unit Tests
1137
+ | # | Story | Test Name | Priority | Target File | Gap Closed |
1138
+ |----|-------|-----------|----------|-------------|------------|
1139
+ | 1 | <ID> | <descriptive_name> | Critical | <test_file_path> | <which gap> |
1140
+
1141
+ (Each with framework-specific code sketch below the table)
1142
+
1143
+ ### Regression Tests (from bughunt findings)
1144
+ | # | Bughunt Finding | Severity | Story | Test Name | Target File |
1145
+ |----|----------------|----------|-------|-----------|-------------|
1146
+ | 1 | <finding ref> | Critical | <ID> | regression_<desc> | <test_file_path> |
1147
+
1148
+ (Each with code sketch that reproduces the vulnerable scenario and asserts correct behavior)
1149
+
1150
+ ### Integration Tests
1151
+ | # | Stories | Modules | Test Name | Target File |
1152
+ |----|---------|---------|-----------|-------------|
1153
+ | 1 | <IDs> | mod_a ↔ mod_b | integration_<scenario> | <test_file_path> |
1154
+
1155
+ (Each with code sketch testing the cross-module interaction)
1156
+
1157
+ ### Test Suggestion Summary
1158
+ | Type | Count | Critical | High | Medium |
1159
+ |------|------:|:--------:|:----:|:------:|
1160
+ | Unit | <N> | <N> | <N> | <N> |
1161
+ | Regression | <N> | <N> | <N> | <N> |
1162
+ | Integration | <N> | <N> | <N> | <N> |
1163
+ | **Total** | **<N>** | **<N>** | **<N>** | **<N>** |
1164
+
1165
+ ## Gap Analysis
1166
+
1167
+ ### Implementation Gaps
1168
+ | # | Gap | Story | Severity | Detail |
1169
+ |----|-----|-------|----------|--------|
1170
+ | 1 | Requirement not traced to code | <ID> | High | <detail> |
1171
+ | 2 | Code story without code changes | <ID> | High | <detail> |
1172
+ | 3 | Code change not MERGED | <change> | Critical | <detail> |
1173
+
1174
+ ### Quality Gaps
1175
+ | # | Source | Severity | Finding | Location |
1176
+ |----|--------|----------|---------|----------|
1177
+
1178
+ ### Process Gaps
1179
+ | # | Gap | Detail |
1180
+ |----|-----|--------|
1181
+ | 1 | Unresolved stories | <count>: <IDs> |
1182
+ | 2 | In Progress stories | <count>: <IDs> |
1183
+ | 3 | Missing design doc | <status> |
1184
+ | 4 | Missing test plan | <status> |
1185
+ | 5 | Unreviewed changes | <count>: <change IDs> |
1186
+ | 6 | Unresolved review comments | <count>: <change IDs> |
1187
+ | 7 | Stories without tests | <count>: <IDs> |
1188
+ | 8 | Failed quality analyses | <which Phase 5 commands failed> |
1189
+
1190
+ ## Artifacts
1191
+ | Artifact | Location | Status |
1192
+ |----------|----------|--------|
1193
+ | Design Doc | <URL> | Accessible / Not found |
1194
+ | Test Plan | <URL> | Accessible / Not found |
1195
+ | Design Doc Synthesis | draft/jira-review/<JIRA_ID>/design-doc-synthesis.md | Generated / N/A |
1196
+ | Test Data Synthesis | draft/jira-review/<JIRA_ID>/test-data-synthesis.md | Generated / N/A |
1197
+ | Context Document | draft/jira-review/<JIRA_ID>/context.md | Generated |
1198
+ | Deep Review Reports | draft/deep-review-reports/ | Generated / Failed |
1199
+ | Bughunt Report | draft/bughunt-report-latest.md | Generated / Failed |
1200
+ | Coverage Report | Per module | Generated / Failed / No framework |
1201
+ | Draft Architecture | draft/architecture.md | Pre-existing / Generated by init |
1202
+
1203
+ ## Recommendations
1204
+ ### Must-Fix (blocks qualification)
1205
+ 1. <item with file references and change IDs>
1206
+
1207
+ ### Should-Fix (improves qualification)
1208
+ 1. <item>
1209
+
1210
+ ### Test Improvements
1211
+ 1. <suggested test from Phase 6>
1212
+
1213
+ ### Nice-to-Have
1214
+ 1. <item>
1215
+
1216
+ ## All Code Changes
1217
+ | # | Change ID | Subject | Author | Story | Branch | Status | Approval | Link |
1218
+ |----|-----------|---------|--------|-------|--------|--------|----------|------|
1219
+
1220
+ Total: <N> changes across <M> stories
1221
+
1222
+ ## All Files Changed
1223
+ (Deduplicated, grouped by module:)
1224
+ ```
1225
+ module_a/ (N files)
1226
+ - file1.cc (MODIFIED, stories: ENG-111, ENG-222)
1227
+ - file2.h (ADDED, stories: ENG-111)
1228
+ ```
1229
+ Total: <N> files across <M> modules
1230
+ ```
1231
+
1232
+ ### 7.3 Remediation Plan
1233
+
1234
+ If verdict ≠ QUALIFIED, write `draft/jira-review/<JIRA_ID>/remediation-plan.md` (with metadata header):
1235
+
1236
+ ```markdown
1237
+ # Remediation Plan: <JIRA_ID> Qualification Gaps
1238
+
1239
+ **Issue**: <JIRA_ID> — <Summary>
1240
+ **Issue Type**: <Epic | Story | Bug | Sub-task>
1241
+ **Verdict**: PARTIALLY QUALIFIED / NOT QUALIFIED
1242
+ **Date**: <ISO timestamp>
1243
+
1244
+ ## Phase 1: Critical Quality and Bug Issues
1245
+ - [ ] Fix <Critical bug description> in <file:line> (source: bughunt)
1246
+ - [ ] Fix <ACID violation> in <module> (source: deep-review)
1247
+
1248
+ ## Phase 2: Unresolved Stories and Unmerged Changes
1249
+ - [ ] Resolve <STORY_ID> — <summary> (status: <current>)
1250
+ - [ ] Merge code change <change_id> for <STORY_ID> (status: NEW)
1251
+ - [ ] Address <N> unresolved comments on change <change_id>
1252
+
1253
+ ## Phase 3: Missing Artifacts and Process Gaps
1254
+ - [ ] Create or link design document
1255
+ - [ ] Create or link test plan
1256
+ - [ ] Complete Approval for changes: <change IDs>
1257
+
1258
+ ## Phase 4: Test Coverage Gaps
1259
+ - [ ] Write test for: <untested acceptance criterion> (story: <ID>)
1260
+ - [ ] Add unit tests for <file> — currently at <X>% (target: <Y>%)
1261
+ - [ ] Create TestRail test cases for stories: <IDs without tests>
1262
+ ```
1263
+
1264
+ ### 7.4 Delta from Previous Run
1265
+
1266
+ If Phase 0.5 found a previous `qualification-report.md`, include at the end of the new report:
1267
+
1268
+ ```markdown
1269
+ ## Delta from Previous Qualification
1270
+
1271
+ | Metric | Previous (<date>) | Current | Change |
1272
+ |--------|-------------------|---------|--------|
1273
+ | Verdict | <old> | <new> | Improved / Unchanged / Regressed |
1274
+ | Unresolved Stories | <N> | <M> | <diff> |
1275
+ | Unmerged Changes | <N> | <M> | <diff> |
1276
+ | Critical/High Bugs | <N> | <M> | <diff> |
1277
+ | Test Coverage | <X>% | <Y>% | <diff> |
1278
+ | Process Gaps | <N> | <M> | <diff> |
1279
+ ```
1280
+
1281
+ ---
1282
+
1283
+ ## Error Handling
1284
+
1285
+ | Condition | Action |
1286
+ |-----------|--------|
1287
+ | Jira MCP unavailable | **STOP** — cannot proceed |
1288
+ | Code Review MCP unavailable | **DEGRADE** — skip Phase 3 code review checks, cap verdict at PARTIALLY QUALIFIED |
1289
+ | TestRail MCP unavailable | **DEGRADE** — skip TestRail, flag as gap |
1290
+ | Document URL inaccessible | **DEGRADE** — record URL, flag as process gap |
1291
+ | No stories found (Epic, all fallbacks) | Flag, produce minimal report |
1292
+ | Story not RESOLVED | Include in gaps, still collect code changes |
1293
+ | Story In Progress | Flag separately from Unresolved, collect available changes |
1294
+ | Code change not found | Flag per-story, continue with other changes |
1295
+ | No changes for code story | Flag "implementation gap" |
1296
+ | draft:init fails | **STOP** — context required for quality analysis |
1297
+ | draft/ exists but stale | Warn, proceed (note in report) |
1298
+ | draft:deep-review fails | **DEGRADE** — record failure, continue pipeline, cap verdict at PARTIALLY QUALIFIED |
1299
+ | draft:bughunt fails | **DEGRADE** — record failure, continue pipeline, cap verdict at PARTIALLY QUALIFIED |
1300
+ | draft:coverage fails / no framework | **DEGRADE** — record, flag "no coverage data" as gap |
1301
+ | 50+ stories (Epic) | Process in batches of 25, warn about duration |
1302
+ | Jira MCP rate limit / timeout | Back off with exponential delay, retry up to 3 times per call |
1303
+ | Numeric-only input | Prompt for project prefix — do NOT assume |
1304
+ | Issue type is Sub-task | Fetch parent for context, qualify sub-task scope, note parent in report |
1305
+ | Issue type is non-code Task | Skip Phase 3–6, produce minimal report explaining qualification N/A |
1306
+
1307
+ ---
1308
+
1309
+ ## Output Files Summary
1310
+
1311
+ All generated artifacts and their locations:
1312
+
1313
+ | File | Path | Phase |
1314
+ |------|------|-------|
1315
+ | Design Doc Synthesis | `draft/jira-review/<JIRA_ID>/design-doc-synthesis.md` | 2 |
1316
+ | Test Data Synthesis | `draft/jira-review/<JIRA_ID>/test-data-synthesis.md` | 2 |
1317
+ | Context Document | `draft/jira-review/<JIRA_ID>/context.md` | 4 |
1318
+ | Qualification Report | `draft/jira-review/<JIRA_ID>/qualification-report.md` | 7 |
1319
+ | Remediation Plan | `draft/jira-review/<JIRA_ID>/remediation-plan.md` | 7 (if gaps) |
1320
+ | Deep Review Reports | `draft/deep-review-reports/<module>.md` | 5 (managed by deep-review) |
1321
+ | Bughunt Report | `draft/bughunt-report-latest.md` | 5 (managed by bughunt) |
1322
+ | Coverage Reports | Per coverage command output | 5 (managed by coverage) |