@massa-ai/cursor-plugin 1.6.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 (172) hide show
  1. package/.cursor-plugin/plugin.json +5 -0
  2. package/README.md +87 -0
  3. package/agents/massa-ai-architecture-specialist.md +65 -0
  4. package/agents/massa-ai-audit-specialist.md +81 -0
  5. package/agents/massa-ai-builder.md +67 -0
  6. package/agents/massa-ai-context-curator.md +67 -0
  7. package/agents/massa-ai-documentation-agent.md +65 -0
  8. package/agents/massa-ai-furps-analyst.md +71 -0
  9. package/agents/massa-ai-investigator.md +68 -0
  10. package/agents/massa-ai-mobile-specialist.md +82 -0
  11. package/agents/massa-ai-navigator.md +75 -0
  12. package/agents/massa-ai-plan-critic.md +90 -0
  13. package/agents/massa-ai-planner.md +65 -0
  14. package/agents/massa-ai-requirements-analyst.md +64 -0
  15. package/agents/massa-ai-reviewer.md +66 -0
  16. package/agents/massa-ai-test-engineer.md +66 -0
  17. package/agents/massa-ai-verification-agent.md +65 -0
  18. package/hooks/hooks.json +26 -0
  19. package/hooks/massa-ai-hook +298 -0
  20. package/install.sh +413 -0
  21. package/package.json +30 -0
  22. package/skills/agents/architecture-specialist/SKILL.md +69 -0
  23. package/skills/agents/audit-specialist/SKILL.md +85 -0
  24. package/skills/agents/builder/SKILL.md +71 -0
  25. package/skills/agents/context-curator/SKILL.md +71 -0
  26. package/skills/agents/documentation-agent/SKILL.md +69 -0
  27. package/skills/agents/furps-analyst/SKILL.md +74 -0
  28. package/skills/agents/investigator/SKILL.md +72 -0
  29. package/skills/agents/mobile-specialist/SKILL.md +86 -0
  30. package/skills/agents/navigator/SKILL.md +79 -0
  31. package/skills/agents/plan-critic/SKILL.md +93 -0
  32. package/skills/agents/planner/SKILL.md +69 -0
  33. package/skills/agents/requirements-analyst/SKILL.md +68 -0
  34. package/skills/agents/reviewer/SKILL.md +70 -0
  35. package/skills/agents/test-engineer/SKILL.md +70 -0
  36. package/skills/agents/verification-agent/SKILL.md +69 -0
  37. package/skills/def/SKILL.md +17 -0
  38. package/skills/find/SKILL.md +19 -0
  39. package/skills/graph/SKILL.md +16 -0
  40. package/skills/index/SKILL.md +19 -0
  41. package/skills/map/SKILL.md +24 -0
  42. package/skills/massa-ai/SKILL.md +315 -0
  43. package/skills/massa-ai/personas/README.md +35 -0
  44. package/skills/massa-ai/personas/ai-native-nodejs-cli-architect.md +76 -0
  45. package/skills/massa-ai/personas/catalog.json +157 -0
  46. package/skills/massa-ai/personas/context-skill-harness-engineer-architect.md +74 -0
  47. package/skills/massa-ai/personas/product-manager.md +67 -0
  48. package/skills/massa-ai/personas/senior-mobile-engineer.md +74 -0
  49. package/skills/massa-ai/personas/senior-mobile-qa-automation-engineer.md +75 -0
  50. package/skills/massa-ai/references/adr-authoring.md +189 -0
  51. package/skills/massa-ai/references/agent-orchestration.md +221 -0
  52. package/skills/massa-ai/references/architecture-coupling-lens.md +239 -0
  53. package/skills/massa-ai/references/architecture-deepening-lens.md +136 -0
  54. package/skills/massa-ai/references/architecture-domain-lens.md +186 -0
  55. package/skills/massa-ai/references/architecture-lenses.md +108 -0
  56. package/skills/massa-ai/references/audit-report-io.md +459 -0
  57. package/skills/massa-ai/references/audit-scope.md +103 -0
  58. package/skills/massa-ai/references/code-annotation.md +111 -0
  59. package/skills/massa-ai/references/codebase-investigation.md +96 -0
  60. package/skills/massa-ai/references/context-firewall.md +62 -0
  61. package/skills/massa-ai/references/conversation-feedback.md +104 -0
  62. package/skills/massa-ai/references/debug-diagnosis-loop.md +140 -0
  63. package/skills/massa-ai/references/decision-engine.md +73 -0
  64. package/skills/massa-ai/references/evidence-gate.md +53 -0
  65. package/skills/massa-ai/references/furps/analyst-role.md +49 -0
  66. package/skills/massa-ai/references/furps/checklist.md +92 -0
  67. package/skills/massa-ai/references/furps/intake.md +104 -0
  68. package/skills/massa-ai/references/furps/report-contract.md +140 -0
  69. package/skills/massa-ai/references/hook-enforcement.md +137 -0
  70. package/skills/massa-ai/references/implementation-delivery.md +101 -0
  71. package/skills/massa-ai/references/installation.md +110 -0
  72. package/skills/massa-ai/references/lessons.md +119 -0
  73. package/skills/massa-ai/references/maestro/artifacts-reports.md +69 -0
  74. package/skills/massa-ai/references/maestro/cli-device.md +65 -0
  75. package/skills/massa-ai/references/maestro/cloud.md +67 -0
  76. package/skills/massa-ai/references/maestro/config-env-output.md +76 -0
  77. package/skills/massa-ai/references/maestro/fact-ledger.md +71 -0
  78. package/skills/massa-ai/references/maestro/js-scripting.md +70 -0
  79. package/skills/massa-ai/references/maestro/mcp.md +59 -0
  80. package/skills/massa-ai/references/maestro/patterns.md +96 -0
  81. package/skills/massa-ai/references/maestro/selectors.md +91 -0
  82. package/skills/massa-ai/references/maestro/workspace-execution.md +81 -0
  83. package/skills/massa-ai/references/maestro/yaml-commands.md +203 -0
  84. package/skills/massa-ai/references/maestro.md +47 -0
  85. package/skills/massa-ai/references/mcp-tools.md +296 -0
  86. package/skills/massa-ai/references/memory-policy.md +103 -0
  87. package/skills/massa-ai/references/mobile-context.md +113 -0
  88. package/skills/massa-ai/references/mobile-diagnosis.md +106 -0
  89. package/skills/massa-ai/references/mobile-figma-matcher/ATTRIBUTION.md +5 -0
  90. package/skills/massa-ai/references/mobile-figma-matcher/android-compose.md +13 -0
  91. package/skills/massa-ai/references/mobile-figma-matcher/android-views.md +13 -0
  92. package/skills/massa-ai/references/mobile-figma-matcher/core.md +117 -0
  93. package/skills/massa-ai/references/mobile-figma-matcher/ios-swiftui.md +12 -0
  94. package/skills/massa-ai/references/mobile-figma-matcher/ios-uikit.md +12 -0
  95. package/skills/massa-ai/references/mobile-figma-matcher/kmp-compose-multiplatform.md +14 -0
  96. package/skills/massa-ai/references/mobile-figma-matcher/repository-detection.md +77 -0
  97. package/skills/massa-ai/references/naming-standards.md +47 -0
  98. package/skills/massa-ai/references/pr-task-fix.md +80 -0
  99. package/skills/massa-ai/references/project-context.md +76 -0
  100. package/skills/massa-ai/references/rfc/ATTRIBUTION.md +5 -0
  101. package/skills/massa-ai/references/rfc/discovery-and-sizing.md +120 -0
  102. package/skills/massa-ai/references/rfc/document-contract.md +85 -0
  103. package/skills/massa-ai/references/rfc/quality-and-lifecycle.md +101 -0
  104. package/skills/massa-ai/references/root-cause-scripts.md +97 -0
  105. package/skills/massa-ai/references/spec-driven/artifact-store.md +98 -0
  106. package/skills/massa-ai/references/spec-driven/code-analysis.md +119 -0
  107. package/skills/massa-ai/references/spec-driven/coding-principles.md +80 -0
  108. package/skills/massa-ai/references/spec-driven/context-limits.md +64 -0
  109. package/skills/massa-ai/references/spec-driven/design.md +257 -0
  110. package/skills/massa-ai/references/spec-driven/discuss.md +182 -0
  111. package/skills/massa-ai/references/spec-driven/execute.md +471 -0
  112. package/skills/massa-ai/references/spec-driven/lessons.md +5 -0
  113. package/skills/massa-ai/references/spec-driven/memory.md +214 -0
  114. package/skills/massa-ai/references/spec-driven/specify.md +283 -0
  115. package/skills/massa-ai/references/spec-driven/sub-agents.md +151 -0
  116. package/skills/massa-ai/references/spec-driven/tasks.md +494 -0
  117. package/skills/massa-ai/references/spec-driven/validate.md +397 -0
  118. package/skills/massa-ai/references/subagent-design.md +132 -0
  119. package/skills/massa-ai/references/synapse-policy.md +160 -0
  120. package/skills/massa-ai/references/tdd/calibrated-examples.md +54 -0
  121. package/skills/massa-ai/references/tdd/discovery-and-sizing.md +83 -0
  122. package/skills/massa-ai/references/tdd/document-contract.md +136 -0
  123. package/skills/massa-ai/references/tdd/quality-and-lifecycle.md +83 -0
  124. package/skills/massa-ai/references/the-fool/cognitive-bias-inventory.md +103 -0
  125. package/skills/massa-ai/references/the-fool/dialectic-synthesis.md +170 -0
  126. package/skills/massa-ai/references/the-fool/evidence-audit.md +202 -0
  127. package/skills/massa-ai/references/the-fool/mode-selection-guide.md +113 -0
  128. package/skills/massa-ai/references/the-fool/pre-mortem-analysis.md +200 -0
  129. package/skills/massa-ai/references/the-fool/red-team-adversarial.md +206 -0
  130. package/skills/massa-ai/references/the-fool/socratic-questioning.md +153 -0
  131. package/skills/massa-ai/references/ticket/atlassian-fix.md +130 -0
  132. package/skills/massa-ai/references/ticket/intake-and-sources.md +65 -0
  133. package/skills/massa-ai/references/ticket/templates-and-quality.md +129 -0
  134. package/skills/massa-ai/references/verification-ladder.md +62 -0
  135. package/skills/massa-ai/scripts/lessons.py +590 -0
  136. package/skills/massa-ai/workflows/adr.md +33 -0
  137. package/skills/massa-ai/workflows/architecture/architecture-audit.md +125 -0
  138. package/skills/massa-ai/workflows/architecture/architecture-fix.md +110 -0
  139. package/skills/massa-ai/workflows/bugs/bugs-audit.md +113 -0
  140. package/skills/massa-ai/workflows/bugs/bugs-fix.md +97 -0
  141. package/skills/massa-ai/workflows/code-quality/code-quality-audit.md +154 -0
  142. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +99 -0
  143. package/skills/massa-ai/workflows/commit.md +61 -0
  144. package/skills/massa-ai/workflows/debug.md +86 -0
  145. package/skills/massa-ai/workflows/design.md +54 -0
  146. package/skills/massa-ai/workflows/exploration.md +119 -0
  147. package/skills/massa-ai/workflows/feature.md +52 -0
  148. package/skills/massa-ai/workflows/general.md +46 -0
  149. package/skills/massa-ai/workflows/implementation/implementation-audit.md +87 -0
  150. package/skills/massa-ai/workflows/implementation/implementation-fix.md +90 -0
  151. package/skills/massa-ai/workflows/long-session.md +44 -0
  152. package/skills/massa-ai/workflows/maestro/maestro-audit.md +56 -0
  153. package/skills/massa-ai/workflows/maestro/maestro-fix.md +74 -0
  154. package/skills/massa-ai/workflows/maestro/maestro.md +68 -0
  155. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-audit.md +68 -0
  156. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +74 -0
  157. package/skills/massa-ai/workflows/onboarding.md +23 -0
  158. package/skills/massa-ai/workflows/refactor.md +47 -0
  159. package/skills/massa-ai/workflows/refinement/furps-refinement.md +81 -0
  160. package/skills/massa-ai/workflows/requirements/requirements-audit.md +114 -0
  161. package/skills/massa-ai/workflows/requirements/requirements-fix.md +93 -0
  162. package/skills/massa-ai/workflows/rfc.md +55 -0
  163. package/skills/massa-ai/workflows/security/security-audit.md +113 -0
  164. package/skills/massa-ai/workflows/security/security-fix.md +97 -0
  165. package/skills/massa-ai/workflows/spec-driven.md +217 -0
  166. package/skills/massa-ai/workflows/tdd.md +71 -0
  167. package/skills/massa-ai/workflows/tests/tests-audit.md +114 -0
  168. package/skills/massa-ai/workflows/tests/tests-fix.md +96 -0
  169. package/skills/massa-ai/workflows/the-fool.md +82 -0
  170. package/skills/massa-ai/workflows/ticket.md +42 -0
  171. package/skills/persona-router/SKILL.md +158 -0
  172. package/skills/status/SKILL.md +15 -0
