@harness-engineering/cli 1.6.2 → 1.8.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 (180) hide show
  1. package/dist/agents/personas/documentation-maintainer.yaml +3 -1
  2. package/dist/agents/personas/performance-guardian.yaml +23 -0
  3. package/dist/agents/personas/planner.yaml +27 -0
  4. package/dist/agents/personas/verifier.yaml +30 -0
  5. package/dist/agents/skills/claude-code/align-documentation/SKILL.md +13 -0
  6. package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +25 -1
  7. package/dist/agents/skills/claude-code/cleanup-dead-code/skill.yaml +5 -2
  8. package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +12 -0
  9. package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +67 -1
  10. package/dist/agents/skills/claude-code/enforce-architecture/skill.yaml +5 -2
  11. package/dist/agents/skills/claude-code/harness-accessibility/SKILL.md +281 -0
  12. package/dist/agents/skills/claude-code/harness-accessibility/skill.yaml +51 -0
  13. package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +119 -72
  14. package/dist/agents/skills/claude-code/harness-autopilot/skill.yaml +4 -2
  15. package/dist/agents/skills/claude-code/harness-brainstorming/SKILL.md +76 -4
  16. package/dist/agents/skills/claude-code/harness-brainstorming/skill.yaml +2 -0
  17. package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +487 -234
  18. package/dist/agents/skills/claude-code/harness-code-review/skill.yaml +15 -2
  19. package/dist/agents/skills/claude-code/harness-codebase-cleanup/SKILL.md +226 -0
  20. package/dist/agents/skills/claude-code/harness-codebase-cleanup/skill.yaml +64 -0
  21. package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +35 -6
  22. package/dist/agents/skills/claude-code/harness-dependency-health/skill.yaml +1 -1
  23. package/dist/agents/skills/claude-code/harness-design/SKILL.md +265 -0
  24. package/dist/agents/skills/claude-code/harness-design/skill.yaml +53 -0
  25. package/dist/agents/skills/claude-code/harness-design-mobile/SKILL.md +336 -0
  26. package/dist/agents/skills/claude-code/harness-design-mobile/skill.yaml +49 -0
  27. package/dist/agents/skills/claude-code/harness-design-system/SKILL.md +282 -0
  28. package/dist/agents/skills/claude-code/harness-design-system/skill.yaml +50 -0
  29. package/dist/agents/skills/claude-code/harness-design-web/SKILL.md +360 -0
  30. package/dist/agents/skills/claude-code/harness-design-web/skill.yaml +52 -0
  31. package/dist/agents/skills/claude-code/harness-docs-pipeline/SKILL.md +460 -0
  32. package/dist/agents/skills/claude-code/harness-docs-pipeline/skill.yaml +69 -0
  33. package/dist/agents/skills/claude-code/harness-execution/SKILL.md +73 -8
  34. package/dist/agents/skills/claude-code/harness-execution/skill.yaml +1 -0
  35. package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +32 -6
  36. package/dist/agents/skills/claude-code/harness-hotspot-detector/skill.yaml +1 -1
  37. package/dist/agents/skills/claude-code/harness-i18n/SKILL.md +484 -0
  38. package/dist/agents/skills/claude-code/harness-i18n/skill.yaml +54 -0
  39. package/dist/agents/skills/claude-code/harness-i18n-process/SKILL.md +388 -0
  40. package/dist/agents/skills/claude-code/harness-i18n-process/skill.yaml +43 -0
  41. package/dist/agents/skills/claude-code/harness-i18n-workflow/SKILL.md +512 -0
  42. package/dist/agents/skills/claude-code/harness-i18n-workflow/skill.yaml +53 -0
  43. package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +51 -6
  44. package/dist/agents/skills/claude-code/harness-integrity/SKILL.md +35 -1
  45. package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +46 -5
  46. package/dist/agents/skills/claude-code/harness-knowledge-mapper/skill.yaml +1 -1
  47. package/dist/agents/skills/claude-code/harness-onboarding/SKILL.md +19 -1
  48. package/dist/agents/skills/claude-code/harness-perf/SKILL.md +37 -8
  49. package/dist/agents/skills/claude-code/harness-perf/skill.yaml +3 -0
  50. package/dist/agents/skills/claude-code/harness-perf-tdd/SKILL.md +17 -4
  51. package/dist/agents/skills/claude-code/harness-planning/SKILL.md +57 -3
  52. package/dist/agents/skills/claude-code/harness-planning/skill.yaml +2 -0
  53. package/dist/agents/skills/claude-code/harness-release-readiness/SKILL.md +29 -9
  54. package/dist/agents/skills/claude-code/harness-roadmap/SKILL.md +562 -0
  55. package/dist/agents/skills/claude-code/harness-roadmap/skill.yaml +43 -0
  56. package/dist/agents/skills/claude-code/harness-security-review/SKILL.md +36 -2
  57. package/dist/agents/skills/claude-code/harness-security-review/skill.yaml +8 -6
  58. package/dist/agents/skills/claude-code/harness-security-scan/skill.yaml +1 -1
  59. package/dist/agents/skills/claude-code/harness-soundness-review/SKILL.md +1267 -0
  60. package/dist/agents/skills/claude-code/harness-soundness-review/skill.yaml +48 -0
  61. package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +35 -6
  62. package/dist/agents/skills/claude-code/harness-verification/SKILL.md +66 -0
  63. package/dist/agents/skills/claude-code/harness-verification/skill.yaml +1 -0
  64. package/dist/agents/skills/claude-code/harness-verify/SKILL.md +37 -0
  65. package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +15 -1
  66. package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +12 -0
  67. package/dist/agents/skills/gemini-cli/harness-accessibility/SKILL.md +281 -0
  68. package/dist/agents/skills/gemini-cli/harness-accessibility/skill.yaml +51 -0
  69. package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +119 -72
  70. package/dist/agents/skills/gemini-cli/harness-autopilot/skill.yaml +4 -2
  71. package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/SKILL.md +226 -0
  72. package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/skill.yaml +64 -0
  73. package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +35 -6
  74. package/dist/agents/skills/gemini-cli/harness-dependency-health/skill.yaml +1 -1
  75. package/dist/agents/skills/gemini-cli/harness-design/SKILL.md +265 -0
  76. package/dist/agents/skills/gemini-cli/harness-design/skill.yaml +53 -0
  77. package/dist/agents/skills/gemini-cli/harness-design-mobile/SKILL.md +336 -0
  78. package/dist/agents/skills/gemini-cli/harness-design-mobile/skill.yaml +49 -0
  79. package/dist/agents/skills/gemini-cli/harness-design-system/SKILL.md +282 -0
  80. package/dist/agents/skills/gemini-cli/harness-design-system/skill.yaml +50 -0
  81. package/dist/agents/skills/gemini-cli/harness-design-web/SKILL.md +360 -0
  82. package/dist/agents/skills/gemini-cli/harness-design-web/skill.yaml +52 -0
  83. package/dist/agents/skills/gemini-cli/harness-docs-pipeline/SKILL.md +460 -0
  84. package/dist/agents/skills/gemini-cli/harness-docs-pipeline/skill.yaml +69 -0
  85. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +32 -6
  86. package/dist/agents/skills/gemini-cli/harness-hotspot-detector/skill.yaml +1 -1
  87. package/dist/agents/skills/gemini-cli/harness-i18n/SKILL.md +484 -0
  88. package/dist/agents/skills/gemini-cli/harness-i18n/skill.yaml +54 -0
  89. package/dist/agents/skills/gemini-cli/harness-i18n-process/SKILL.md +388 -0
  90. package/dist/agents/skills/gemini-cli/harness-i18n-process/skill.yaml +43 -0
  91. package/dist/agents/skills/gemini-cli/harness-i18n-workflow/SKILL.md +512 -0
  92. package/dist/agents/skills/gemini-cli/harness-i18n-workflow/skill.yaml +53 -0
  93. package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +51 -6
  94. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +46 -5
  95. package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/skill.yaml +1 -1
  96. package/dist/agents/skills/gemini-cli/harness-perf/SKILL.md +37 -8
  97. package/dist/agents/skills/gemini-cli/harness-perf/skill.yaml +3 -0
  98. package/dist/agents/skills/gemini-cli/harness-perf-tdd/SKILL.md +17 -4
  99. package/dist/agents/skills/gemini-cli/harness-release-readiness/SKILL.md +29 -9
  100. package/dist/agents/skills/gemini-cli/harness-roadmap/SKILL.md +562 -0
  101. package/dist/agents/skills/gemini-cli/harness-roadmap/skill.yaml +43 -0
  102. package/dist/agents/skills/gemini-cli/harness-security-review/skill.yaml +8 -6
  103. package/dist/agents/skills/gemini-cli/harness-security-scan/skill.yaml +1 -1
  104. package/dist/agents/skills/gemini-cli/harness-soundness-review/SKILL.md +1267 -0
  105. package/dist/agents/skills/gemini-cli/harness-soundness-review/skill.yaml +48 -0
  106. package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +35 -6
  107. package/dist/agents/skills/node_modules/.bin/vitest +2 -2
  108. package/dist/agents/skills/shared/design-knowledge/anti-patterns/color.yaml +106 -0
  109. package/dist/agents/skills/shared/design-knowledge/anti-patterns/layout.yaml +109 -0
  110. package/dist/agents/skills/shared/design-knowledge/anti-patterns/motion.yaml +109 -0
  111. package/dist/agents/skills/shared/design-knowledge/anti-patterns/typography.yaml +112 -0
  112. package/dist/agents/skills/shared/design-knowledge/industries/creative.yaml +80 -0
  113. package/dist/agents/skills/shared/design-knowledge/industries/ecommerce.yaml +80 -0
  114. package/dist/agents/skills/shared/design-knowledge/industries/emerging-tech.yaml +83 -0
  115. package/dist/agents/skills/shared/design-knowledge/industries/fintech.yaml +80 -0
  116. package/dist/agents/skills/shared/design-knowledge/industries/healthcare.yaml +80 -0
  117. package/dist/agents/skills/shared/design-knowledge/industries/lifestyle.yaml +80 -0
  118. package/dist/agents/skills/shared/design-knowledge/industries/saas.yaml +80 -0
  119. package/dist/agents/skills/shared/design-knowledge/industries/services.yaml +80 -0
  120. package/dist/agents/skills/shared/design-knowledge/palettes/curated.yaml +234 -0
  121. package/dist/agents/skills/shared/design-knowledge/platform-rules/android.yaml +125 -0
  122. package/dist/agents/skills/shared/design-knowledge/platform-rules/flutter.yaml +144 -0
  123. package/dist/agents/skills/shared/design-knowledge/platform-rules/ios.yaml +106 -0
  124. package/dist/agents/skills/shared/design-knowledge/platform-rules/web.yaml +102 -0
  125. package/dist/agents/skills/shared/design-knowledge/typography/pairings.yaml +274 -0
  126. package/dist/agents/skills/shared/i18n-knowledge/accessibility/intersection.yaml +142 -0
  127. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/encoding.yaml +67 -0
  128. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/formatting.yaml +106 -0
  129. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/layout.yaml +80 -0
  130. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/pluralization.yaml +80 -0
  131. package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/string-handling.yaml +106 -0
  132. package/dist/agents/skills/shared/i18n-knowledge/frameworks/android-resources.yaml +47 -0
  133. package/dist/agents/skills/shared/i18n-knowledge/frameworks/apple-strings.yaml +47 -0
  134. package/dist/agents/skills/shared/i18n-knowledge/frameworks/backend-patterns.yaml +50 -0
  135. package/dist/agents/skills/shared/i18n-knowledge/frameworks/flutter-intl.yaml +47 -0
  136. package/dist/agents/skills/shared/i18n-knowledge/frameworks/i18next.yaml +47 -0
  137. package/dist/agents/skills/shared/i18n-knowledge/frameworks/react-intl.yaml +47 -0
  138. package/dist/agents/skills/shared/i18n-knowledge/frameworks/vue-i18n.yaml +47 -0
  139. package/dist/agents/skills/shared/i18n-knowledge/industries/ecommerce.yaml +66 -0
  140. package/dist/agents/skills/shared/i18n-knowledge/industries/fintech.yaml +66 -0
  141. package/dist/agents/skills/shared/i18n-knowledge/industries/gaming.yaml +69 -0
  142. package/dist/agents/skills/shared/i18n-knowledge/industries/healthcare.yaml +66 -0
  143. package/dist/agents/skills/shared/i18n-knowledge/industries/legal.yaml +66 -0
  144. package/dist/agents/skills/shared/i18n-knowledge/locales/ar.yaml +41 -0
  145. package/dist/agents/skills/shared/i18n-knowledge/locales/de.yaml +35 -0
  146. package/dist/agents/skills/shared/i18n-knowledge/locales/en.yaml +32 -0
  147. package/dist/agents/skills/shared/i18n-knowledge/locales/es.yaml +35 -0
  148. package/dist/agents/skills/shared/i18n-knowledge/locales/fi.yaml +35 -0
  149. package/dist/agents/skills/shared/i18n-knowledge/locales/fr.yaml +35 -0
  150. package/dist/agents/skills/shared/i18n-knowledge/locales/he.yaml +41 -0
  151. package/dist/agents/skills/shared/i18n-knowledge/locales/hi.yaml +35 -0
  152. package/dist/agents/skills/shared/i18n-knowledge/locales/it.yaml +32 -0
  153. package/dist/agents/skills/shared/i18n-knowledge/locales/ja.yaml +38 -0
  154. package/dist/agents/skills/shared/i18n-knowledge/locales/ko.yaml +38 -0
  155. package/dist/agents/skills/shared/i18n-knowledge/locales/nl.yaml +32 -0
  156. package/dist/agents/skills/shared/i18n-knowledge/locales/pl.yaml +35 -0
  157. package/dist/agents/skills/shared/i18n-knowledge/locales/pt.yaml +32 -0
  158. package/dist/agents/skills/shared/i18n-knowledge/locales/ru.yaml +35 -0
  159. package/dist/agents/skills/shared/i18n-knowledge/locales/sv.yaml +32 -0
  160. package/dist/agents/skills/shared/i18n-knowledge/locales/th.yaml +35 -0
  161. package/dist/agents/skills/shared/i18n-knowledge/locales/tr.yaml +35 -0
  162. package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hans.yaml +38 -0
  163. package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hant.yaml +35 -0
  164. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/i18next-mcp.yaml +56 -0
  165. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lingo-dev.yaml +56 -0
  166. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lokalise.yaml +60 -0
  167. package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/tolgee.yaml +60 -0
  168. package/dist/agents/skills/shared/i18n-knowledge/testing/locale-testing.yaml +107 -0
  169. package/dist/agents/skills/shared/i18n-knowledge/testing/pseudo-localization.yaml +86 -0
  170. package/dist/bin/harness.js +64 -4
  171. package/dist/{chunk-UDWGSL3T.js → chunk-3JWCBVUZ.js} +3 -3
  172. package/dist/{chunk-IUFFBBYV.js → chunk-LNI4T7R6.js} +179 -61
  173. package/dist/{chunk-USEYPS7F.js → chunk-SJECMKSS.js} +2250 -40
  174. package/dist/{dist-4MYPT3OE.js → dist-BDO5GFEM.js} +295 -14
  175. package/dist/{dist-RBZXXJHG.js → dist-NT3GXHQZ.js} +95 -1
  176. package/dist/index.d.ts +266 -7
  177. package/dist/index.js +7 -3
  178. package/dist/validate-cross-check-2OPGCGGU.js +7 -0
  179. package/package.json +7 -7
  180. package/dist/validate-cross-check-CPEPNLOD.js +0 -7