@@ -0,0 +1,459 @@
1
+ # Audit Report I/O
2
+
3
+ Use this reference from audit workflows before writing reports and from execution workflows before report-driven changes.
4
+
5
+ ## Report Paths
6
+
7
+ Direct single-lens audits save under the target project root:
8
+
9
+ ```text
10
+ audits/<workflow>/<YYYY-MM-DD <workflow>-audit>.md
11
+ ```
12
+
13
+ Supported single-lens workflow directories are `architecture`, `code-quality`, `security`, `requirements`, `tests`, and `bugs`.
14
+
15
+ ```text
16
+ audits/architecture/2026-06-15 architecture-audit.md
17
+ audits/code-quality/2026-06-15 code-quality-audit.md
18
+ audits/security/2026-06-15 security-audit.md
19
+ audits/requirements/2026-06-15 requirements-audit.md
20
+ audits/tests/2026-06-15 tests-audit.md
21
+ audits/bugs/2026-06-15 bugs-audit.md
22
+ ```
23
+
24
+ Parent implementation audits, mobile Figma audits, and Maestro audits use dedicated paths:
25
+
26
+ ```text
27
+ audits/implementation/<YYYY-MM-DD implementation-audit.md>
28
+ audits/mobile-figma/<YYYY-MM-DD mobile-figma-audit.md>
29
+ audits/maestro/<YYYY-MM-DD maestro-audit.md>
30
+ ```
31
+
32
+ Use the local current date. Create the required directory when missing. Do not silently overwrite a different run; ask the user or choose a deterministic suffix and state the deviation. Suffix rule: use `-2`, `-3`, etc. for same-day same-target collisions in one session; use `-<HHMMSS>` only when existing files do not reveal a stable sequence.
33
+
34
+ ## Report Schema v2 Determinism
35
+
36
+ Apply these rules to every saved audit report and every execution workflow that consumes one:
37
+
38
+ - Drift invalidates a finding when the file is missing, the evidence line changed, base/head changed, resolved files no longer match the target, or the finding cannot be revalidated from current source.
39
+ - Ruled-out candidates are included only when their pre-disproof severity was `high` or `critical`, or confidence was `medium` or `high`.
40
+ - Low-confidence suspects stay in Scope And Evidence unless the user explicitly asks to investigate them.
41
+ - A report selector without workflow, target, target focus, scope, base/head or `n/a`, evidence timestamp, material files/evidence, commands/searches, skipped checks, and residual risk is invalid input for execution.
42
+
43
+ Child lenses invoked by implementation audit return compact findings to the parent unless explicitly asked to save independent reports.
44
+
45
+ ## Verification/Test Fidelity Checklist
46
+
47
+ Every audit report and every compact child-lens result must include a Verification/Test Fidelity Checklist. The checklist is the proof layer for findings, no-finding conclusions, skipped checks, and execution handoff readiness.
48
+
49
+ Required checklist fields:
50
+
51
+ | Item | Required Evidence |
52
+ |---|---|
53
+ | Deterministic sensor | Exact command, static scan, artifact inspection, runtime/render sensor, or `not available` with reason |
54
+ | Result | `pass`, `fail`, `not run`, or `not applicable` |
55
+ | Coverage target | Finding ID, no-finding claim, requirement, behavior, surface, file, or validation asset covered |
56
+ | Validation assets protected | Tests, specs, fixtures, snapshots, benchmarks, public contracts, generated baselines, or `none` |
57
+ | Skipped-check reason | `none`, `too-expensive`, `needs-network`, `needs-credentials`, `destructive-risk`, `outside-scope`, `tool-missing`, or `not-applicable` |
58
+ | Execution handoff | Verification command/artifact and validation assets to re-run for every actionable finding |
59
+
60
+ Model judgment alone cannot satisfy the Verification/Test Fidelity Checklist. If no deterministic sensor exists, the report must state the missing sensor and residual risk instead of implying verification/testing all-clear.
61
+
62
+ Child lenses invoked by implementation audit return this checklist to the parent. Parent implementation reports preserve child checklist evidence in the lens coverage matrix, Scope And Evidence, and Execution Handoff.
63
+
64
+ ## Plan Mode Save Rule
65
+
66
+ In Plan Mode, do not write report files. Return the proposed canonical path and complete report content.
67
+
68
+ In Default mode, write the canonical report unless acting as a child lens returning compact findings to implementation audit.
69
+
70
+ ## Single-Lens Report Contract
71
+
72
+ ```md
73
+ # <Workflow> Audit
74
+
75
+ Date: <YYYY-MM-DD>
76
+ Workflow: architecture | code-quality | security | requirements | tests | bugs
77
+ ProjectId: <projectId>
78
+ WorkflowSessionId: <workflowSessionId>
79
+ Target: <target>
80
+ Target Focus: <path, module, branch comparison, commits, symbol, feature, flow, changed-file set, or prompt target>
81
+ Scope: <modified files | explicit files/globs | commit range | branch comparison | codebase area | symbol/class/function | feature/flow | PR diff>
82
+ Git Base: <sha/ref or n/a>
83
+ Git Head: <sha/ref, working-tree, or n/a>
84
+ Source Evidence Timestamp: <YYYY-MM-DD HH:MM local time, or unavailable>
85
+ Requirements Source: <requirements-only, when applicable or n/a>
86
+
87
+ ## Findings
88
+
89
+ ### <PREFIX-N>: <short title>
90
+
91
+ Severity: critical | high | medium | low
92
+ Confidence: high | medium | low
93
+ Location: <path:line or module>
94
+ Evidence: <concrete source evidence>
95
+ Impact: <risk or cost>
96
+ Simplest Fix Direction: <smallest sufficient change>
97
+ Verification Suggestion: <deterministic command, test, or artifact check>
98
+
99
+ ## Ruled-Out Candidates
100
+
101
+ <Plausible candidates disproved by evidence, or "None">
102
+
103
+ ## Scope And Evidence
104
+
105
+ <Files, commands, searches, skipped checks, and residual risk>
106
+
107
+ ## Verification/Test Fidelity Checklist
108
+
109
+ | Item | Evidence |
110
+ |---|---|
111
+ | Deterministic sensor | <command, static scan, artifact inspection, runtime/render sensor, or not available with reason> |
112
+ | Result | <pass, fail, not run, or not applicable> |
113
+ | Coverage target | <finding ID, no-finding claim, requirement, behavior, surface, file, or validation asset> |
114
+ | Validation assets protected | <tests, specs, fixtures, snapshots, benchmarks, public contracts, generated baselines, or none> |
115
+ | Skipped-check reason | <none or allowed skipped-check reason> |
116
+ | Execution handoff | <verification command/artifact and validation assets for every actionable finding> |
117
+
118
+ ## Execution Handoff
119
+
120
+ <Ordered actionable IDs, dependencies, validation assets, verification, and cautions>
121
+ ```
122
+
123
+ Single-lens finding prefixes:
124
+
125
+ | Workflow | Prefix |
126
+ |---|---|
127
+ | Code Quality | `CQ-` |
128
+ | Architecture | `ARCH-` |
129
+ | Security | `SEC-` |
130
+ | Requirements | `REQ-` |
131
+ | Tests | `TST-` |
132
+ | Bugs | `BUG-` |
133
+
134
+ ## Coupling Finding Extension
135
+
136
+ Architecture findings that report coupling carry these extra fields so the
137
+ three-dimensional verdict is reproducible, not scattered prose:
138
+
139
+ - Coupling Dimensions: `S=<High|Low> D=<High|Low> V=<High|Low>`
140
+ - Balance Score: `<0 | 1>` — from `BALANCE = (S XOR D) OR (NOT V)`
141
+ - Maintenance Effort: `<0 | 1>` — from `MAINTENANCE_EFFORT = S * D * V`
142
+ - Connascence: `<Name | Type | Meaning | Position | Algorithm>`
143
+ - Symmetric: `<yes | no>` — duplicated rule with no import edge
144
+
145
+ Record all five even when the edge is healthy; the Balance Score is the
146
+ prioritization signal handed off to `architecture-fix`.
147
+
148
+ ## Implementation Audit Report Contract
149
+
150
+ ```md
151
+ # Implementation Audit
152
+
153
+ Date: <YYYY-MM-DD>
154
+ Workflow: implementation-audit
155
+ ProjectId: <projectId>
156
+ WorkflowSessionId: <implementation-audit-[entity]>
157
+ Target: <implementation target>
158
+ Target Focus: <modified files, files/globs, commits, branch/PR comparison, module, symbol, feature, flow, or whole repository>
159
+ Scope: <scope type from audit-scope.md>
160
+ Git Base: <sha/ref or n/a>
161
+ Git Head: <sha/ref, working-tree, or n/a>
162
+ Source Evidence Timestamp: <YYYY-MM-DD HH:MM local time, or unavailable>
163
+ Requirements Source: <source description or n/a>
164
+
165
+ ## Lens Coverage Matrix
166
+
167
+ | Lens | Status | Scope Checked | Evidence | Skipped Check Reason |
168
+ |---|---|---|---|---|
169
+
170
+ ## Findings
171
+
172
+ ### <Source Lens>/<Original ID>: <short title>
173
+
174
+ Severity: critical | high | medium | low
175
+ Confidence: high | medium | low
176
+ Source Lens: Correctness | Architecture | Code Quality | Security | Requirements | Tests
177
+ Original Finding ID: BUG-1 | ARCH-1 | CQ-1 | SEC-1 | REQ-1 | TST-1
178
+ Location: <path:line or module>
179
+ Evidence: <concrete source evidence>
180
+ Impact: <risk or cost>
181
+ Simplest Fix Direction: <smallest sufficient change>
182
+ Verification Suggestion: <deterministic command, test, or artifact check>
183
+
184
+ ## Ruled-Out Candidates
185
+
186
+ <Plausible candidates disproved by evidence, or "None">
187
+
188
+ ## Scope And Evidence
189
+
190
+ <Immutable implementation scope packet, commands, searches, skipped checks, and residual risk>
191
+
192
+ ## Verification/Test Fidelity Checklist
193
+
194
+ | Item | Evidence |
195
+ |---|---|
196
+ | Deterministic sensor | <child lens command, static scan, artifact inspection, runtime/render sensor, or not available with reason> |
197
+ | Result | <pass, fail, not run, or not applicable> |
198
+ | Coverage target | <source-qualified finding ID, no-finding claim, requirement, behavior, file, or validation asset> |
199
+ | Validation assets protected | <tests, specs, fixtures, snapshots, benchmarks, public contracts, generated baselines, or none> |
200
+ | Skipped-check reason | <none or allowed skipped-check reason> |
201
+ | Execution handoff | <verification command/artifact and validation assets for every actionable finding> |
202
+
203
+ ## Execution Handoff
204
+
205
+ <Ordered source-qualified IDs, dependencies, likely files, validation assets, verification commands, and cautions>
206
+ ```
207
+
208
+ ### Source-Qualified Finding IDs
209
+
210
+ Every implementation-audit finding carries a **source-qualified ID** of the form `<Area>/<PREFIX>-<N>`. The Area qualifies which source lens produced the finding; the `PREFIX-N` keeps ordering within that area. This discipline is mandatory because implementation-audit spans a broader scope than a single PR diff, so the source lens must survive into execution for traceability and revalidation.
211
+
212
+ Canonical area/prefix pairs:
213
+
214
+ | Area | Prefix | Example |
215
+ |---|---|---|
216
+ | Correctness | `BUG-` | `Correctness/BUG-1` |
217
+ | Architecture | `ARCH-` | `Architecture/ARCH-1` |
218
+ | Code Quality | `CQ-` | `Code Quality/CQ-1` |
219
+ | Security | `SEC-` | `Security/SEC-2` |
220
+ | Requirements | `REQ-` | `Requirements/REQ-1` |
221
+ | Tests | `TST-` | `Tests/TST-1` |
222
+
223
+ Rules:
224
+
225
+ - The `<Area>` segment must match one of the supported source lenses above; do not invent new areas or use bare `PREFIX-N` IDs in implementation reports.
226
+ - The `<PREFIX>` must match the lens's single-lens prefix; do not mix (e.g., never `Security/BUG-1`).
227
+ - Preserve the same source-qualified ID verbatim from audit through `implementation-fix` execution and the closure matrix.
228
+ - SonarQube-derived findings must normalize to one of these source-qualified IDs before entering Findings or Execution Handoff; raw `SONAR-*` output is evidence only.
229
+
230
+ This `audit-report-io.md` section is the canonical home for the source-qualified ID discipline. `implementation-audit.md` and `implementation-fix.md` restate the `Area/PREFIX-N` requirement and point here rather than duplicating the table.
231
+
232
+ ## Mobile Figma Report Contract
233
+
234
+ ```md
235
+ # Mobile Figma Audit
236
+
237
+ Date: <YYYY-MM-DD>
238
+ Workflow: mobile-figma-audit
239
+ ProjectId: <projectId>
240
+ WorkflowSessionId: <mobile-figma-audit-[entity]>
241
+ Target: <mobile UI target>
242
+ Target Focus: <feature, files, screen, classes/views/composables, commits, branch comparison, or modified files>
243
+ Scope: <scope type from audit-scope.md>
244
+ Git Base: <sha/ref or n/a>
245
+ Git Head: <sha/ref, working-tree, or n/a>
246
+ Source Evidence Timestamp: <YYYY-MM-DD HH:MM local time>
247
+ Repository Classification: Android | iOS | KMP | monorepo/mixed
248
+ Figma Source: <URL, file key, or desktop selection>
249
+ Figma Evidence Timestamp: <YYYY-MM-DD HH:MM local time>
250
+ Requirements Source: <source description or n/a>
251
+
252
+ ## Target Surface Matrix
253
+
254
+ | Surface ID | Module/Source Set | UI Stack | Detection Evidence | Figma Node | Runtime Targets | Status |
255
+ |---|---|---|---|---|---|---|
256
+
257
+ Supported UI stacks: Android Views XML, Android Jetpack Compose, iOS UIKit, iOS SwiftUI, and KMP Compose Multiplatform. Mixed KMP reports add applicable native host/source-set rows instead of labeling every Compose surface as shared.
258
+
259
+ ## Platform Comparison Configurations
260
+
261
+ ### <Surface ID>
262
+
263
+ <Fixed stack-specific viewport/device, density or display scale, orientation, OS/API, traits/theme, locale, text scaling, safe-area/inset assumptions, build variant/scheme, and content state>
264
+
265
+ ## Capability Matrix
266
+
267
+ | Surface ID | Capability | Status | Evidence | Limitation |
268
+ |---|---|---|---|---|
269
+
270
+ ## Comparison Matrix
271
+
272
+ | ID | Surface ID | Element/State | Property/Constraint | Figma Value | Resolved Implementation Value | Runtime Evidence | Evidence Class | Status | Confidence | Fix Direction |
273
+ |---|---|---|---|---|---|---|---|---|---|---|
274
+
275
+ ## Findings
276
+
277
+ ### MFM-<N>: <short title>
278
+
279
+ Severity: critical | high | medium | low
280
+ Confidence: high | medium | low
281
+ Surface ID: <surface ID from Target Surface Matrix>
282
+ UI Stack: Android Views XML | Android Jetpack Compose | iOS UIKit | iOS SwiftUI | KMP Compose Multiplatform
283
+ Module/Source Set: <module and source-set evidence>
284
+ Element/State: <element and state>
285
+ Property/Constraint: <property or behavior>
286
+ Figma Value: <resolved design value>
287
+ Resolved Implementation Value: <resource/token/asset chain and final value>
288
+ Runtime Evidence: <measurement, artifact, or unavailable>
289
+ Evidence Class: deterministic-source | deterministic-runtime | inferential-visual | missing
290
+ Platform Configuration: <surface configuration used>
291
+ Location: <path:line or module>
292
+ Impact: <visual, interaction, accessibility, or maintenance impact>
293
+ Simplest Fix Direction: <smallest sufficient change>
294
+ Verification Suggestion: <deterministic sensor and optional Maestro reproduction>
295
+
296
+ ## Constraint Deviations
297
+
298
+ <Documented accessibility, platform, localization, system UI, or product deviations>
299
+
300
+ ## Not Evaluated
301
+
302
+ <Rows and capabilities lacking safe or sufficient evidence>
303
+
304
+ ## Scope And Evidence
305
+
306
+ <Figma packet and surface mappings, target modules/source sets, per-surface files/resources, render sensors, optional Maestro metadata/artifacts, skipped checks, and residual risk>
307
+
308
+ ## Verification/Test Fidelity Checklist
309
+
310
+ | Item | Evidence |
311
+ |---|---|
312
+ | Deterministic sensor | <Figma MCP evidence, source value resolution, static render check, screenshot/runtime sensor, Maestro artifact, or not available with reason> |
313
+ | Result | <pass, fail, not run, or not applicable> |
314
+ | Coverage target | <MFM ID, no-finding claim, surface ID, comparison row, behavior, file, or validation asset> |
315
+ | Validation assets protected | <screenshot tests, previews, fixtures, snapshots, test tags/selectors, resources, public contracts, or none> |
316
+ | Skipped-check reason | <none or allowed skipped-check reason> |
317
+ | Execution handoff | <verification command/artifact, platform configuration, and validation assets for every actionable mismatch> |
318
+
319
+ ## Execution Handoff
320
+
321
+ <Ordered MFM IDs and surface IDs, shared/platform root fixes, likely files, protected validation assets, configurations, verification, and Maestro reproduction packets when present>
322
+ ```
323
+
324
+ Only `MISMATCH` comparison rows become `MFM-*` findings. `CONSTRAINT DEVIATION` and `NOT EVALUATED` rows are never silently promoted to executable findings.
325
+
326
+ ## Maestro Audit Report Contract
327
+
328
+ ```md
329
+ # Maestro Audit
330
+
331
+ Date: <YYYY-MM-DD>
332
+ Workflow: maestro-audit
333
+ ProjectId: <projectId>
334
+ WorkflowSessionId: <maestro-audit-[entity]>
335
+ Target: <Maestro target>
336
+ Target Focus: <flow root, suite, tag, app/module, platform, commit range, branch comparison, or modified files>
337
+ Scope: <scope type from audit-scope.md>
338
+ Git Base: <sha/ref or n/a>
339
+ Git Head: <sha/ref, working-tree, or n/a>
340
+ Source Evidence Timestamp: <YYYY-MM-DD HH:MM local time, or unavailable>
341
+ Scenario Source: <Jira/Confluence, local file, prompt text, explored/inferred behavior, or n/a>
342
+ Maestro CLI: <version/help result or unavailable with reason>
343
+ Device/Emulator Readiness: <command/result or unavailable with reason>
344
+
345
+ ## Flow Inventory
346
+
347
+ | Flow ID | Path | Suite/Tag | Platform | Setup/Teardown | Scenario Source | Status |
348
+ |---|---|---|---|---|---|---|
349
+
350
+ ## Maestro Run Matrix
351
+
352
+ | Flow ID | Command | Exit Status | Result | JUnit Report | Artifact Directory | Device/Platform | Skipped-Check Reason |
353
+ |---|---|---|---|---|---|---|---|
354
+
355
+ ## Scenario Coverage Matrix
356
+
357
+ | Scenario ID | Source | Expected Behavior | Covered Flow ID | Evidence | Gap |
358
+ |---|---|---|---|---|---|
359
+
360
+ ## Findings
361
+
362
+ ### MST-<N>: <short title>
363
+
364
+ Severity: critical | high | medium | low
365
+ Confidence: high | medium | low
366
+ Flow/Subflow: <flow ID and path>
367
+ Scenario Source: <source identifier>
368
+ Location: <path:line or module>
369
+ Evidence: <concrete source, report, or artifact evidence>
370
+ Impacted Journey: <user journey or release smoke path>
371
+ Flake Or Coverage Risk: <risk class and impact>
372
+ Simplest Fix Direction: <smallest sufficient Maestro flow, fixture, setup, teardown, or test-data change>
373
+ Verification Suggestion: <Maestro command, JUnit report check, artifact inspection, or static check>
374
+
375
+ ## Ruled-Out Candidates
376
+
377
+ <Plausible candidates disproved by evidence, or "None">
378
+
379
+ ## Scope And Evidence
380
+
381
+ <Flow roots, scenario sources, commands/searches, exit statuses, JUnit reports, artifact directories, skipped checks, validation assets, and residual risk>
382
+
383
+ ## Verification/Test Fidelity Checklist
384
+
385
+ | Item | Evidence |
386
+ |---|---|
387
+ | Deterministic sensor | <Maestro command, JUnit report, artifact inspection, static YAML/config scan, or not available with reason> |
388
+ | Result | <pass, fail, not run, or not applicable> |
389
+ | Coverage target | <MST ID, no-finding claim, scenario, flow, behavior, file, or validation asset> |
390
+ | Validation assets protected | <flows, subflows, fixtures, setup/teardown, test data, snapshots, CI report consumers, or none> |
391
+ | Skipped-check reason | <none or allowed skipped-check reason> |
392
+ | Execution handoff | <verification command/artifact and validation assets for every actionable MST finding> |
393
+
394
+ ## Execution Handoff
395
+
396
+ <Ordered MST IDs, dependencies, likely files, protected validation assets, verification commands, artifact expectations, and cautions>
397
+ ```
398
+
399
+ Only executable flow, fixture, setup/teardown, test-data, or directly scoped Maestro CI/report issues become `MST-*` findings. App bugs, product behavior gaps, backend defects, and unclear requirements must route to `debug`, `feature`, or `requirements-audit` instead of `maestro-fix`.
400
+
401
+ ## Required Finding Fields
402
+
403
+ All findings require severity, confidence, location, concrete evidence, impact, smallest fix direction, and verification suggestion. Workflow-specific fields are mandatory:
404
+
405
+ | Workflow | Required Extra Fields |
406
+ |---|---|
407
+ | Code Quality | `Rule`, `Current Shape`, `Simplest Safe Transformation` |
408
+ | Architecture | `Lens`, `Boundary/Module`, `Tradeoff`, `Dependency Direction` when relevant |
409
+ | Security | `Security Boundary`, `Asset`, `Trigger or Exploit Path`, `Negative Test Direction` |
410
+ | Requirements | `Requirement Source`, `Requirement ID or Quote`, `Requirement Gap Type` |
411
+ | Tests | `Impacted Behavior`, `Regression Risk`, `Simplest Test Direction`, `Deterministic Sensor` |
412
+ | Bugs | `Bug Class`, `Impacted Flow`, `Trigger or Repro Path`, `Root Cause Hypothesis`, `Regression Risk` |
413
+ | Mobile Figma | `Surface ID`, `UI Stack`, `Module/Source Set`, `Element/State`, `Property/Constraint`, `Figma Value`, `Resolved Implementation Value`, `Runtime Evidence`, `Evidence Class`, `Platform Configuration` |
414
+ | Maestro | `Flow/Subflow`, `Scenario Source`, `Impacted Journey`, `Flake Or Coverage Risk` |
415
+
416
+ If a required field is unknown, write `Unknown` and explain the evidence gap. Execution treats unknown required fields as a stop condition unless the user explicitly accepts the risk after revalidation.
417
+
418
+ ## Freshness Metadata
419
+
420
+ Every report must include project, workflow, target, target focus, scope, git base/head or `n/a`, source evidence timestamp, material files/evidence, commands/searches, skipped checks, and residual risk.
421
+
422
+ Implementation reports must preserve the exact parent scope packet and source-qualified findings. Mobile Figma reports must also preserve repository classification, Target Surface Matrix, Figma identity/mappings/timestamp, per-surface platform configurations, capability matrix, complete comparison matrix, and optional Maestro reproduction metadata. Maestro reports must preserve scenario source, flow inventory, Maestro run matrix, JUnit report path, artifact directory, device/emulator readiness, and execution handoff for `MST-*` findings.
423
+
424
+ When implementation-audit uses SonarQube MCP, preserve the MCP availability result, project key or skipped-check reason, quality gate status when available, tool names used, and summarized issue/security-hotspot/measure evidence in Scope And Evidence. Sonar-derived findings are executable only after they are normalized to existing source-qualified IDs for Architecture, Correctness/Bugs, Code Quality, Security, or Tests; unmapped SonarQube output remains evidence only and does not enter Execution Handoff.
425
+
426
+ ## Execution Report Input
427
+
428
+ Execution workflows read a saved markdown report before changing code. Establish:
429
+
430
+ - Report selector: exact path, `latest`, or omitted.
431
+ - Target focus: module, flow, files/globs, branch comparison, commit range, PR target, symbol/class/function, feature/screen, modified files, or explicit whole-repository target.
432
+ - Finding selector: optional workflow IDs or source-qualified implementation IDs.
433
+
434
+ If a path is supplied, use it and validate it against any stated focus. For `latest` or omitted paths, require a concrete focus before selecting from the matching directory.
435
+
436
+ Select the latest matching report by:
437
+
438
+ 1. Highest `YYYY-MM-DD` parsed from matching filenames.
439
+ 2. Most recent mtime as tie-breaker.
440
+ 3. Lexicographically last path if still tied.
441
+
442
+ Specialized selection rules:
443
+
444
+ - `implementation-fix` selects only `audits/implementation/* implementation-audit.md` with `Workflow: implementation-audit`.
445
+ - `mobile-figma-fix` selects only `audits/mobile-figma/* mobile-figma-audit.md` with `Workflow: mobile-figma-audit`.
446
+ - `maestro-fix` selects only `audits/maestro/* maestro-audit.md` with `Workflow: maestro-audit`.
447
+ - Single-lens execution selects only its matching workflow directory and metadata.
448
+
449
+ Before editing:
450
+
451
+ - Verify workflow, project, target, target focus, scope, base/head, and resolved files match the current request.
452
+ - Reinspect each finding's current location and evidence. Stop or re-audit when schema v2 drift rules invalidate any selected finding.
453
+ - Verify every finding has common and workflow-specific fields plus the correct ID form.
454
+ - For implementation reports, require source-qualified IDs and child-lens fields.
455
+ - For mobile Figma reports, re-read the Figma node and reject stale design/source/configuration evidence.
456
+ - Ignore ruled-out candidates, skipped checks, no-finding summaries, `NOT EVALUATED` rows, constraint deviations, and low-confidence suspects unless the user explicitly changes scope after revalidation.
457
+ - Build verification from report suggestions plus current project sensors.
458
+
459
+ Do not execute from chat summaries, inline comments, screenshots alone, or remembered audit content. The saved markdown report is the source of truth.
@@ -0,0 +1,103 @@
1
+ # Audit Scope
2
+
3
+ Use this reference from audit workflows, implementation audit, bug finder, mobile Figma, and execution workflows before inspecting changed code or selecting an audit report.
4
+
5
+ ## Scope Packets
6
+
7
+ Every audit scope must produce a compact scope packet before analysis:
8
+
9
+ ```text
10
+ Scope Type: <modified files | explicit files/globs | commit range | branch comparison | codebase area | symbol/class/function | feature/flow | PR diff>
11
+ Target Focus: <path, module, branch comparison, commits, symbol, feature, flow, PR, changed-file set, or prompt target>
12
+ Resolution Method: <commands, tools, or user-supplied packet used to resolve scope>
13
+ Git Base: <sha/ref or n/a>
14
+ Git Head: <sha/ref or working-tree>
15
+ Resolved Files: <explicit list or pointer to summarized list>
16
+ Diff Source: <command, PR URL, supplied diff, or user-provided file set>
17
+ Excluded Paths: <generated/dependency/build/log/cache/temp/secret paths removed>
18
+ Requirements Source: <requirements-only, when applicable>
19
+ Freshness Checked At: <YYYY-MM-DD HH:MM local time, or unavailable>
20
+ ```
21
+
22
+ Pass the same packet to child audit lenses. Child workflows must not silently recompute a different base or broaden scope beyond the packet.
23
+
24
+ ## Target Intake Rules
25
+
26
+ Direct audit workflows require a concrete target focus before analysis. Accepted targets include modified files, explicit files or globs, commit hashes or commit ranges, branch comparisons, modules/packages, feature areas, classes/functions/symbols, runtime flows, or an explicitly requested whole-repo audit.
27
+
28
+ If the target is missing, vague, or too broad to inspect without guessing, stop and ask for a target focus. Do not default to a whole-repo audit. Whole-repo audits are valid only when the user explicitly asks for the whole repository and accepts the broader cost and lower precision.
29
+
30
+ Requirements audits also require a requirements source: prompt text, spec, issue/task, PR description, ADR/RFC, acceptance criteria, README/docs section, or another explicit source of expected behavior. If no requirements source can be found from the prompt or supplied context, stop and ask for it.
31
+
32
+ Execution workflows require both a report selector and a target focus before editing:
33
+
34
+ - Exact audit report path plus optional finding IDs is preferred.
35
+ - If the user asks for "latest" or omits a report path, first confirm a target focus such as module, flow, files, branch comparison, commit range, or PR target.
36
+ - Select the latest report only from the matching workflow directory, then verify report metadata matches the target focus before editing.
37
+ - If report target, scope, base/head, resolved files, or current evidence drift from the user's target focus, stop before editing unless the user explicitly accepts the risk.
38
+
39
+ ## Audit Budgets
40
+
41
+ Use these default budgets unless the user explicitly expands scope:
42
+
43
+ | Scope size | Files / LOC / modules | Default context depth | Delegation trigger |
44
+ |---|---|---|---|
45
+ | Small | <=3 files, <=200 changed LOC, one module | touched lines plus direct callers/callees only | no delegation unless user requests it |
46
+ | Medium | 4-10 files or <=500 changed LOC in one ownership area | one-hop references, tests, config, and public surfaces | delegate only for independent verification or high/critical candidate findings |
47
+ | Large | >10 files, >500 changed LOC, >2 modules, whole-repo, or cross-boundary scope | top-level map first, then one-hop depth for selected high-risk entry points | delegation only when explicit request, >=2 disjoint slices, or high/critical findings exist |
48
+
49
+ Whole-repo audits start with top-level mapping and central entry points. They must report skipped depth checks instead of implying exhaustive line-by-line coverage.
50
+
51
+ ## Scope Resolution
52
+
53
+ Use the smallest scope type that matches the user's target:
54
+
55
+ - Modified files: staged, unstaged, and relevant untracked files in the working tree. Use `working-tree` as head and record the status/diff commands used.
56
+ - Explicit files/globs: user-provided paths or globs. Resolve to concrete files; ask if nothing matches or if the glob expands beyond the intended target.
57
+ - Commit range: user-provided commit hash, commit list, or revision range. Record the exact range, base/head when available, changed files, and diff command.
58
+ - Branch comparison: user-provided base/head branch or ref comparison. Resolve base/head with the branch diff rules below and record changed files.
59
+ - Codebase area: module, package, directory, service, bounded context, or feature area. Resolve entry points, exported surfaces, tests, config, and adjacent docs only as needed.
60
+ - Symbol/class/function: locate definitions and references with massa-ai symbol
61
+ tools, targeted enriched search, or focused fallback; use `read_file`
62
+ for exact ranges and include defining files, callers, tests, and configs
63
+ needed to verify claims.
64
+ - Feature/flow: map entry points through main transformations and side effects; ask for a narrower flow when the feature spans too many unrelated surfaces.
65
+ - Implementation parent scope: accept the exact packet supplied by `workflows/implementation/implementation-audit.md`, including PR diff when that is the selected scope type; child lenses must not broaden it without parent approval.
66
+
67
+ ## Branch, Commit, And PR Diff Resolution
68
+
69
+ Use this order:
70
+
71
+ 1. Explicit user-provided commit range, branch/PR base and head, diff, or changed-file set.
72
+ 2. Upstream merge-base for the active branch.
73
+ 3. Fallback bases in order: `origin/main`, `origin/master`, `main`, `master`.
74
+
75
+ Stop and ask when no base can be resolved, multiple plausible bases exist, commit/branch syntax is invalid, or the working tree/branch state makes the target ambiguous. Do not invent a base. Record the selected base/head in the scope packet and in any saved audit report.
76
+
77
+ ## File Inclusion
78
+
79
+ Include files that can affect the audited behavior, including source, tests, fixtures, schemas, migrations, config, docs, and packaging metadata when they define behavior or public contracts.
80
+
81
+ Exclude generated, dependency, build, log, cache, temporary, and secret paths according to repo rules. Deleted files stay in scope only when their removal can break imports, exports, routing, migrations, config, tests, packaging, docs, policies, or public contracts.
82
+
83
+ Inspect diffs first when a diff exists. For non-diff scopes, inspect the resolved entry points first. Read surrounding code only to prove or disprove a concrete candidate finding.
84
+
85
+ ## Memory Freshness Gate
86
+
87
+ Recalled memories, accepted exceptions, prior ADR interpretations, and previous audit decisions are leads, not proof.
88
+
89
+ Before suppressing or downgrading a finding because of memory:
90
+
91
+ - Confirm the memory is not tagged `stale` and is not superseded by `stale-replaces:*`.
92
+ - Corroborate it against current code, current ADRs/specs, or the current audit report evidence.
93
+ - Check whether newer code, requirements, or incidents invalidate the exception.
94
+ - If corroboration is missing, keep the candidate alive as `suspect` or report the evidence gap instead of treating memory as authoritative.
95
+
96
+ ## Context Firewall
97
+
98
+ Summarize large diffs, logs, generated reports, snapshots, and broad search output before using them in the main context. Keep raw verbose output out of child-agent and final-report payloads unless a short excerpt is necessary as evidence.
99
+
100
+ When an audit requires repeated massa-ai searches, use the shared Synapse policy.
101
+ Each parallel audit lens receives an isolated `synapseSessionId`; all lenses
102
+ retain the parent/child durable `workflowSessionId` tags and the same scope
103
+ packet.
@@ -0,0 +1,111 @@
1
+ # Code Annotation And Test Coverage
2
+
3
+ Use this reference in every implementation workflow, before writing or editing
4
+ source. It defines the three things every created or updated unit of code owes
5
+ the next reader: an API doc block, a rationale comment, and a test.
6
+
7
+ ## Principle
8
+
9
+ The next person to open this code — often a future agent with none of this
10
+ session's context — must be able to answer three questions from the file alone:
11
+ what does it do, why does it exist in this shape, and how do I prove it still
12
+ works. Doc blocks answer the first, rationale comments the second, tests the
13
+ third. None substitutes for another.
14
+
15
+ ## 1. API Doc Block
16
+
17
+ Every **created or updated** public class, method, exported function, and public
18
+ type gets a language-native documentation block. "Updated" is the trigger too:
19
+ if the behavior changed, the doc that described the old behavior is now wrong.
20
+
21
+ | Language | Syntax | Notes |
22
+ | --- | --- | --- |
23
+ | Java | JavaDoc `/** */` | `@param`, `@return`, `@throws` |
24
+ | Kotlin | KDoc `/** */` | `@param`, `@return`, `@throws`, `@sample` |
25
+ | TypeScript / JavaScript | TSDoc `/** */` | `@param`, `@returns`, `@throws`; no redundant types |
26
+ | Python | docstring `"""..."""` | follow the project's existing convention (Google / NumPy / reST) |
27
+ | Swift | `///` | `- Parameter`, `- Returns`, `- Throws` |
28
+ | Rust | `///` and `//!` | `# Arguments`, `# Returns`, `# Panics`, `# Examples` |
29
+ | Go | `// Name ...` above the declaration | starts with the identifier name |
30
+ | C# | `///` XML | `<summary>`, `<param>`, `<returns>` |
31
+ | Ruby | YARD `#` | `@param`, `@return`, `@raise` |
32
+ | PHP | PHPDoc `/** */` | `@param`, `@return`, `@throws` |
33
+ | Shell | header comment block | usage, arguments, exit codes |
34
+ | SQL | `--` header | purpose, inputs, side effects |
35
+
36
+ Rules:
37
+
38
+ - Match the file's existing style. A repo that uses one-line docstrings does not
39
+ want a Google-format block bolted onto one function.
40
+ - Document the **contract**: inputs, output, errors, side effects, and any
41
+ invariant a caller must hold. Not the line-by-line implementation.
42
+ - Do not restate what the signature already says. `@param userId The user id` is
43
+ noise; `@param userId Must be an active account; throws for soft-deleted users`
44
+ is a contract.
45
+ - Private helpers need a doc block only when their contract is non-obvious.
46
+
47
+ ## 2. Rationale Comment
48
+
49
+ Doc blocks describe the contract. They do not explain why the code changed. Add
50
+ a rationale block once at the changed unit — the class, the method, or the
51
+ enclosing block — not on every line.
52
+
53
+ The three required fields:
54
+
55
+ ```
56
+ // Why: <the problem this solves, or the bug it fixes>
57
+ // Impacts: <the feature, requirement ID, or user-visible behavior it serves>
58
+ // Test: <the exact command or test name that exercises it>
59
+ ```
60
+
61
+ Worked example:
62
+
63
+ ```ts
64
+ /**
65
+ * Resolves the effective vector store for a project.
66
+ *
67
+ * @param projectId - Project whose store is requested.
68
+ * @returns The configured store, or the in-memory fallback when pgvector is unreachable.
69
+ * @throws {ConfigError} When the project id is unknown.
70
+ */
71
+ // Why: cold-start indexing crashed when pgvector was still booting, so the
72
+ // factory must degrade instead of throwing.
73
+ // Impacts: WHO-R9 offline-first indexing; affects `index` and `reindex`.
74
+ // Test: bun test packages/core/src/__tests__/vector-store-factory.test.ts -t "falls back"
75
+ export function getVectorStore(projectId: string): VectorStore {
76
+ ```
77
+
78
+ Use the project's own comment syntax. Keep each field to one line where possible;
79
+ `Why` may run to two when the cause is genuinely non-obvious. If the answer to
80
+ `Why` is "the spec said so", cite the requirement ID — that *is* the reason.
81
+
82
+ ## 3. Tests
83
+
84
+ Every created or updated code path gets test coverage. Not "the module has
85
+ tests" — the specific path you changed.
86
+
87
+ | Change | Required coverage |
88
+ | --- | --- |
89
+ | New function/class | Happy path, each error path, and the boundary of every documented constraint |
90
+ | Changed behavior | A test that fails against the old behavior and passes against the new one |
91
+ | Bug fix (`debug`, `*-fix`) | A regression test at the seam closest to the root cause, written so it **fails before the fix** and passes after |
92
+ | New branch in existing code | One case per branch, including the default/else |
93
+ | Deleted code | Assert the removal where the absence is observable; delete only the tests that tested the deleted contract |
94
+
95
+ Rules:
96
+
97
+ - Tests assert **spec-defined outcomes**, never the implementation's own shape.
98
+ A test that mirrors the code cannot detect that the code is wrong.
99
+ - For a bug fix, run the new test against the unfixed code first. A regression
100
+ test that has never been red proves nothing.
101
+ - Never weaken, skip, delete, or `.only`-narrow an existing test to make a gate
102
+ pass. If an existing test now fails, either the change is wrong or the test
103
+ encoded the bug — decide which, and say which.
104
+ - If no valid test seam exists, document why in the completion report rather
105
+ than silently shipping untested code.
106
+
107
+ ## Completion Evidence
108
+
109
+ Report, per changed unit: doc block present (yes / not-applicable-because), the
110
+ rationale block's `Test:` command, and the test names added or updated with
111
+ their pass/fail transition for bug fixes.