@@ -0,0 +1,1267 @@
1
+ # Harness Soundness Review
2
+
3
+ > Deep soundness analysis of specs and plans. Auto-fixes inferrable issues, surfaces design decisions to you. Runs automatically before sign-off — no extra commands needed.
4
+
5
+ ## When to Use
6
+
7
+ - Automatically invoked by harness-brainstorming before spec sign-off (`--mode spec`)
8
+ - Automatically invoked by harness-planning before plan sign-off (`--mode plan`)
9
+ - Manually invoked to review a spec or plan on demand
10
+ - NOT for reviewing implementation code (use harness-code-review)
11
+ - NOT as a replacement for mechanical validation (harness validate, check-deps remain as-is)
12
+ - NOT in CI — this is a design-time skill
13
+
14
+ ## Arguments
15
+
16
+ - **`--mode spec`** — Run spec-mode checks (S1-S7) against a draft spec. Invoked by harness-brainstorming.
17
+ - **`--mode plan`** — Run plan-mode checks (P1-P7) against a draft plan. Invoked by harness-planning.
18
+
19
+ ## Process
20
+
21
+ ### Iron Law
22
+
23
+ **No spec or plan may be signed off without a converged soundness review. Inferrable fixes are applied silently. Design decisions are always surfaced to the user.**
24
+
25
+ ---
26
+
27
+ ### Finding Schema
28
+
29
+ Every finding produced by a check conforms to this structure:
30
+
31
+ ```json
32
+ {
33
+ "id": "string — unique identifier for this finding",
34
+ "check": "string — check ID, e.g. S1, P3",
35
+ "title": "string — one-line summary",
36
+ "detail": "string — full explanation with evidence",
37
+ "severity": "error | warning — errors block sign-off, warnings are advisory",
38
+ "autoFixable": "boolean — whether this can be fixed without user input",
39
+ "suggestedFix": "string | undefined — what the auto-fix would do, or suggestion for user",
40
+ "evidence": ["string[] — references to spec/plan sections, codebase files"]
41
+ }
42
+ ```
43
+
44
+ ---
45
+
46
+ ### Phase 1: CHECK — Run All Checks for Current Mode
47
+
48
+ Execute all checks for the active mode. Classify each finding as `autoFixable: true` or `autoFixable: false`. Record the total issue count.
49
+
50
+ #### Graph Detection and Fallback
51
+
52
+ Before running checks, determine graph availability:
53
+
54
+ 1. Check whether `.harness/graph/` exists in the project root.
55
+ 2. If the directory exists, the following MCP tools are available for enhanced analysis during checks S3, S5, P1, P3, and P4:
56
+ - `query_graph` — traverse module and dependency nodes to verify referenced patterns exist and check architectural compatibility
57
+ - `find_context_for` — search the graph for related design decisions and assumptions from other specs
58
+ - `get_relationships` — get inbound/outbound relationships for a node to verify dependency direction and layer compliance
59
+ - `get_impact` — analyze downstream impact of file changes to verify dependency completeness and detect indirect conflicts
60
+ 3. If the directory does not exist, use the "Without graph" path for every check. Do not block, warn, or degrade the review — all checks produce useful results from document analysis and codebase reads alone.
61
+
62
+ The per-check procedures below include "Without graph" and "With graph" variants. Use the variant matching the detection result from step 1.
63
+
64
+ #### Spec Mode Checks (`--mode spec`)
65
+
66
+ | # | Check | What it detects | Auto-fixable? |
67
+ | --- | -------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
68
+ | S1 | Internal coherence | Contradictions between decisions, technical design, and success criteria | No — surface to user |
69
+ | S2 | Goal-criteria traceability | Goals without success criteria; orphan criteria not tied to any goal | Yes — add missing links, flag orphans |
70
+ | S3 | Unstated assumptions | Implicit assumptions in the design not called out (e.g., single-tenant, always-online) | Partially — infer and add obvious ones, surface ambiguous |
71
+ | S4 | Requirement completeness | Missing error cases, edge cases, failure modes; apply EARS patterns for unwanted-behavior gaps | Partially — add obvious error cases, surface design-dependent |
72
+ | S5 | Feasibility red flags | Design depends on nonexistent codebase capabilities or incompatible patterns | No — surface to user with evidence |
73
+ | S6 | YAGNI re-scan | Speculative features that crept in during conversation | No — surface to user (removing features is a design decision) |
74
+ | S7 | Testability | Vague success criteria that are not observable or measurable ("should be fast") | Yes — add thresholds/specificity where inferrable |
75
+
76
+ ##### S1 Internal Coherence
77
+
78
+ **What to analyze:** Decisions table, Technical Design section, Success Criteria section, Non-goals section.
79
+
80
+ **How to detect:**
81
+
82
+ 1. For each decision in the Decisions table, verify it is consistent with the Technical Design. A decision that says "use approach A" while the Technical Design describes approach B is a contradiction.
83
+ 2. For each success criterion, verify it does not contradict a decision or a non-goal. A criterion that requires behavior explicitly excluded by a non-goal is a contradiction.
84
+ 3. For each non-goal, verify no part of the Technical Design implements it. A non-goal with a corresponding implementation section is a contradiction.
85
+ 4. Flag any pair where one section asserts X and another section asserts not-X or a conflicting approach.
86
+
87
+ **Finding classification:** Always `severity: "error"`, always `autoFixable: false`. Contradictions are design decisions — the user must resolve which side is correct.
88
+
89
+ **Example finding:**
90
+
91
+ ```json
92
+ {
93
+ "id": "S1-001",
94
+ "check": "S1",
95
+ "title": "Decision contradicts Technical Design",
96
+ "detail": "Decision D3 says 'use SQLite for local storage' but Technical Design section 'Data Layer' describes a PostgreSQL schema with migrations. These are incompatible storage approaches.",
97
+ "severity": "error",
98
+ "autoFixable": false,
99
+ "suggestedFix": "Align the Technical Design with the decision (use SQLite) or update the decision to reflect the PostgreSQL approach.",
100
+ "evidence": [
101
+ "Decisions table, row D3: 'Use SQLite for local storage'",
102
+ "Technical Design > Data Layer: 'PostgreSQL schema with up/down migrations'"
103
+ ]
104
+ }
105
+ ```
106
+
107
+ ##### S2 Goal-Criteria Traceability
108
+
109
+ **What to analyze:** Overview section (goals), Success Criteria section.
110
+
111
+ **How to detect:**
112
+
113
+ 1. Extract the stated goals from the Overview section. Goals are typically phrased as desired outcomes or capabilities the system should have after implementation.
114
+ 2. For each goal, check that at least one success criterion covers it. A goal without a corresponding criterion is a **gap** — there is no way to verify the goal was achieved.
115
+ 3. For each success criterion, check that it traces back to a stated goal or an explicit design decision. A criterion with no corresponding goal is an **orphan** — it may be testing something that was never requested.
116
+ 4. Flag gaps (goals without criteria) and orphans (criteria without goals) separately, as they have different fix strategies.
117
+
118
+ **Finding classification:**
119
+
120
+ - Missing traceability links (goals without criteria): `severity: "warning"`, `autoFixable: true`. The fix is to add a new success criterion that covers the uncovered goal, derived from the Technical Design context.
121
+ - Orphan criteria (criteria without goals): `severity: "warning"`, `autoFixable: false`. Removing or reassigning criteria is a design decision — the criterion may be intentional prerequisite work.
122
+
123
+ **Example findings:**
124
+
125
+ ```json
126
+ {
127
+ "id": "S2-001",
128
+ "check": "S2",
129
+ "title": "Goal has no success criterion",
130
+ "detail": "Overview goal 'Support offline mode' has no corresponding success criterion. There is no way to verify this goal was achieved.",
131
+ "severity": "warning",
132
+ "autoFixable": true,
133
+ "suggestedFix": "Add criterion: 'The application functions without network connectivity for all read operations, returning cached data when available.'",
134
+ "evidence": ["Overview: 'Support offline mode'", "Success Criteria: no match found"]
135
+ }
136
+ ```
137
+
138
+ ```json
139
+ {
140
+ "id": "S2-002",
141
+ "check": "S2",
142
+ "title": "Orphan criterion not tied to any goal",
143
+ "detail": "Success criterion 7 ('All API responses include request-id headers') does not trace to any stated goal in the Overview. It may be an operational requirement that should be added as a goal, or it may be out of scope.",
144
+ "severity": "warning",
145
+ "autoFixable": false,
146
+ "suggestedFix": "Either add a corresponding goal to the Overview (e.g., 'Support request tracing for debugging') or remove this criterion if it is out of scope.",
147
+ "evidence": [
148
+ "Success Criteria #7: 'All API responses include request-id headers'",
149
+ "Overview: no matching goal found"
150
+ ]
151
+ }
152
+ ```
153
+
154
+ ##### S3 Unstated Assumptions
155
+
156
+ **What to analyze:** Technical Design section, Decisions table, data structures, integration points.
157
+
158
+ **How to detect:**
159
+
160
+ - **Document analysis:** Scan for implicit assumptions about runtime environment (single-process, always-online, specific OS), data characteristics (fits in memory, UTF-8 only, no concurrent access), deployment model (single-tenant, monolith, specific cloud provider), and user context (has admin access, uses specific tools). Check whether the spec explicitly states or acknowledges these assumptions.
161
+ - **Without graph (codebase reads):** Read referenced source files (from Technical Design) to identify conventions the spec assumes but does not state (e.g., "uses the existing email utility" — does that utility exist? Does it have the expected interface?). Use Grep/Glob to verify referenced patterns and modules exist.
162
+ - **With graph:** Use `query_graph` to find related modules and their documented assumptions. Use `find_context_for` to surface design decisions from related specs that may conflict.
163
+
164
+ **Finding classification:**
165
+
166
+ - Obvious assumptions (e.g., Node.js runtime, filesystem access, UTF-8 encoding): `severity: "warning"`, `autoFixable: true`. The fix is to add them to an explicit Assumptions section in the spec.
167
+ - Ambiguous assumptions (e.g., single-tenant vs multi-tenant, concurrency model, deployment topology): `severity: "warning"`, `autoFixable: false`. The user must decide which assumption is correct.
168
+
169
+ **Example findings:**
170
+
171
+ ```json
172
+ {
173
+ "id": "S3-001",
174
+ "check": "S3",
175
+ "title": "Implicit Node.js runtime assumption",
176
+ "detail": "Technical Design references 'path.join' and 'fs.readFileSync' without stating the runtime environment. The spec assumes Node.js but does not declare it.",
177
+ "severity": "warning",
178
+ "autoFixable": true,
179
+ "suggestedFix": "Add to Assumptions section: 'Runtime: Node.js >= 18.x (LTS). The implementation uses Node.js built-in modules (fs, path, child_process).'",
180
+ "evidence": [
181
+ "Technical Design > File Operations: uses path.join, fs.readFileSync",
182
+ "No Assumptions section found in spec"
183
+ ]
184
+ }
185
+ ```
186
+
187
+ ```json
188
+ {
189
+ "id": "S3-002",
190
+ "check": "S3",
191
+ "title": "Ambiguous concurrency model",
192
+ "detail": "Technical Design describes a background job processor but does not specify whether it runs in-process (setTimeout/setInterval), as a separate worker thread, or as an independent process. This affects error isolation, memory limits, and deployment.",
193
+ "severity": "warning",
194
+ "autoFixable": false,
195
+ "suggestedFix": "Add a decision to the Decisions table specifying the concurrency model: in-process event loop, worker_threads, or separate process.",
196
+ "evidence": [
197
+ "Technical Design > Job Processor: 'processes background jobs'",
198
+ "Decisions table: no entry for concurrency model"
199
+ ]
200
+ }
201
+ ```
202
+
203
+ ##### S4 Requirement Completeness
204
+
205
+ **What to analyze:** Technical Design section (especially data structures, API endpoints, integration points), Success Criteria section.
206
+
207
+ **How to detect:**
208
+
209
+ - **Error cases:** For each data structure, identify what happens when fields are missing, null, or malformed. For each API endpoint or function, identify error responses. Flag any operation that has no defined error behavior.
210
+ - **Edge cases:** For each numeric field, check if boundary values are specified (zero, negative, overflow). For each string field, check if empty string, very long string, and special character handling is defined. For each collection, check if empty collection behavior is defined.
211
+ - **Failure modes:** For each external dependency (network call, file I/O, third-party service), check if timeout, unavailability, and partial failure behaviors are defined. Apply the EARS "Unwanted" pattern: "If [failure condition], then the system shall [graceful behavior]."
212
+ - **Codebase context:** Read referenced modules to identify error patterns already established in the codebase that the spec should follow.
213
+
214
+ **Finding classification:**
215
+
216
+ - Obvious error cases (missing error handling for file I/O, network calls, JSON parsing): `severity: "warning"`, `autoFixable: true`. The fix is to add the error case following established codebase patterns.
217
+ - Design-dependent error handling (what to do when a service is down — retry? cache? fail?): `severity: "warning"`, `autoFixable: false`. The user must decide the error strategy.
218
+
219
+ **Example findings:**
220
+
221
+ ```json
222
+ {
223
+ "id": "S4-001",
224
+ "check": "S4",
225
+ "title": "Missing file-not-found error case",
226
+ "detail": "Technical Design describes reading a config file with fs.readFileSync but does not specify behavior when the file does not exist. The codebase convention (see packages/core/src/config.ts) is to return a default config object.",
227
+ "severity": "warning",
228
+ "autoFixable": true,
229
+ "suggestedFix": "Add error case: 'If the config file does not exist (ENOENT), return the default configuration object. Log a debug message indicating defaults are being used.'",
230
+ "evidence": [
231
+ "Technical Design > Configuration: 'read config from harness.config.json'",
232
+ "No error handling specified for missing file",
233
+ "Codebase pattern: packages/core/src/config.ts returns defaults on ENOENT"
234
+ ]
235
+ }
236
+ ```
237
+
238
+ ```json
239
+ {
240
+ "id": "S4-002",
241
+ "check": "S4",
242
+ "title": "Undefined retry strategy for external service",
243
+ "detail": "Technical Design describes calling an external API for license validation but does not specify behavior when the API is unavailable, times out, or returns an error. This is a design decision that affects user experience (block vs. degrade gracefully).",
244
+ "severity": "warning",
245
+ "autoFixable": false,
246
+ "suggestedFix": "Add a decision: 'When the license API is unavailable: (a) fail open — allow usage with a warning, (b) fail closed — block usage until validated, or (c) cache — use last known result for N hours.'",
247
+ "evidence": [
248
+ "Technical Design > License Check: 'call /api/validate on startup'",
249
+ "No timeout, retry, or fallback behavior specified"
250
+ ]
251
+ }
252
+ ```
253
+
254
+ ##### S5 Feasibility Red Flags
255
+
256
+ **What to analyze:** Technical Design section (referenced modules, dependencies, patterns, APIs).
257
+
258
+ **How to detect:**
259
+
260
+ - **Without graph (codebase reads):** For each module, function, or class referenced in the Technical Design, use Glob/Grep to verify it exists in the codebase. For each API or interface referenced, read the source to verify the expected signature matches. For each pattern referenced ("uses the existing X"), verify X exists and has the capabilities assumed. Flag references to nonexistent modules, functions with different signatures than assumed, or patterns incompatible with the codebase architecture.
261
+ - **With graph:** Use `query_graph` to verify referenced modules exist and check their dependency relationships. Use `get_relationships` to verify architectural compatibility (e.g., a module in layer A should not depend on layer B). Use `get_impact` to assess whether the proposed changes have cascading effects not accounted for in the spec.
262
+
263
+ **Finding classification:** Always `severity: "error"`, always `autoFixable: false`. Feasibility problems require the user to revise the technical design.
264
+
265
+ **Example finding:**
266
+
267
+ ```json
268
+ {
269
+ "id": "S5-001",
270
+ "check": "S5",
271
+ "title": "Referenced function has different signature",
272
+ "detail": "Technical Design says 'call validateDependencies(projectPath)' but the actual function signature is 'validateDependencies(config: ProjectConfig): ValidationResult'. The spec assumes a simpler interface than what exists.",
273
+ "severity": "error",
274
+ "autoFixable": false,
275
+ "suggestedFix": "Update the Technical Design to use the actual signature: validateDependencies(config) where config is a ProjectConfig object. This may require adding a config construction step before the call.",
276
+ "evidence": [
277
+ "Technical Design > Validation: 'call validateDependencies(projectPath)'",
278
+ "packages/core/src/validator.ts:42: export function validateDependencies(config: ProjectConfig): ValidationResult"
279
+ ]
280
+ }
281
+ ```
282
+
283
+ ##### S6 YAGNI Re-scan
284
+
285
+ **What to analyze:** Technical Design section, Decisions table, Implementation Order.
286
+
287
+ **How to detect:**
288
+
289
+ 1. For each technical component, interface, or configuration option described in Technical Design, check whether it is required by a stated goal or success criterion. Flag components that exist "for future use", "in case we need", or that implement functionality explicitly listed in Non-goals.
290
+ 2. Flag decision rationale that references hypothetical future requirements rather than current needs (e.g., "we might need this later", "for extensibility", "in case the requirements change").
291
+ 3. Flag configuration options that toggle features not yet defined in any goal or criterion.
292
+ 4. Flag abstraction layers or interfaces introduced solely for "flexibility" without a concrete current consumer.
293
+
294
+ **Finding classification:** Always `severity: "warning"`, always `autoFixable: false`. Removing speculative features is a design decision — the user must decide whether the feature is truly needed now or can be deferred.
295
+
296
+ **Example finding:**
297
+
298
+ ```json
299
+ {
300
+ "id": "S6-001",
301
+ "check": "S6",
302
+ "title": "Speculative configuration option",
303
+ "detail": "Technical Design defines a 'pluginDir' configuration option for loading third-party plugins, but no goal or success criterion mentions plugins. The Non-goals section does not exclude plugins, but no current requirement needs them.",
304
+ "severity": "warning",
305
+ "autoFixable": false,
306
+ "suggestedFix": "Remove the pluginDir configuration option and plugin loading logic from the Technical Design. If plugin support is needed later, it can be added in a future spec.",
307
+ "evidence": [
308
+ "Technical Design > Configuration: 'pluginDir: string — directory for third-party plugins'",
309
+ "Overview goals: no mention of plugins",
310
+ "Success Criteria: no criterion references plugins"
311
+ ]
312
+ }
313
+ ```
314
+
315
+ ##### S7 Testability
316
+
317
+ **What to analyze:** Success Criteria section.
318
+
319
+ **How to detect:**
320
+
321
+ 1. For each success criterion, evaluate whether it is observable and measurable. A testable criterion describes a specific behavior that can be verified with a concrete test or measurement.
322
+ 2. Flag criteria that use vague qualifiers without specific thresholds: "should be fast", "handles errors well", "is user-friendly", "scales appropriately", "is robust", "performs efficiently".
323
+ 3. Flag criteria that describe internal implementation details rather than externally observable outcomes (e.g., "uses a clean architecture" — what does "clean" mean in observable terms?).
324
+ 4. For vague criteria where the Technical Design provides context, infer a specific threshold. For example, if the Technical Design mentions a 100ms timeout, "should be fast" can be replaced with "responds within 100ms".
325
+
326
+ **Finding classification:**
327
+
328
+ - Vague criteria with inferrable thresholds (context in Technical Design provides a specific number or behavior): `severity: "warning"`, `autoFixable: true`. The fix is to replace the vague qualifier with the specific threshold or observable behavior derived from the Technical Design.
329
+ - Criteria that are fundamentally unmeasurable (subjective quality, aesthetic judgment, no Technical Design context to infer from): `severity: "error"`, `autoFixable: false`. The user must rewrite the criterion to be observable.
330
+
331
+ **Example findings:**
332
+
333
+ ```json
334
+ {
335
+ "id": "S7-001",
336
+ "check": "S7",
337
+ "title": "Vague performance criterion",
338
+ "detail": "Success criterion 3 says 'the build should be fast' without specifying a threshold. The Technical Design mentions a 30-second CI timeout, suggesting a concrete threshold exists.",
339
+ "severity": "warning",
340
+ "autoFixable": true,
341
+ "suggestedFix": "Replace 'the build should be fast' with 'the build completes in under 30 seconds on CI (as specified in Technical Design > CI Configuration).'",
342
+ "evidence": [
343
+ "Success Criteria #3: 'the build should be fast'",
344
+ "Technical Design > CI Configuration: '30-second timeout'"
345
+ ]
346
+ }
347
+ ```
348
+
349
+ ```json
350
+ {
351
+ "id": "S7-002",
352
+ "check": "S7",
353
+ "title": "Unmeasurable quality criterion",
354
+ "detail": "Success criterion 8 says 'the code is clean and maintainable'. This is a subjective judgment with no observable behavior. There is no Technical Design context to infer specific metrics.",
355
+ "severity": "error",
356
+ "autoFixable": false,
357
+ "suggestedFix": "Rewrite with observable criteria, e.g., 'all functions are under 50 lines, cyclomatic complexity under 10, no eslint warnings' or remove if covered by existing linting rules.",
358
+ "evidence": [
359
+ "Success Criteria #8: 'the code is clean and maintainable'",
360
+ "No Technical Design context for measurable thresholds"
361
+ ]
362
+ }
363
+ ```
364
+
365
+ #### Plan Mode Checks (`--mode plan`)
366
+
367
+ | # | Check | What it detects | Auto-fixable? |
368
+ | --- | ---------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
369
+ | P1 | Spec-plan coverage | Success criteria from spec with no corresponding task(s) | Yes — add missing tasks |
370
+ | P2 | Task completeness | Tasks missing clear inputs, outputs, or verification criteria | Yes — infer from context and fill in |
371
+ | P3 | Dependency correctness | Cycles in dependency graph; task B uses output of A but does not declare dependency | Yes — add missing dependency edges |
372
+ | P4 | Ordering sanity | Tasks touching same files scheduled in parallel; consumers before producers | Yes — reorder |
373
+ | P5 | Risk coverage | Spec risks without mitigation in plan (no task or explicit acceptance) | Partially — add mitigation tasks for obvious risks, surface others |
374
+ | P6 | Scope drift | Plan tasks not traceable to any spec requirement | No — surface to user (might be intentional prerequisite work) |
375
+ | P7 | Task-level feasibility | Tasks requiring decisions not made in brainstorming; tasks too vague to execute | No — surface to user |
376
+
377
+ ##### P1 Spec-Plan Coverage
378
+
379
+ **What to analyze:** The spec's Success Criteria section and the plan's Tasks section. Requires access to both the spec document (referenced in the plan header) and the plan being reviewed.
380
+
381
+ **How to detect:**
382
+
383
+ - Without graph: Extract each numbered success criterion from the spec. For each criterion, search the plan's task descriptions, verification steps, and observable truths for text that covers the criterion. A criterion is "covered" if at least one task's verification step or observable truth would confirm the criterion is met. Flag any criterion with no corresponding task coverage.
384
+ - With graph: If graph traceability edges exist between spec criteria and plan tasks, use those edges to verify coverage. Flag criteria with no inbound traceability edge.
385
+
386
+ **Finding classification:** Always `severity: "error"`, always `autoFixable: true`. The fix is to add a new task (or extend an existing task's verification step) that covers the uncovered criterion.
387
+
388
+ **Example finding:**
389
+
390
+ ```json
391
+ {
392
+ "id": "P1-001",
393
+ "check": "P1",
394
+ "title": "Spec criterion not covered by any plan task",
395
+ "detail": "Success criterion #4 ('All API errors return structured error responses with request-id') has no corresponding task in the plan. No task's verification step or observable truth would confirm this criterion is met.",
396
+ "severity": "error",
397
+ "autoFixable": true,
398
+ "suggestedFix": "Add a new task that implements structured error responses and verifies request-id headers are included. Place it after the API route tasks (Task 3) with appropriate dependencies.",
399
+ "evidence": [
400
+ "Spec Success Criteria #4: 'All API errors return structured error responses with request-id'",
401
+ "Plan Tasks 1-8: no task references error response format or request-id"
402
+ ]
403
+ }
404
+ ```
405
+
406
+ ##### P2 Task Completeness
407
+
408
+ **What to analyze:** Each task in the plan's Tasks section.
409
+
410
+ **How to detect:** For each task, verify it has: (a) clear inputs (what files/artifacts the task reads or depends on), (b) clear outputs (what files the task creates or modifies), (c) a verification criterion (a test command, observable behavior, or check that confirms the task succeeded). Flag tasks missing any of these three elements.
411
+
412
+ **Finding classification:** Always `severity: "warning"`, always `autoFixable: true`. The fix is to infer the missing element from the task description and surrounding context (e.g., if a task says "create src/foo.ts" but has no verification, add "Run: `npx vitest run src/foo.test.ts`" if a test file exists in the plan, or "Run: `tsc --noEmit`" as a minimal verification).
413
+
414
+ **Example finding:**
415
+
416
+ ```json
417
+ {
418
+ "id": "P2-001",
419
+ "check": "P2",
420
+ "title": "Task missing verification criterion",
421
+ "detail": "Task 3 ('Create notification service') specifies inputs (notification types from Task 1) and outputs (src/services/notification-service.ts) but has no verification criterion. There is no test command, observable behavior, or check that confirms the task succeeded.",
422
+ "severity": "warning",
423
+ "autoFixable": true,
424
+ "suggestedFix": "Add verification: 'Run: `npx vitest run src/services/notification-service.test.ts`' (test file exists in Task 4 of the plan).",
425
+ "evidence": [
426
+ "Task 3: no 'Run:', 'Verify:', or 'Check:' step found",
427
+ "Task 4 creates src/services/notification-service.test.ts — can be referenced as verification"
428
+ ]
429
+ }
430
+ ```
431
+
432
+ ##### P3 Dependency Correctness
433
+
434
+ **What to analyze:** The "Depends on" declarations across all tasks, and the file paths / artifacts referenced in each task.
435
+
436
+ **How to detect:**
437
+
438
+ - Build a dependency graph from all "Depends on: Task N" declarations.
439
+ - **Cycle detection:** Run a topological sort on the graph. If the sort fails, a cycle exists. Report the cycle as the set of tasks involved (e.g., "Task 3 -> Task 5 -> Task 3").
440
+ - **Missing edges:** For each task, extract the files it reads or imports. If a file is created by another task (check the File Map), verify the creating task is declared as a dependency. Flag missing edges.
441
+ - Without graph (static analysis): Parse file paths from task descriptions ("Create src/types/foo.ts", "Modify src/services/bar.ts") and match creators to consumers.
442
+ - With graph: Use `get_impact` on each task's output files to verify that all downstream consumers are declared as dependents. Graph edges provide more accurate dependency data than text parsing.
443
+
444
+ **Finding classification:**
445
+
446
+ - Cycles: `severity: "error"`, `autoFixable: false`. Cycles indicate a decomposition error that requires restructuring tasks. Surface to user.
447
+ - Missing dependency edges: `severity: "warning"`, `autoFixable: true`. The fix is to add the missing "Depends on" declaration to the consuming task.
448
+
449
+ **Example findings:**
450
+
451
+ ```json
452
+ {
453
+ "id": "P3-001",
454
+ "check": "P3",
455
+ "title": "Dependency cycle detected",
456
+ "detail": "Tasks form a cycle: Task 3 depends on Task 5, Task 5 depends on Task 3. Topological sort fails. These tasks cannot be executed in any valid order without restructuring.",
457
+ "severity": "error",
458
+ "autoFixable": false,
459
+ "suggestedFix": "Break the cycle by merging Tasks 3 and 5 into a single task, or by extracting the shared dependency into a new task that both depend on.",
460
+ "evidence": [
461
+ "Task 3: 'Depends on: Task 5'",
462
+ "Task 5: 'Depends on: Task 3'",
463
+ "Topological sort failed — cycle: Task 3 -> Task 5 -> Task 3"
464
+ ]
465
+ }
466
+ ```
467
+
468
+ ```json
469
+ {
470
+ "id": "P3-002",
471
+ "check": "P3",
472
+ "title": "Missing dependency edge",
473
+ "detail": "Task 5 imports from 'src/types/notification.ts' which is created by Task 1, but Task 5 does not declare 'Depends on: Task 1'. If Task 5 runs before Task 1, it will fail.",
474
+ "severity": "warning",
475
+ "autoFixable": true,
476
+ "suggestedFix": "Add 'Depends on: Task 1' to Task 5's header.",
477
+ "evidence": [
478
+ "Task 5: imports src/types/notification.ts",
479
+ "File Map: src/types/notification.ts created by Task 1",
480
+ "Task 5 'Depends on' line: 'Depends on: Task 4' (Task 1 not listed)"
481
+ ]
482
+ }
483
+ ```
484
+
485
+ ##### P4 Ordering Sanity
486
+
487
+ **What to analyze:** The task execution order (numbering and dependency graph), the file paths each task touches, and any parallel opportunities declared.
488
+
489
+ **How to detect:**
490
+
491
+ - **File conflict detection:** Extract file paths from each task. If two tasks touch the same file and are not sequenced by a dependency edge (one could run before the other), flag them as a potential conflict. Tasks touching the same file must be ordered.
492
+ - **Consumer-before-producer:** If Task A creates a type or export that Task B imports, but Task B has a lower number and no dependency on Task A, the consumer is scheduled before the producer. Flag the ordering violation.
493
+ - Without graph: Parse file paths from task descriptions and the File Map. Build a file-to-task mapping and check for conflicts.
494
+ - With graph: Use graph file ownership data to get accurate file-to-module mappings. This catches indirect conflicts (e.g., two tasks modify different files in the same module, and the module has a single barrel export that both affect).
495
+
496
+ **Finding classification:** Always `severity: "warning"`, always `autoFixable: true`. The fix is to reorder the tasks (update task numbers and "Depends on" declarations) so that producers come before consumers and file-conflicting tasks are sequenced.
497
+
498
+ **Example finding:**
499
+
500
+ ```json
501
+ {
502
+ "id": "P4-001",
503
+ "check": "P4",
504
+ "title": "Consumer task scheduled before producer",
505
+ "detail": "Task 2 imports from 'src/types/user.ts' which is created by Task 4. Task 2 has no dependency on Task 4, so it could execute first and fail on the missing import.",
506
+ "severity": "warning",
507
+ "autoFixable": true,
508
+ "suggestedFix": "Add 'Depends on: Task 4' to Task 2, or reorder so the type definition task (currently Task 4) comes before Task 2.",
509
+ "evidence": [
510
+ "Task 2: 'import { User } from src/types/user.ts'",
511
+ "Task 4: 'Create src/types/user.ts with User interface'",
512
+ "Task 2 'Depends on': 'none' (Task 4 not listed)"
513
+ ]
514
+ }
515
+ ```
516
+
517
+ ##### P5 Risk Coverage
518
+
519
+ **What to analyze:** The spec's risk-related content (any section mentioning risks, caveats, concerns, open questions) and the plan's tasks and checkpoints.
520
+
521
+ **How to detect:** Identify risks stated in the spec. These appear in: explicit "Risks" sections, decision rationale mentioning tradeoffs, success criteria that imply failure modes, non-goals that have adjacent risk (e.g., "not in CI" implies no automated gate). For each identified risk, check whether the plan contains: (a) a task that directly mitigates it, (b) a checkpoint that acknowledges it, or (c) an explicit "accepted risk" note. Flag risks with no coverage.
522
+
523
+ **Finding classification:**
524
+
525
+ - Obvious mitigation (the risk is technical and a straightforward task addresses it, e.g., "add error handling for X"): `severity: "warning"`, `autoFixable: true`. The fix is to add a mitigation task or extend an existing task's verification step.
526
+ - Judgment-dependent mitigation (the risk involves a design tradeoff, e.g., "performance vs correctness" or "scope vs timeline"): `severity: "warning"`, `autoFixable: false`. Surface to user with mitigation options.
527
+
528
+ **Example findings:**
529
+
530
+ ```json
531
+ {
532
+ "id": "P5-001",
533
+ "check": "P5",
534
+ "title": "Spec risk has no mitigation in plan",
535
+ "detail": "The spec identifies 'convergence loop may not terminate' as a risk in the Risks section, but no plan task tests termination behavior. The mitigation is straightforward: add a test that verifies the loop terminates on fixed-point inputs.",
536
+ "severity": "warning",
537
+ "autoFixable": true,
538
+ "suggestedFix": "Add a task that tests convergence termination with inputs that produce a fixed point (zero auto-fixable findings on first pass).",
539
+ "evidence": [
540
+ "Spec Risks: 'The convergence loop may not terminate if auto-fixes oscillate'",
541
+ "Plan Tasks 1-8: no task references termination testing or loop bounds"
542
+ ]
543
+ }
544
+ ```
545
+
546
+ ```json
547
+ {
548
+ "id": "P5-002",
549
+ "check": "P5",
550
+ "title": "Risk requires design judgment to mitigate",
551
+ "detail": "The spec notes 'auto-fix may introduce new issues' as a risk. Mitigation depends on a design choice: (a) add a rollback mechanism, (b) limit auto-fixes to one pass, or (c) require human approval for cascading fixes. This is a design tradeoff the user must decide.",
552
+ "severity": "warning",
553
+ "autoFixable": false,
554
+ "suggestedFix": "Choose a mitigation strategy: (a) rollback mechanism — add undo capability, (b) single-pass limit — simpler but less thorough, (c) human gate — safer but slower.",
555
+ "evidence": [
556
+ "Spec Risks: 'Auto-fixes may introduce new issues in subsequent passes'",
557
+ "No mitigation strategy specified in spec Decisions table"
558
+ ]
559
+ }
560
+ ```
561
+
562
+ ##### P6 Scope Drift
563
+
564
+ **What to analyze:** The plan's tasks and the spec's goals, success criteria, and technical design.
565
+
566
+ **How to detect:** For each plan task, check whether it is traceable to a spec requirement. A task is traceable if it (a) directly implements a success criterion, (b) is a necessary prerequisite for a task that implements a criterion (type definitions, shared utilities), or (c) is infrastructure work explicitly called for in the spec's implementation order. Flag tasks that cannot be traced to any spec requirement.
567
+
568
+ **Finding classification:** Always `severity: "warning"`, always `autoFixable: false`. Untraceable tasks might be intentional prerequisite work that the planner identified as necessary. The user must confirm whether each flagged task is in scope or should be removed.
569
+
570
+ **Example finding:**
571
+
572
+ ```json
573
+ {
574
+ "id": "P6-001",
575
+ "check": "P6",
576
+ "title": "Plan task not traceable to spec requirement",
577
+ "detail": "Task 8 ('Add Redis caching layer for API responses') is not traceable to any spec goal, success criterion, or technical design section. The spec does not mention caching, Redis, or response-time optimization.",
578
+ "severity": "warning",
579
+ "autoFixable": false,
580
+ "suggestedFix": "Either (a) remove Task 8 if caching is not needed for the current scope, or (b) add a corresponding goal and success criterion to the spec if caching is a genuine requirement.",
581
+ "evidence": [
582
+ "Task 8: 'Add Redis caching layer for API responses'",
583
+ "Spec goals: no mention of caching or performance optimization",
584
+ "Spec success criteria: no criterion references response time or caching",
585
+ "Spec technical design: no caching architecture described"
586
+ ]
587
+ }
588
+ ```
589
+
590
+ ##### P7 Task-Level Feasibility
591
+
592
+ **What to analyze:** Each task's description, file paths, code snippets, and referenced decisions.
593
+
594
+ **How to detect:**
595
+
596
+ - **Undecided dependencies:** Check whether any task requires a design decision that was not made during brainstorming. Indicators: task description says "depending on the approach chosen", "if we go with option A", or references a decision not present in the spec's Decisions table.
597
+ - **Vague instructions:** Check whether any task lacks the specificity required by the harness-planning iron law ("every task must be completable in one context window"). Indicators: task says "implement the service" without specifying which functions, "add validation" without specifying what validation rules, or "handle errors" without specifying which errors and how.
598
+ - **Oversized tasks:** Check whether any task touches more than 3 files, or combines multiple independent concerns (e.g., "create the type, implement the service, write tests, and integrate with the API" in a single task).
599
+
600
+ **Finding classification:** Always `severity: "error"`, always `autoFixable: false`. Feasibility problems require the planner to revise the task — either by making a decision, splitting the task, or adding specificity. These are judgment calls that an auto-fix cannot resolve correctly.
601
+
602
+ **Example findings:**
603
+
604
+ ```json
605
+ {
606
+ "id": "P7-001",
607
+ "check": "P7",
608
+ "title": "Task depends on undecided design choice",
609
+ "detail": "Task 7 says 'implement caching layer' but the spec's Decisions table has no entry for caching strategy (LRU, TTL, write-through, etc.). The task cannot be executed without knowing which caching approach to use.",
610
+ "severity": "error",
611
+ "autoFixable": false,
612
+ "suggestedFix": "Make the caching decision in the spec's Decisions table (e.g., 'D5: Use LRU cache with 5-minute TTL'), then update Task 7 with the specific implementation details.",
613
+ "evidence": [
614
+ "Task 7: 'Implement caching layer for API responses'",
615
+ "Spec Decisions table: no entry for caching strategy",
616
+ "Task 7 references no specific cache implementation"
617
+ ]
618
+ }
619
+ ```
620
+
621
+ ```json
622
+ {
623
+ "id": "P7-002",
624
+ "check": "P7",
625
+ "title": "Task too vague to execute in one context window",
626
+ "detail": "Task 4 says 'implement the notification service' without specifying which methods to implement, what the function signatures are, or what error handling to apply. A developer cannot complete this task without making design decisions that should have been made during planning.",
627
+ "severity": "error",
628
+ "autoFixable": false,
629
+ "suggestedFix": "Split Task 4 into specific sub-tasks: (a) create NotificationService.create() with signature and error handling, (b) create NotificationService.list() with filtering logic, (c) create NotificationService.markRead() with idempotency handling.",
630
+ "evidence": [
631
+ "Task 4: 'Implement the notification service'",
632
+ "No function signatures, no error handling spec, no test expectations",
633
+ "harness-planning iron law: every task must be completable in one context window"
634
+ ]
635
+ }
636
+ ```
637
+
638
+ ---
639
+
640
+ ### Phase 2: FIX — Auto-Fix Inferrable Issues
641
+
642
+ For every finding where `autoFixable: true`:
643
+
644
+ 1. Apply the fix to the spec or plan document in place.
645
+ 2. Log what changed and why (visible to the user after convergence).
646
+ 3. Do NOT prompt the user for auto-fixable issues — they are mechanical.
647
+
648
+ For findings where `autoFixable: false`: skip them in this phase. They will be surfaced in Phase 4.
649
+
650
+ #### Silent vs Surfaced Classification
651
+
652
+ | Check | Auto-fixable findings | Fix behavior |
653
+ | ----- | ----------------------------------------------------------- | ------------------------------------------------- |
654
+ | S1 | None — all findings need user input | Always surfaced |
655
+ | S2 | Missing traceability links (goals without criteria) | Silent fix |
656
+ | S2 | Orphan criteria (criteria without goals) | Surfaced — removing criteria is a design decision |
657
+ | S3 | Obvious assumptions (runtime, encoding, filesystem) | Silent fix |
658
+ | S3 | Ambiguous assumptions (concurrency, tenancy, deployment) | Surfaced — user must choose |
659
+ | S4 | Obvious error cases (file I/O, JSON parse, network timeout) | Silent fix |
660
+ | S4 | Design-dependent error handling (retry strategy, failover) | Surfaced — user must choose strategy |
661
+ | S5 | None — all findings need user input | Always surfaced |
662
+ | S6 | None — all findings need user input | Always surfaced |
663
+ | S7 | Vague criteria with inferrable thresholds | Silent fix |
664
+ | S7 | Unmeasurable criteria (no context to infer) | Surfaced — user must rewrite |
665
+ | P1 | Missing task for uncovered criterion | Silent fix |
666
+ | P2 | Missing inputs, outputs, or verification | Silent fix |
667
+ | P3 | Missing dependency edges | Silent fix |
668
+ | P3 | Dependency cycles | Surfaced — restructuring is a design decision |
669
+ | P4 | File conflicts or consumer-before-producer | Silent fix |
670
+ | P5 | Obvious risk mitigation (technical, straightforward) | Silent fix |
671
+ | P5 | Judgment-dependent risk mitigation | Surfaced — user must choose strategy |
672
+ | P6 | None — all findings need user input | Always surfaced |
673
+ | P7 | None — all findings need user input | Always surfaced |
674
+
675
+ **Rule:** A fix is silent when the correct resolution can be determined from the document context alone, with no design judgment required. If there are two or more plausible resolutions, the fix is surfaced.
676
+
677
+ #### Fix Procedures by Check
678
+
679
+ ##### S2 Fix: Add Missing Success Criteria
680
+
681
+ **When:** A goal in the Overview has no corresponding success criterion.
682
+
683
+ **Procedure:**
684
+
685
+ 1. Read the Technical Design section for context about the uncovered goal.
686
+ 2. Draft a success criterion that is specific, observable, and testable — following the EARS patterns if applicable.
687
+ 3. Append the new criterion to the Success Criteria section with the next available number.
688
+ 4. Record a fix log entry.
689
+
690
+ **Edit operation:** Append to the Success Criteria list.
691
+
692
+ **Fix log entry example:**
693
+
694
+ ```
695
+ [S2-001] FIXED: Added success criterion #11 for goal 'Support offline mode':
696
+ 'The application functions without network connectivity for all read operations,
697
+ returning cached data when available.'
698
+ Derived from: Technical Design > Offline Cache section.
699
+ ```
700
+
701
+ ##### S7 Fix: Replace Vague Criteria with Specific Thresholds
702
+
703
+ **When:** A success criterion uses vague qualifiers ("should be fast", "handles errors well") and the Technical Design provides a concrete threshold or behavior to reference.
704
+
705
+ **Procedure:**
706
+
707
+ 1. Identify the vague qualifier in the criterion.
708
+ 2. Search the Technical Design for a related threshold, timeout, limit, or behavioral specification.
709
+ 3. Replace the vague qualifier with the specific threshold, citing the Technical Design source.
710
+ 4. Record a fix log entry.
711
+
712
+ **Edit operation:** Replace the vague criterion text in place.
713
+
714
+ **Fix log entry example:**
715
+
716
+ ```
717
+ [S7-001] FIXED: Replaced vague criterion #3 'the build should be fast' with:
718
+ 'The build completes in under 30 seconds on CI
719
+ (per Technical Design > CI Configuration: 30-second timeout).'
720
+ ```
721
+
722
+ ##### S3 Fix: Add Obvious Assumptions
723
+
724
+ **When:** The Technical Design uses patterns or APIs that imply a specific runtime, encoding, or environment, and no Assumptions section exists or the assumption is missing from it.
725
+
726
+ **Procedure:**
727
+
728
+ 1. Identify the assumption from the Technical Design evidence (e.g., `fs.readFileSync` implies Node.js, `UTF-8` encoding implied by string operations).
729
+ 2. If no Assumptions section exists in the spec, create one after the Non-goals section.
730
+ 3. Add the assumption as a bullet point with a brief rationale.
731
+ 4. Record a fix log entry.
732
+
733
+ **Edit operation:** Append to the Assumptions section (create section if missing).
734
+
735
+ **Fix log entry example:**
736
+
737
+ ```
738
+ [S3-001] FIXED: Added assumption to Assumptions section:
739
+ 'Runtime: Node.js >= 18.x (LTS). The implementation uses Node.js
740
+ built-in modules (fs, path, child_process).'
741
+ Evidence: Technical Design references path.join, fs.readFileSync.
742
+ ```
743
+
744
+ ##### S4 Fix: Add Obvious Error Cases
745
+
746
+ **When:** A Technical Design operation (file I/O, JSON parsing, network call) has no defined error behavior, and the codebase has an established pattern for that error.
747
+
748
+ **Procedure:**
749
+
750
+ 1. Identify the operation missing error handling.
751
+ 2. Read the referenced codebase module (if cited) to find the established error pattern (e.g., return defaults on ENOENT, log and rethrow on parse errors).
752
+ 3. Add the error case to the Technical Design section near the operation, following EARS "Unwanted" pattern: "If [failure condition], then the system shall [graceful behavior]."
753
+ 4. Record a fix log entry.
754
+
755
+ **Edit operation:** Insert error case after the operation description in Technical Design.
756
+
757
+ **Fix log entry example:**
758
+
759
+ ```
760
+ [S4-001] FIXED: Added error case for config file read:
761
+ 'If the config file does not exist (ENOENT), return the default
762
+ configuration object. Log a debug message indicating defaults are used.'
763
+ Following codebase pattern: packages/core/src/config.ts returns defaults on ENOENT.
764
+ ```
765
+
766
+ ##### P1 Fix: Add Missing Tasks for Uncovered Criteria
767
+
768
+ **When:** A spec success criterion has no corresponding plan task.
769
+
770
+ **Procedure:**
771
+
772
+ 1. Read the spec criterion and Technical Design for context.
773
+ 2. Draft a new task that would verify the criterion, including file paths, test commands, and commit message.
774
+ 3. Insert the task at the appropriate position in the task list (respecting dependencies).
775
+ 4. Update the File Map if new files are introduced.
776
+ 5. Record a fix log entry.
777
+
778
+ **Edit operation:** Insert new task in Tasks section; update File Map.
779
+
780
+ **Fix log entry example:**
781
+
782
+ ```
783
+ [P1-001] FIXED: Added Task 9 covering spec criterion #5 (error logging):
784
+ 'Create src/utils/error-logger.ts with structured error logging.
785
+ Verify: npx vitest run src/utils/error-logger.test.ts'
786
+ Derived from: Spec criterion #5 and Technical Design > Error Handling section.
787
+ ```
788
+
789
+ ##### P2 Fix: Fill In Missing Task Elements
790
+
791
+ **When:** A task is missing clear inputs, outputs, or verification criteria.
792
+
793
+ **Procedure:**
794
+
795
+ 1. Identify which element is missing (inputs, outputs, or verification).
796
+ 2. Infer from the task description and surrounding tasks.
797
+ 3. Add the missing element to the task.
798
+ 4. Record a fix log entry.
799
+
800
+ **Edit operation:** Modify the task in place.
801
+
802
+ **Fix log entry example:**
803
+
804
+ ```
805
+ [P2-001] FIXED: Added verification step to Task 3:
806
+ 'Run: npx vitest run src/services/notification-service.test.ts'
807
+ Inferred from: Task 4 creates the test file for the service Task 3 implements.
808
+ ```
809
+
810
+ ##### P3 Fix: Add Missing Dependency Edges
811
+
812
+ **When:** Task B uses a file or artifact produced by Task A but does not declare "Depends on: Task A".
813
+
814
+ **Procedure:**
815
+
816
+ 1. Identify the producer task from the File Map.
817
+ 2. Add "Depends on: Task N" to the consuming task's header.
818
+ 3. Record a fix log entry.
819
+
820
+ **Edit operation:** Modify the consuming task's "Depends on" line.
821
+
822
+ **Fix log entry example:**
823
+
824
+ ```
825
+ [P3-001] FIXED: Added 'Depends on: Task 2' to Task 5:
826
+ Task 5 imports src/types/notification.ts which is created by Task 2.
827
+ ```
828
+
829
+ ##### P4 Fix: Reorder Conflicting Tasks
830
+
831
+ **When:** Two tasks touch the same file but are not sequenced, or a consumer task is numbered before its producer.
832
+
833
+ **Procedure:**
834
+
835
+ 1. Identify the conflict.
836
+ 2. Reorder by updating task numbers or adding a dependency edge.
837
+ 3. If reordering changes task numbers, update all "Depends on" references throughout the plan.
838
+ 4. Record a fix log entry.
839
+
840
+ **Edit operation:** Reorder tasks and update cross-references.
841
+
842
+ **Fix log entry example:**
843
+
844
+ ```
845
+ [P4-001] FIXED: Added 'Depends on: Task 4' to Task 2:
846
+ Both tasks modify src/routes/index.ts. Task 4 creates the base route
847
+ that Task 2 extends. Sequencing prevents merge conflicts.
848
+ ```
849
+
850
+ ##### P5 Fix: Add Obvious Mitigation Tasks
851
+
852
+ **When:** A spec risk has no coverage in the plan and the mitigation is straightforward (e.g., add error handling, add a test for an edge case).
853
+
854
+ **Procedure:**
855
+
856
+ 1. Read the risk description from the spec.
857
+ 2. Draft a mitigation task or extend an existing task's verification step.
858
+ 3. Insert at the appropriate position.
859
+ 4. Record a fix log entry.
860
+
861
+ **Edit operation:** Insert new task or extend existing task; update File Map if needed.
862
+
863
+ **Fix log entry example:**
864
+
865
+ ```
866
+ [P5-001] FIXED: Added Task 10 for convergence termination testing:
867
+ 'Add test that verifies convergence loop terminates on fixed-point inputs
868
+ (zero auto-fixable findings on first pass).'
869
+ Mitigates spec risk: 'convergence loop may not terminate'.
870
+ ```
871
+
872
+ #### Fix Log Format
873
+
874
+ Every auto-fix MUST be logged. The fix log is accumulated during Phase 2 and presented to the user after convergence (in Phase 4) as an informational summary. The format is:
875
+
876
+ ```
877
+ [{finding-id}] FIXED: {one-line description of what changed}
878
+ {the new text or criterion that was added/modified}
879
+ {source/evidence for the fix}
880
+ ```
881
+
882
+ The fix log serves two purposes: (1) the user can review what was silently changed, and (2) if a fix introduces a new issue in the re-check, the log helps trace the cause.
883
+
884
+ ---
885
+
886
+ ### Phase 3: CONVERGE — Re-Check and Loop
887
+
888
+ After auto-fixes are applied in Phase 2, the convergence loop determines whether further progress is possible.
889
+
890
+ #### Convergence Procedure
891
+
892
+ 1. **Record the issue count.** After Phase 2 completes, note the total number of remaining findings (both auto-fixable and non-auto-fixable) as `count_previous`.
893
+
894
+ 2. **Re-run all checks.** Execute every check for the current mode (S1-S7 for spec mode) against the updated document. Produce a fresh set of findings. Note the new total as `count_current`.
895
+
896
+ 3. **Compare counts.**
897
+ - If `count_current < count_previous`: progress was made. Some auto-fixes resolved issues, or a fix in one area resolved a finding in another (cascading fix). Go to Phase 2 (FIX) and apply any new auto-fixable findings, then return here.
898
+ - If `count_current == count_previous`: no progress. The remaining issues either need user input or cannot be resolved by auto-fix. Stop looping and proceed to Phase 4 (SURFACE).
899
+ - If `count_current > count_previous`: auto-fixes introduced new issues. Log a warning in the fix log ("Auto-fixes increased issue count from {previous} to {current} — review fix procedures for unintended side effects.") and proceed to Phase 4 (SURFACE). Do not continue looping.
900
+
901
+ 4. **Repeat.** Steps 1-3 repeat until no progress is detected. There is no arbitrary iteration cap — the "no progress" check is the termination condition.
902
+
903
+ #### Cascading Fixes
904
+
905
+ A fix applied in one pass can make a previously non-auto-fixable finding become auto-fixable in the next pass. This is called a **cascading fix**. Examples:
906
+
907
+ - **S4 enables S3:** The S4 fix adds an error case that creates an Assumptions section. In the next pass, S3 finds that additional obvious assumptions can now be appended to the existing section (previously S3 could not infer whether to create the section or append to it).
908
+ - **S2 enables S7:** The S2 fix adds a new success criterion. In the next pass, S7 checks the new criterion and finds it can be made more specific using Technical Design context.
909
+ - **S4 enables S4:** The S4 fix adds an error case for one operation. In the next pass, S4 finds a related operation that can now follow the same error pattern (the first fix established a local convention).
910
+
911
+ Plan-mode cascading fix examples:
912
+
913
+ - **P1 enables P3:** The P1 fix adds a new task (covering a missing spec criterion). In the next pass, P3 detects that existing tasks import files created by the new task but do not declare a dependency on it. P3 adds the missing dependency edges.
914
+ - **P1 enables P4:** The P1 fix adds a new task that creates a type file. In the next pass, P4 detects that the new task should be ordered before tasks that import that type, and reorders accordingly.
915
+ - **P2 enables P5:** The P2 fix adds a verification step to a task, making its outputs explicit. In the next pass, P5 finds that a spec risk (previously unmatched to any task) is now mitigated by the newly explicit verification step.
916
+
917
+ Cascading fixes are the reason the loop re-runs all checks, not just the checks that produced auto-fixable findings in the previous pass.
918
+
919
+ #### Worked Example: Two-Pass Convergence
920
+
921
+ ```
922
+ Pass 1 (initial check):
923
+ S1: 0 findings
924
+ S2: 1 finding (auto-fixable: missing criterion for 'offline mode' goal)
925
+ S3: 2 findings (1 auto-fixable: Node.js runtime, 1 needs user input: concurrency)
926
+ S4: 1 finding (auto-fixable: missing ENOENT error case)
927
+ S5: 0 findings
928
+ S6: 0 findings
929
+ S7: 1 finding (auto-fixable: vague 'fast' criterion)
930
+ Total: 5 findings, 4 auto-fixable, 1 needs user input.
931
+ → count_previous = 5
932
+
933
+ Phase 2 (FIX): Apply 4 auto-fixes.
934
+ [S2-001] FIXED: Added success criterion #11 for 'offline mode'.
935
+ [S3-001] FIXED: Added Node.js runtime assumption to new Assumptions section.
936
+ [S4-001] FIXED: Added ENOENT error case for config read.
937
+ [S7-001] FIXED: Replaced 'fast' with 'under 30 seconds on CI'.
938
+
939
+ Pass 2 (re-check):
940
+ S1: 0 findings
941
+ S2: 0 findings (criterion added — gap closed)
942
+ S3: 1 finding — CASCADING: S4-001 fix created Assumptions section,
943
+ so the Node.js assumption that S3-001 added is confirmed,
944
+ BUT a new obvious assumption (UTF-8 encoding) can now be appended.
945
+ (1 auto-fixable)
946
+ S3: 1 finding (unchanged: concurrency model still needs user input)
947
+ S4: 0 findings (error case added)
948
+ S5: 0 findings
949
+ S6: 0 findings
950
+ S7: 0 findings (criterion sharpened)
951
+ Total: 2 findings, 1 auto-fixable, 1 needs user input.
952
+ → count_current = 2 < count_previous = 5. Progress made. Continue.
953
+
954
+ Phase 2 (FIX): Apply 1 auto-fix.
955
+ [S3-003] FIXED: Added UTF-8 encoding assumption to Assumptions section.
956
+
957
+ Pass 3 (re-check):
958
+ S3: 1 finding (unchanged: concurrency model still needs user input)
959
+ Total: 1 finding, 0 auto-fixable, 1 needs user input.
960
+ → count_current = 1 < count_previous = 2. Progress made. Continue.
961
+
962
+ Phase 2 (FIX): 0 auto-fixable findings. Nothing to fix.
963
+
964
+ Pass 4 (re-check):
965
+ Total: 1 finding, 0 auto-fixable.
966
+ → count_current = 1 = count_previous = 1. No progress. Converged.
967
+ → Proceed to Phase 4 (SURFACE) with 1 remaining issue.
968
+ ```
969
+
970
+ #### Worked Example: Plan-Mode Two-Pass Convergence
971
+
972
+ ```
973
+ Pass 1 (initial check):
974
+ P1: 1 finding (auto-fixable: spec criterion #6 has no plan task)
975
+ P2: 1 finding (auto-fixable: Task 4 missing verification step)
976
+ P3: 0 findings
977
+ P4: 0 findings
978
+ P5: 1 finding (needs user input: performance vs correctness tradeoff)
979
+ P6: 0 findings
980
+ P7: 1 finding (needs user input: Task 7 depends on undecided caching strategy)
981
+ Total: 4 findings, 2 auto-fixable, 2 need user input.
982
+ → count_previous = 4
983
+
984
+ Phase 2 (FIX): Apply 2 auto-fixes.
985
+ [P1-001] FIXED: Added Task 9 covering spec criterion #6 (structured error logging).
986
+ Creates src/utils/error-logger.ts and src/utils/error-logger.test.ts.
987
+ [P2-001] FIXED: Added verification step to Task 4:
988
+ 'Run: npx vitest run src/services/notification-service.test.ts'
989
+
990
+ Pass 2 (re-check):
991
+ P1: 0 findings (criterion now covered by Task 9)
992
+ P2: 0 findings (Task 4 now has verification)
993
+ P3: 1 finding — CASCADING: Task 9 (added by P1-001) creates
994
+ src/utils/error-logger.ts, but Task 6 imports from it without
995
+ declaring 'Depends on: Task 9'. (1 auto-fixable)
996
+ P4: 0 findings
997
+ P5: 1 finding (unchanged: performance tradeoff still needs user input)
998
+ P6: 0 findings
999
+ P7: 1 finding (unchanged: caching decision still needed)
1000
+ Total: 3 findings, 1 auto-fixable, 2 need user input.
1001
+ → count_current = 3 < count_previous = 4. Progress made. Continue.
1002
+
1003
+ Phase 2 (FIX): Apply 1 auto-fix.
1004
+ [P3-001] FIXED: Added 'Depends on: Task 9' to Task 6.
1005
+
1006
+ Pass 3 (re-check):
1007
+ P5: 1 finding (unchanged: performance tradeoff)
1008
+ P7: 1 finding (unchanged: caching decision)
1009
+ Total: 2 findings, 0 auto-fixable, 2 need user input.
1010
+ → count_current = 2 < count_previous = 3. Progress made. Continue.
1011
+
1012
+ Phase 2 (FIX): 0 auto-fixable findings. Nothing to fix.
1013
+
1014
+ Pass 4 (re-check):
1015
+ Total: 2 findings, 0 auto-fixable.
1016
+ → count_current = 2 = count_previous = 2. No progress. Converged.
1017
+ → Proceed to Phase 4 (SURFACE) with 2 remaining issues.
1018
+ ```
1019
+
1020
+ #### Termination Guarantee
1021
+
1022
+ The loop terminates because:
1023
+
1024
+ 1. Each pass can only fix auto-fixable findings. The set of auto-fixable findings is finite (bounded by the document size).
1025
+ 2. Each fix modifies the document, so the "same" finding cannot be auto-fixed twice (the context has changed).
1026
+ 3. If no auto-fixable findings remain, Phase 2 applies zero fixes, and the re-check produces the same count — triggering the "no progress" exit.
1027
+ 4. Cascading fixes can only occur a finite number of times because each adds content to the document, and the checks that detect missing content will eventually find nothing missing.
1028
+
1029
+ ---
1030
+
1031
+ ### Phase 4: SURFACE — Present Remaining Issues
1032
+
1033
+ When findings remain after the convergence loop (Phase 3 determined no further auto-fix progress), present them to the user. If no `needs-user-input` findings remain (all were resolved by auto-fix), skip this phase entirely and proceed to Clean Exit.
1034
+
1035
+ #### Step 1: Group and Prioritize Findings
1036
+
1037
+ Organize remaining findings for presentation:
1038
+
1039
+ 1. **Group by severity.** Present all `error` findings before `warning` findings. Errors block sign-off; warnings are advisory.
1040
+ 2. **Within each severity group, order by check ID.** S1 before S2 before S3 (spec mode); P1 before P2 before P3 (plan mode). This gives the user a predictable reading order.
1041
+ 3. **Count and announce.** State the total: `N remaining issues need your input (X errors, Y warnings).`
1042
+
1043
+ #### Step 2: Present Each Finding
1044
+
1045
+ For each finding, present exactly three sections:
1046
+
1047
+ **What is wrong** — Use the finding's `title` as a heading, followed by the `detail` field. Include the `evidence` references so the user can locate the problem in context.
1048
+
1049
+ ```
1050
+ [{id}] {title} ({severity})
1051
+ {detail}
1052
+ Evidence: {evidence[0]}, {evidence[1]}, ...
1053
+ ```
1054
+
1055
+ **Why it matters** — Explain the consequence of leaving this unresolved:
1056
+
1057
+ - For `error` severity: "This blocks sign-off. The spec/plan cannot be finalized until this is resolved."
1058
+ - For `warning` severity: "This is advisory. You may dismiss it with a reason, but the concern will be logged."
1059
+
1060
+ **Suggested resolution** — Present the `suggestedFix` as the primary option, then list alternative resolution paths:
1061
+
1062
+ - **Option A (recommended):** The suggested fix from the finding.
1063
+ - **Option B:** An alternative approach if one is apparent from context.
1064
+ - **Option C (warnings only):** "Dismiss with reason — explain why this is acceptable."
1065
+
1066
+ #### Step 3: User Interaction
1067
+
1068
+ Wait for the user to respond to each finding. Accepted responses:
1069
+
1070
+ 1. **Resolve:** The user makes the suggested change (or an alternative). Mark the finding as `resolved`. The user may edit the spec/plan directly, add a decision to the Decisions table, add a task, or modify an existing task.
1071
+
1072
+ 2. **Dismiss with reason (warnings only):** The user provides a reason why the warning is acceptable. Mark the finding as `dismissed` and log: `[{id}] DISMISSED by user: {reason}`. Dismissed findings are not re-surfaced in subsequent loop iterations.
1073
+
1074
+ 3. **Clarify:** The user asks for more context about the finding. Provide additional detail from the evidence and codebase reads. Do not mark the finding as resolved — wait for a resolve or dismiss response.
1075
+
1076
+ Error-severity findings cannot be dismissed. They must be resolved before sign-off.
1077
+
1078
+ #### Step 4: Track Resolution Progress
1079
+
1080
+ Maintain a running status of all surfaced findings:
1081
+
1082
+ ```
1083
+ Surfaced findings: N total
1084
+ Resolved: X
1085
+ Dismissed: Y (warnings only)
1086
+ Pending: Z
1087
+ ```
1088
+
1089
+ After each user resolution or dismissal, update the count and present the next pending finding. When all findings are either resolved or dismissed, proceed to Step 5.
1090
+
1091
+ #### Step 5: Re-Check After Resolution
1092
+
1093
+ After all surfaced findings have been addressed:
1094
+
1095
+ 1. Loop back to Phase 1 (CHECK) to verify that user resolutions are correct and catch any cascading issues introduced by the changes.
1096
+ 2. Previously dismissed findings (logged with reason) are excluded from this re-check. They do not re-appear.
1097
+ 3. If the re-check produces new findings, the full convergence loop runs again (Phase 1 through Phase 4). This is expected — user changes can introduce new issues.
1098
+ 4. If the re-check produces zero findings, proceed to Clean Exit.
1099
+
1100
+ #### Clean Exit
1101
+
1102
+ Clean Exit occurs when ALL of the following are true:
1103
+
1104
+ - All checks pass with zero findings (excluding dismissed warnings).
1105
+ - No `error`-severity findings are pending or dismissed (errors cannot be dismissed).
1106
+ - The convergence loop has terminated (issue count stopped decreasing or reached zero).
1107
+
1108
+ On clean exit:
1109
+
1110
+ 1. Announce: `CLEAN EXIT — all checks pass. Returning control to {parent skill} for sign-off.`
1111
+ 2. If any warnings were dismissed, include a summary: `Note: {N} warnings were dismissed by user. See log for reasons.`
1112
+ 3. Return control to the parent skill (harness-brainstorming or harness-planning).
1113
+
1114
+ ---
1115
+
1116
+ ### Codebase and Graph Integration
1117
+
1118
+ Checks that benefit from codebase awareness (S3, S5, P1, P3, P4) use these tools:
1119
+
1120
+ | Check | Without graph | With graph |
1121
+ | ----- | ------------------------------------ | ----------------------------------------------------------------------------------------- |
1122
+ | S5 | Grep/glob for referenced patterns | `query_graph` + `get_relationships` to verify dependencies and architecture compatibility |
1123
+ | S3 | Infer from codebase conventions | `find_context_for` to surface related design decisions |
1124
+ | P1 | Text matching criteria to tasks | Graph traceability edges if available |
1125
+ | P3 | Static analysis of task descriptions | `get_impact` to verify dependency completeness |
1126
+ | P4 | Parse file paths, detect conflicts | Graph file ownership for accurate conflict detection |
1127
+
1128
+ All checks produce useful results from document analysis and basic codebase reads alone. Graph adds precision but is never required.
1129
+
1130
+ ## Harness Integration
1131
+
1132
+ - **`harness validate`** — Run by the parent skill (harness-brainstorming or harness-planning) before and after the soundness review. This skill does not invoke validate directly.
1133
+ - **Parent skill invocation** — harness-brainstorming invokes `--mode spec` before sign-off; harness-planning invokes `--mode plan` before sign-off.
1134
+ - **No new user commands** — Users invoke brainstorming and planning exactly as before. The soundness review is invisible until it surfaces an issue.
1135
+ - **Graph queries** — When `.harness/graph/` exists, use `query_graph` and `get_impact` for enhanced feasibility and dependency checks. Fall back to file-based reads when no graph is available.
1136
+
1137
+ ## Success Criteria
1138
+
1139
+ These criteria validate the skill implementation artifacts. The behavioral success criteria from the spec (automatic invocation, coherence detection, convergence termination, etc.) are verified by running the skill against real specs and plans.
1140
+
1141
+ 1. The skill.yaml passes schema validation with all required fields
1142
+ 2. The SKILL.md contains all required sections and passes structure tests
1143
+ 3. Both platform copies (claude-code, gemini-cli) are byte-identical and pass parity tests
1144
+ 4. The two modes (spec, plan) are defined with their check tables (S1-S7, P1-P7)
1145
+ 5. The `SoundnessFinding` schema is defined in the SKILL.md
1146
+ 6. The convergence loop structure (CHECK, FIX, CONVERGE, SURFACE, CLEAN EXIT) is documented
1147
+ 7. `harness validate` passes after all files are written
1148
+ 8. The skill test suite passes (structure, schema, platform-parity, references)
1149
+
1150
+ ## Examples
1151
+
1152
+ ### Example: Spec Mode Invocation
1153
+
1154
+ **Context:** harness-brainstorming has drafted a spec and is about to sign off.
1155
+
1156
+ ```
1157
+ Invoking harness-soundness-review --mode spec...
1158
+
1159
+ Phase 1: CHECK
1160
+ Running S1 (internal coherence)... 0 findings
1161
+ Running S2 (goal-criteria traceability)... 1 finding (auto-fixable)
1162
+ Running S3 (unstated assumptions)... 2 findings (2 need user input)
1163
+ Running S4 (requirement completeness)... 1 finding (auto-fixable)
1164
+ Running S5 (feasibility red flags)... 0 findings
1165
+ Running S6 (YAGNI re-scan)... 0 findings
1166
+ Running S7 (testability)... 1 finding (auto-fixable)
1167
+
1168
+ 5 findings total: 3 auto-fixable, 2 need user input.
1169
+
1170
+ Phase 2: FIX
1171
+ [S2-001] FIXED: Added success criterion for 'Support offline mode' goal.
1172
+ [S4-001] FIXED: Added ENOENT error case for config file read (following codebase pattern).
1173
+ [S7-001] FIXED: Replaced 'build should be fast' with 'completes in under 30 seconds on CI'.
1174
+ 3 auto-fixes applied.
1175
+
1176
+ Phase 3: CONVERGE
1177
+ Re-running checks...
1178
+ S3-001 (implicit Node.js assumption) — now auto-fixable (S4-001 fix added
1179
+ Assumptions section, so S3-001 can append to it instead of creating one).
1180
+ [S3-001] FIXED: Added Node.js runtime assumption to Assumptions section.
1181
+ 1 additional fix applied. Re-checking...
1182
+ Issue count: 1 (was 2). Decreased — continuing.
1183
+ Re-running checks...
1184
+ Issue count: 1 (unchanged). Converged.
1185
+
1186
+ Phase 4: SURFACE
1187
+ 1 remaining issue needs your input:
1188
+
1189
+ [S3-002] Ambiguous concurrency model (warning)
1190
+ Technical Design describes a background job processor but does not specify
1191
+ whether it runs in-process, as a worker thread, or as a separate process.
1192
+ → Add a decision to the Decisions table specifying the concurrency model.
1193
+
1194
+ User resolves S3-002 → adds decision: "in-process event loop"
1195
+ Re-running checks... 0 findings.
1196
+
1197
+ CLEAN EXIT — returning control to harness-brainstorming for sign-off.
1198
+ ```
1199
+
1200
+ ### Example: Plan Mode Invocation
1201
+
1202
+ **Context:** harness-planning has drafted a plan and is about to sign off.
1203
+
1204
+ ```
1205
+ Invoking harness-soundness-review --mode plan...
1206
+
1207
+ Phase 1: CHECK
1208
+ Running P1 (spec-plan coverage)... 1 finding (auto-fixable)
1209
+ Running P2 (task completeness)... 2 findings (auto-fixable)
1210
+ Running P3 (dependency correctness)... 1 finding (auto-fixable)
1211
+ Running P4 (ordering sanity)... 0 findings
1212
+ Running P5 (risk coverage)... 1 finding (1 needs user input)
1213
+ Running P6 (scope drift)... 0 findings
1214
+ Running P7 (task-level feasibility)... 1 finding (needs user input)
1215
+
1216
+ 6 findings total: 4 auto-fixable, 2 need user input.
1217
+
1218
+ Phase 2: FIX
1219
+ [P1-001] FIXED: Added Task 9 covering spec criterion #5 (error logging).
1220
+ [P2-001] FIXED: Added verification step to Task 3 (run vitest).
1221
+ [P2-002] FIXED: Added outputs to Task 6 (creates src/utils/helper.ts).
1222
+ [P3-001] FIXED: Added 'Depends on: Task 2' to Task 5 (uses types from Task 2).
1223
+ 4 auto-fixes applied.
1224
+
1225
+ Phase 3: CONVERGE
1226
+ Re-running checks...
1227
+ Issue count: 2 (was 6). Decreased — continuing.
1228
+ Re-running checks...
1229
+ Issue count: 2 (unchanged). Converged.
1230
+
1231
+ Phase 4: SURFACE
1232
+ 2 remaining issues need your input:
1233
+
1234
+ [P5-001] Spec risk 'performance vs correctness tradeoff' has no mitigation (warning)
1235
+ The spec notes that strict validation may impact throughput, but no plan task
1236
+ addresses performance testing or defines an acceptable latency threshold.
1237
+ -> Add a performance benchmark task, relax validation, or accept the risk.
1238
+
1239
+ [P7-001] Task 7 depends on undecided caching strategy (error)
1240
+ Task 7 says 'implement caching layer' but the spec Decisions table has no
1241
+ entry for caching strategy. This task cannot be executed without a decision.
1242
+ -> Make the caching decision in the spec, then update Task 7 with specifics.
1243
+
1244
+ User resolves P5-001 -> adds Task 10 for performance benchmark at 100ms threshold.
1245
+ User resolves P7-001 -> updates spec with LRU cache decision, updates Task 7.
1246
+ Re-running checks... 0 findings.
1247
+
1248
+ CLEAN EXIT — returning control to harness-planning for sign-off.
1249
+ ```
1250
+
1251
+ ## Gates
1252
+
1253
+ These are hard stops. Violating any gate means the process has broken down.
1254
+
1255
+ - **No sign-off without convergence.** The soundness review must reach a clean exit (zero findings) before the parent skill proceeds to write the spec or plan. If issues remain, the user must resolve them.
1256
+ - **No silent resolution of design decisions.** Contradictions (S1), feasibility concerns (S5), YAGNI violations (S6), scope drift (P6), and task-level feasibility (P7) are NEVER auto-fixed. The user must always decide.
1257
+ - **No auto-fix without logging.** Every auto-fix must be logged with what changed and why. Silent, unlogged mutations are not allowed.
1258
+ - **Convergence must terminate.** The loop stops when issue count stops decreasing. There is no retry cap — but "no progress" is the hard stop.
1259
+
1260
+ ## Escalation
1261
+
1262
+ - **When the spec or plan is too large for a single pass:** Break the document into sections and run checks section by section. Present findings grouped by section.
1263
+ - **When a check produces false positives:** Log the false positive and skip it. Do not block sign-off on a finding that the user has explicitly dismissed.
1264
+ - **When the convergence loop makes no progress on the first iteration:** All remaining findings need user input. Skip directly to Phase 4 (SURFACE) without looping.
1265
+ - **When graph queries are unavailable:** Fall back to document analysis and codebase reads. All checks are designed to work without graph. Do not block or warn about missing graph — just use the fallback path.
1266
+ - **When user resolutions repeatedly introduce new errors:** After 2 consecutive resolution attempts that each introduce a new error-severity finding, suggest pausing the soundness review to revisit the spec design holistically rather than fixing issues one at a time.
1267
+ - **When codebase files referenced in the spec cannot be read:** Skip the feasibility sub-check for that file. Log the skip and continue with the remaining checks. Do not block the review on inaccessible files.