api-tests-coverage 1.0.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 (288) hide show
  1. package/README.md +703 -0
  2. package/config.yaml.example +227 -0
  3. package/dist/action/src/index.d.ts +2 -0
  4. package/dist/action/src/index.d.ts.map +1 -0
  5. package/dist/action/src/index.js +349 -0
  6. package/dist/action/src/prComment.d.ts +34 -0
  7. package/dist/action/src/prComment.d.ts.map +1 -0
  8. package/dist/action/src/prComment.js +146 -0
  9. package/dist/src/ast/astAnalysisOrchestrator.d.ts +36 -0
  10. package/dist/src/ast/astAnalysisOrchestrator.d.ts.map +1 -0
  11. package/dist/src/ast/astAnalysisOrchestrator.js +123 -0
  12. package/dist/src/ast/astTypes.d.ts +105 -0
  13. package/dist/src/ast/astTypes.d.ts.map +1 -0
  14. package/dist/src/ast/astTypes.js +9 -0
  15. package/dist/src/ast/languageAnalyzer.d.ts +46 -0
  16. package/dist/src/ast/languageAnalyzer.d.ts.map +1 -0
  17. package/dist/src/ast/languageAnalyzer.js +9 -0
  18. package/dist/src/ast/languageCapabilities.d.ts +24 -0
  19. package/dist/src/ast/languageCapabilities.d.ts.map +1 -0
  20. package/dist/src/ast/languageCapabilities.js +92 -0
  21. package/dist/src/ast/parseFile.d.ts +16 -0
  22. package/dist/src/ast/parseFile.d.ts.map +1 -0
  23. package/dist/src/ast/parseFile.js +65 -0
  24. package/dist/src/ast/parserRegistry.d.ts +39 -0
  25. package/dist/src/ast/parserRegistry.d.ts.map +1 -0
  26. package/dist/src/ast/parserRegistry.js +66 -0
  27. package/dist/src/buildSummary.d.ts +26 -0
  28. package/dist/src/buildSummary.d.ts.map +1 -0
  29. package/dist/src/buildSummary.js +193 -0
  30. package/dist/src/businessCoverage.d.ts +68 -0
  31. package/dist/src/businessCoverage.d.ts.map +1 -0
  32. package/dist/src/businessCoverage.js +290 -0
  33. package/dist/src/compatibilityCoverage.d.ts +83 -0
  34. package/dist/src/compatibilityCoverage.d.ts.map +1 -0
  35. package/dist/src/compatibilityCoverage.js +501 -0
  36. package/dist/src/config/defaultConfig.d.ts +9 -0
  37. package/dist/src/config/defaultConfig.d.ts.map +1 -0
  38. package/dist/src/config/defaultConfig.js +97 -0
  39. package/dist/src/config/index.d.ts +12 -0
  40. package/dist/src/config/index.d.ts.map +1 -0
  41. package/dist/src/config/index.js +37 -0
  42. package/dist/src/config/loadConfig.d.ts +29 -0
  43. package/dist/src/config/loadConfig.d.ts.map +1 -0
  44. package/dist/src/config/loadConfig.js +135 -0
  45. package/dist/src/config/mergeConfig.d.ts +15 -0
  46. package/dist/src/config/mergeConfig.d.ts.map +1 -0
  47. package/dist/src/config/mergeConfig.js +57 -0
  48. package/dist/src/config/schema.d.ts +15 -0
  49. package/dist/src/config/schema.d.ts.map +1 -0
  50. package/dist/src/config/schema.js +30 -0
  51. package/dist/src/config/types.d.ts +175 -0
  52. package/dist/src/config/types.d.ts.map +1 -0
  53. package/dist/src/config/types.js +9 -0
  54. package/dist/src/config/validateConfig.d.ts +22 -0
  55. package/dist/src/config/validateConfig.d.ts.map +1 -0
  56. package/dist/src/config/validateConfig.js +171 -0
  57. package/dist/src/config.d.ts +168 -0
  58. package/dist/src/config.d.ts.map +1 -0
  59. package/dist/src/config.js +204 -0
  60. package/dist/src/coverage/deep-analysis/callGraph.d.ts +67 -0
  61. package/dist/src/coverage/deep-analysis/callGraph.d.ts.map +1 -0
  62. package/dist/src/coverage/deep-analysis/callGraph.js +275 -0
  63. package/dist/src/coverage/deep-analysis/deepEndpointResolver.d.ts +23 -0
  64. package/dist/src/coverage/deep-analysis/deepEndpointResolver.d.ts.map +1 -0
  65. package/dist/src/coverage/deep-analysis/deepEndpointResolver.js +394 -0
  66. package/dist/src/coverage/deep-analysis/index.d.ts +17 -0
  67. package/dist/src/coverage/deep-analysis/index.d.ts.map +1 -0
  68. package/dist/src/coverage/deep-analysis/index.js +63 -0
  69. package/dist/src/coverage/deep-analysis/resolveAssertions.d.ts +60 -0
  70. package/dist/src/coverage/deep-analysis/resolveAssertions.d.ts.map +1 -0
  71. package/dist/src/coverage/deep-analysis/resolveAssertions.js +121 -0
  72. package/dist/src/coverage/deep-analysis/resolveConstants.d.ts +36 -0
  73. package/dist/src/coverage/deep-analysis/resolveConstants.d.ts.map +1 -0
  74. package/dist/src/coverage/deep-analysis/resolveConstants.js +92 -0
  75. package/dist/src/coverage/deep-analysis/resolveEnums.d.ts +55 -0
  76. package/dist/src/coverage/deep-analysis/resolveEnums.d.ts.map +1 -0
  77. package/dist/src/coverage/deep-analysis/resolveEnums.js +152 -0
  78. package/dist/src/coverage/deep-analysis/resolveMethodChains.d.ts +70 -0
  79. package/dist/src/coverage/deep-analysis/resolveMethodChains.d.ts.map +1 -0
  80. package/dist/src/coverage/deep-analysis/resolveMethodChains.js +152 -0
  81. package/dist/src/coverage/deep-analysis/resolvePaths.d.ts +80 -0
  82. package/dist/src/coverage/deep-analysis/resolvePaths.d.ts.map +1 -0
  83. package/dist/src/coverage/deep-analysis/resolvePaths.js +216 -0
  84. package/dist/src/coverage/deep-analysis/resolveRequestWrappers.d.ts +71 -0
  85. package/dist/src/coverage/deep-analysis/resolveRequestWrappers.d.ts.map +1 -0
  86. package/dist/src/coverage/deep-analysis/resolveRequestWrappers.js +226 -0
  87. package/dist/src/coverage/deep-analysis/symbolTable.d.ts +58 -0
  88. package/dist/src/coverage/deep-analysis/symbolTable.d.ts.map +1 -0
  89. package/dist/src/coverage/deep-analysis/symbolTable.js +230 -0
  90. package/dist/src/coverage/deep-analysis/types.d.ts +122 -0
  91. package/dist/src/coverage/deep-analysis/types.d.ts.map +1 -0
  92. package/dist/src/coverage/deep-analysis/types.js +21 -0
  93. package/dist/src/discovery/fileClassifier.d.ts +50 -0
  94. package/dist/src/discovery/fileClassifier.d.ts.map +1 -0
  95. package/dist/src/discovery/fileClassifier.js +238 -0
  96. package/dist/src/discovery/projectDiscovery.d.ts +66 -0
  97. package/dist/src/discovery/projectDiscovery.d.ts.map +1 -0
  98. package/dist/src/discovery/projectDiscovery.js +287 -0
  99. package/dist/src/endpointCoverage.d.ts +70 -0
  100. package/dist/src/endpointCoverage.d.ts.map +1 -0
  101. package/dist/src/endpointCoverage.js +381 -0
  102. package/dist/src/errorCoverage.d.ts +93 -0
  103. package/dist/src/errorCoverage.d.ts.map +1 -0
  104. package/dist/src/errorCoverage.js +698 -0
  105. package/dist/src/index.d.ts +3 -0
  106. package/dist/src/index.d.ts.map +1 -0
  107. package/dist/src/index.js +1441 -0
  108. package/dist/src/inference/businessRuleInference.d.ts +63 -0
  109. package/dist/src/inference/businessRuleInference.d.ts.map +1 -0
  110. package/dist/src/inference/businessRuleInference.js +268 -0
  111. package/dist/src/inference/integrationFlowInference.d.ts +56 -0
  112. package/dist/src/inference/integrationFlowInference.d.ts.map +1 -0
  113. package/dist/src/inference/integrationFlowInference.js +266 -0
  114. package/dist/src/integrationCoverage.d.ts +72 -0
  115. package/dist/src/integrationCoverage.d.ts.map +1 -0
  116. package/dist/src/integrationCoverage.js +317 -0
  117. package/dist/src/intelligence/index.d.ts +20 -0
  118. package/dist/src/intelligence/index.d.ts.map +1 -0
  119. package/dist/src/intelligence/index.js +105 -0
  120. package/dist/src/intelligence/linkageEngine.d.ts +20 -0
  121. package/dist/src/intelligence/linkageEngine.d.ts.map +1 -0
  122. package/dist/src/intelligence/linkageEngine.js +522 -0
  123. package/dist/src/intelligence/markdownReporter.d.ts +12 -0
  124. package/dist/src/intelligence/markdownReporter.d.ts.map +1 -0
  125. package/dist/src/intelligence/markdownReporter.js +265 -0
  126. package/dist/src/intelligence/riskScoring.d.ts +53 -0
  127. package/dist/src/intelligence/riskScoring.d.ts.map +1 -0
  128. package/dist/src/intelligence/riskScoring.js +181 -0
  129. package/dist/src/intelligence/types.d.ts +121 -0
  130. package/dist/src/intelligence/types.d.ts.map +1 -0
  131. package/dist/src/intelligence/types.js +8 -0
  132. package/dist/src/languageDetection.d.ts +100 -0
  133. package/dist/src/languageDetection.d.ts.map +1 -0
  134. package/dist/src/languageDetection.js +349 -0
  135. package/dist/src/languages/java/index.d.ts +16 -0
  136. package/dist/src/languages/java/index.d.ts.map +1 -0
  137. package/dist/src/languages/java/index.js +103 -0
  138. package/dist/src/languages/java/parser.d.ts +7 -0
  139. package/dist/src/languages/java/parser.d.ts.map +1 -0
  140. package/dist/src/languages/java/parser.js +50 -0
  141. package/dist/src/languages/java/semanticBuilder.d.ts +21 -0
  142. package/dist/src/languages/java/semanticBuilder.d.ts.map +1 -0
  143. package/dist/src/languages/java/semanticBuilder.js +358 -0
  144. package/dist/src/languages/javascript/annotationExtractor.d.ts +20 -0
  145. package/dist/src/languages/javascript/annotationExtractor.d.ts.map +1 -0
  146. package/dist/src/languages/javascript/annotationExtractor.js +94 -0
  147. package/dist/src/languages/javascript/assertionResolver.d.ts +18 -0
  148. package/dist/src/languages/javascript/assertionResolver.d.ts.map +1 -0
  149. package/dist/src/languages/javascript/assertionResolver.js +150 -0
  150. package/dist/src/languages/javascript/callResolver.d.ts +23 -0
  151. package/dist/src/languages/javascript/callResolver.d.ts.map +1 -0
  152. package/dist/src/languages/javascript/callResolver.js +236 -0
  153. package/dist/src/languages/javascript/httpInteractionExtractor.d.ts +23 -0
  154. package/dist/src/languages/javascript/httpInteractionExtractor.d.ts.map +1 -0
  155. package/dist/src/languages/javascript/httpInteractionExtractor.js +205 -0
  156. package/dist/src/languages/javascript/index.d.ts +20 -0
  157. package/dist/src/languages/javascript/index.d.ts.map +1 -0
  158. package/dist/src/languages/javascript/index.js +136 -0
  159. package/dist/src/languages/javascript/parser.d.ts +14 -0
  160. package/dist/src/languages/javascript/parser.d.ts.map +1 -0
  161. package/dist/src/languages/javascript/parser.js +38 -0
  162. package/dist/src/languages/javascript/symbolResolver.d.ts +31 -0
  163. package/dist/src/languages/javascript/symbolResolver.d.ts.map +1 -0
  164. package/dist/src/languages/javascript/symbolResolver.js +183 -0
  165. package/dist/src/languages/kotlin/index.d.ts +16 -0
  166. package/dist/src/languages/kotlin/index.d.ts.map +1 -0
  167. package/dist/src/languages/kotlin/index.js +151 -0
  168. package/dist/src/languages/kotlin/parser.d.ts +11 -0
  169. package/dist/src/languages/kotlin/parser.d.ts.map +1 -0
  170. package/dist/src/languages/kotlin/parser.js +74 -0
  171. package/dist/src/languages/python/index.d.ts +15 -0
  172. package/dist/src/languages/python/index.d.ts.map +1 -0
  173. package/dist/src/languages/python/index.js +293 -0
  174. package/dist/src/languages/ruby/index.d.ts +15 -0
  175. package/dist/src/languages/ruby/index.d.ts.map +1 -0
  176. package/dist/src/languages/ruby/index.js +274 -0
  177. package/dist/src/languages/shared/treeSitterUtils.d.ts +43 -0
  178. package/dist/src/languages/shared/treeSitterUtils.d.ts.map +1 -0
  179. package/dist/src/languages/shared/treeSitterUtils.js +100 -0
  180. package/dist/src/languages/typescript/index.d.ts +14 -0
  181. package/dist/src/languages/typescript/index.d.ts.map +1 -0
  182. package/dist/src/languages/typescript/index.js +25 -0
  183. package/dist/src/lib/index.d.ts +228 -0
  184. package/dist/src/lib/index.d.ts.map +1 -0
  185. package/dist/src/lib/index.js +486 -0
  186. package/dist/src/mcp/client/index.d.ts +37 -0
  187. package/dist/src/mcp/client/index.d.ts.map +1 -0
  188. package/dist/src/mcp/client/index.js +235 -0
  189. package/dist/src/mcp/config.d.ts +50 -0
  190. package/dist/src/mcp/config.d.ts.map +1 -0
  191. package/dist/src/mcp/config.js +125 -0
  192. package/dist/src/mcp/events.d.ts +24 -0
  193. package/dist/src/mcp/events.d.ts.map +1 -0
  194. package/dist/src/mcp/events.js +48 -0
  195. package/dist/src/mcp/fallback/index.d.ts +50 -0
  196. package/dist/src/mcp/fallback/index.d.ts.map +1 -0
  197. package/dist/src/mcp/fallback/index.js +216 -0
  198. package/dist/src/mcp/index.d.ts +67 -0
  199. package/dist/src/mcp/index.d.ts.map +1 -0
  200. package/dist/src/mcp/index.js +212 -0
  201. package/dist/src/mcp/normalizer.d.ts +21 -0
  202. package/dist/src/mcp/normalizer.d.ts.map +1 -0
  203. package/dist/src/mcp/normalizer.js +99 -0
  204. package/dist/src/mcp/prompts/index.d.ts +86 -0
  205. package/dist/src/mcp/prompts/index.d.ts.map +1 -0
  206. package/dist/src/mcp/prompts/index.js +304 -0
  207. package/dist/src/mcp/templates/index.d.ts +35 -0
  208. package/dist/src/mcp/templates/index.d.ts.map +1 -0
  209. package/dist/src/mcp/templates/index.js +143 -0
  210. package/dist/src/mcp/testing/mock-server/index.d.ts +47 -0
  211. package/dist/src/mcp/testing/mock-server/index.d.ts.map +1 -0
  212. package/dist/src/mcp/testing/mock-server/index.js +157 -0
  213. package/dist/src/mcp/types.d.ts +127 -0
  214. package/dist/src/mcp/types.d.ts.map +1 -0
  215. package/dist/src/mcp/types.js +8 -0
  216. package/dist/src/observability.d.ts +138 -0
  217. package/dist/src/observability.d.ts.map +1 -0
  218. package/dist/src/observability.js +519 -0
  219. package/dist/src/parameterCoverage.d.ts +75 -0
  220. package/dist/src/parameterCoverage.d.ts.map +1 -0
  221. package/dist/src/parameterCoverage.js +629 -0
  222. package/dist/src/perfResilienceCoverage.d.ts +155 -0
  223. package/dist/src/perfResilienceCoverage.d.ts.map +1 -0
  224. package/dist/src/perfResilienceCoverage.js +670 -0
  225. package/dist/src/pluginLoader.d.ts +51 -0
  226. package/dist/src/pluginLoader.d.ts.map +1 -0
  227. package/dist/src/pluginLoader.js +72 -0
  228. package/dist/src/publishing.d.ts +63 -0
  229. package/dist/src/publishing.d.ts.map +1 -0
  230. package/dist/src/publishing.js +379 -0
  231. package/dist/src/qualityGate.d.ts +58 -0
  232. package/dist/src/qualityGate.d.ts.map +1 -0
  233. package/dist/src/qualityGate.js +118 -0
  234. package/dist/src/reporting.d.ts +41 -0
  235. package/dist/src/reporting.d.ts.map +1 -0
  236. package/dist/src/reporting.js +278 -0
  237. package/dist/src/screenshots.d.ts +71 -0
  238. package/dist/src/screenshots.d.ts.map +1 -0
  239. package/dist/src/screenshots.js +141 -0
  240. package/dist/src/security/gate/index.d.ts +11 -0
  241. package/dist/src/security/gate/index.d.ts.map +1 -0
  242. package/dist/src/security/gate/index.js +65 -0
  243. package/dist/src/security/index.d.ts +30 -0
  244. package/dist/src/security/index.d.ts.map +1 -0
  245. package/dist/src/security/index.js +342 -0
  246. package/dist/src/security/normalizers/semgrep.d.ts +10 -0
  247. package/dist/src/security/normalizers/semgrep.d.ts.map +1 -0
  248. package/dist/src/security/normalizers/semgrep.js +104 -0
  249. package/dist/src/security/normalizers/trivy.d.ts +10 -0
  250. package/dist/src/security/normalizers/trivy.d.ts.map +1 -0
  251. package/dist/src/security/normalizers/trivy.js +78 -0
  252. package/dist/src/security/normalizers/zap.d.ts +10 -0
  253. package/dist/src/security/normalizers/zap.d.ts.map +1 -0
  254. package/dist/src/security/normalizers/zap.js +104 -0
  255. package/dist/src/security/scanners/semgrep.d.ts +6 -0
  256. package/dist/src/security/scanners/semgrep.d.ts.map +1 -0
  257. package/dist/src/security/scanners/semgrep.js +125 -0
  258. package/dist/src/security/scanners/trivy.d.ts +6 -0
  259. package/dist/src/security/scanners/trivy.d.ts.map +1 -0
  260. package/dist/src/security/scanners/trivy.js +115 -0
  261. package/dist/src/security/scanners/zap.d.ts +6 -0
  262. package/dist/src/security/scanners/zap.d.ts.map +1 -0
  263. package/dist/src/security/scanners/zap.js +135 -0
  264. package/dist/src/security/types.d.ts +146 -0
  265. package/dist/src/security/types.d.ts.map +1 -0
  266. package/dist/src/security/types.js +6 -0
  267. package/dist/src/securityCoverage.d.ts +116 -0
  268. package/dist/src/securityCoverage.d.ts.map +1 -0
  269. package/dist/src/securityCoverage.js +725 -0
  270. package/dist/src/summary/buildSummary.d.ts +28 -0
  271. package/dist/src/summary/buildSummary.d.ts.map +1 -0
  272. package/dist/src/summary/buildSummary.js +257 -0
  273. package/dist/src/summary/evaluateMetrics.d.ts +31 -0
  274. package/dist/src/summary/evaluateMetrics.d.ts.map +1 -0
  275. package/dist/src/summary/evaluateMetrics.js +118 -0
  276. package/dist/src/summary/index.d.ts +10 -0
  277. package/dist/src/summary/index.d.ts.map +1 -0
  278. package/dist/src/summary/index.js +22 -0
  279. package/dist/src/summary/markdownRenderer.d.ts +139 -0
  280. package/dist/src/summary/markdownRenderer.d.ts.map +1 -0
  281. package/dist/src/summary/markdownRenderer.js +459 -0
  282. package/dist/src/summary/prSummary.d.ts +24 -0
  283. package/dist/src/summary/prSummary.d.ts.map +1 -0
  284. package/dist/src/summary/prSummary.js +233 -0
  285. package/dist/src/summary/summaryTypes.d.ts +35 -0
  286. package/dist/src/summary/summaryTypes.d.ts.map +1 -0
  287. package/dist/src/summary/summaryTypes.js +27 -0
  288. package/package.json +84 -0
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ /**
3
+ * Coverage Intelligence – AI-Friendly Markdown Reporter.
4
+ *
5
+ * Generates structured, concise markdown and JSON reports from
6
+ * IntelligenceReport data. All outputs are deterministic.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.renderCoverageIntelligenceMd = renderCoverageIntelligenceMd;
43
+ exports.renderMissingTestsMd = renderMissingTestsMd;
44
+ exports.renderRiskPrioritizationMd = renderRiskPrioritizationMd;
45
+ exports.writeIntelligenceReports = writeIntelligenceReports;
46
+ const fs = __importStar(require("fs"));
47
+ const path = __importStar(require("path"));
48
+ const riskScoring_1 = require("./riskScoring");
49
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
50
+ function severityEmoji(s) {
51
+ switch (s) {
52
+ case 'CRITICAL': return '🔴';
53
+ case 'HIGH': return '🟠';
54
+ case 'MEDIUM': return '🟡';
55
+ default: return '🔵';
56
+ }
57
+ }
58
+ function priorityEmoji(p) {
59
+ switch (p) {
60
+ case 'P0': return '🚨';
61
+ case 'P1': return '🔴';
62
+ case 'P2': return '🟠';
63
+ default: return '🟡';
64
+ }
65
+ }
66
+ function riskBandEmoji(score) {
67
+ const band = (0, riskScoring_1.scoreToRiskBand)(score);
68
+ switch (band) {
69
+ case 'Critical': return '🔴 Critical';
70
+ case 'High': return '🟠 High';
71
+ case 'Moderate': return '🟡 Moderate';
72
+ default: return '🔵 Low';
73
+ }
74
+ }
75
+ function formatEndpoint(ep) {
76
+ var _a, _b;
77
+ if (!ep)
78
+ return 'N/A';
79
+ return `\`${(_a = ep.method) !== null && _a !== void 0 ? _a : 'GET'} ${(_b = ep.path) !== null && _b !== void 0 ? _b : '/'}\``;
80
+ }
81
+ // ─── Coverage Intelligence Summary ───────────────────────────────────────────
82
+ function renderCoverageIntelligenceMd(report) {
83
+ const { summary, findings, recommendations } = report;
84
+ const topFindings = findings.slice(0, 10);
85
+ const topRecs = recommendations.slice(0, 10);
86
+ const lines = [
87
+ `# Coverage Intelligence Report`,
88
+ ``,
89
+ `> Generated: ${report.generatedAt} `,
90
+ `> Project: **${report.projectName}**`,
91
+ ``,
92
+ `## Summary`,
93
+ ``,
94
+ `| Metric | Value |`,
95
+ `|--------|-------|`,
96
+ `| Total Findings | ${summary.totalFindings} |`,
97
+ `| Total Recommendations | ${summary.totalRecommendations} |`,
98
+ `| Max Risk Score | ${summary.maxRiskScore} (${(0, riskScoring_1.scoreToRiskBand)(summary.maxRiskScore)}) |`,
99
+ `| Avg Risk Score | ${summary.avgRiskScore} |`,
100
+ `| Critical Uncovered Items | ${summary.criticalUncoveredItems} |`,
101
+ `| Unprotected Security Findings | ${summary.unprotectedSecurityFindings} |`,
102
+ ``,
103
+ `### Findings by Severity`,
104
+ ``,
105
+ `| Severity | Count |`,
106
+ `|----------|-------|`,
107
+ ...['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].map((s) => { var _a; return `| ${severityEmoji(s)} ${s} | ${(_a = summary.findingsBySeverity[s]) !== null && _a !== void 0 ? _a : 0} |`; }),
108
+ ``,
109
+ `### Recommendations by Priority`,
110
+ ``,
111
+ `| Priority | Count |`,
112
+ `|----------|-------|`,
113
+ ...['P0', 'P1', 'P2', 'P3'].map((p) => { var _a; return `| ${priorityEmoji(p)} ${p} | ${(_a = summary.recommendationsByPriority[p]) !== null && _a !== void 0 ? _a : 0} |`; }),
114
+ ``,
115
+ `## Top Functional Findings`,
116
+ ``,
117
+ ];
118
+ if (topFindings.length === 0) {
119
+ lines.push('_No findings detected._', '');
120
+ }
121
+ else {
122
+ topFindings.forEach((f, i) => {
123
+ var _a, _b;
124
+ lines.push(`### ${i + 1}. ${severityEmoji(f.severity)} ${f.title}`, ``, `- **Category:** ${f.category}`, `- **Source:** ${f.source}`, `- **Severity:** ${f.severity}`, `- **Endpoint:** ${formatEndpoint(f.endpoint)}`, `- **Description:** ${f.description}`, ((_a = f.missingTestTypes) === null || _a === void 0 ? void 0 : _a.length)
125
+ ? `- **Missing Tests:** ${f.missingTestTypes.join(', ')}`
126
+ : '', ((_b = f.frameworkHints) === null || _b === void 0 ? void 0 : _b.length)
127
+ ? `- **Framework Hints:** ${f.frameworkHints.join(', ')}`
128
+ : '', ``);
129
+ });
130
+ }
131
+ lines.push(`## Top Missing Test Recommendations`, ``);
132
+ if (topRecs.length === 0) {
133
+ lines.push('_No recommendations._', '');
134
+ }
135
+ else {
136
+ topRecs.forEach((r, i) => {
137
+ var _a, _b;
138
+ lines.push(`### ${i + 1}. ${priorityEmoji(r.priority)} ${r.title}`, ``, `| Field | Value |`, `|-------|-------|`, `| **Priority** | ${r.priority} |`, `| **Risk Score** | ${r.riskScore} (${riskBandEmoji(r.riskScore)}) |`, `| **Test Type** | ${r.recommendedTestType} |`, `| **Endpoint** | ${formatEndpoint(r.endpoint)} |`, `| **Framework** | ${(_a = r.likelyFramework) !== null && _a !== void 0 ? _a : 'N/A'} |`, `| **Language** | ${(_b = r.likelyLanguage) !== null && _b !== void 0 ? _b : 'N/A'} |`, `| **Confidence** | ${r.confidence} |`, ``, `**Rationale:** ${r.rationale}`, ``, `**Linked Findings:** ${r.linkedFindingIds.join(', ')}`, ``);
139
+ });
140
+ }
141
+ if (summary.topRiskAreas.length > 0) {
142
+ lines.push(`## Highest-Risk Areas`, ``, ...summary.topRiskAreas.map((a) => `- ${a}`), ``);
143
+ }
144
+ return lines.filter((l) => l !== undefined).join('\n');
145
+ }
146
+ // ─── Missing Test Recommendations report ─────────────────────────────────────
147
+ function renderMissingTestsMd(report) {
148
+ var _a, _b;
149
+ const { recommendations } = report;
150
+ const lines = [
151
+ `# Missing Test Recommendations`,
152
+ ``,
153
+ `> Generated: ${report.generatedAt} `,
154
+ `> Project: **${report.projectName}**`,
155
+ ``,
156
+ `Total: **${recommendations.length}** recommendations`,
157
+ ``,
158
+ ];
159
+ if (recommendations.length === 0) {
160
+ lines.push('_No missing test recommendations at this time._', '');
161
+ return lines.join('\n');
162
+ }
163
+ for (const r of recommendations) {
164
+ lines.push(`## ${priorityEmoji(r.priority)} [${r.priority}] ${r.title}`, ``, `| Field | Value |`, `|-------|-------|`, `| **Priority** | \`${r.priority}\` |`, `| **Risk Score** | ${r.riskScore} — ${riskBandEmoji(r.riskScore)} |`, `| **Test Type** | \`${r.recommendedTestType}\` |`, `| **Endpoint** | ${formatEndpoint(r.endpoint)} |`, `| **Language** | ${(_a = r.likelyLanguage) !== null && _a !== void 0 ? _a : '_undetected_'} |`, `| **Framework** | ${(_b = r.likelyFramework) !== null && _b !== void 0 ? _b : '_undetected_'} |`, `| **Confidence** | ${r.confidence} |`, ``, `> ${r.rationale}`, ``, `**Linked Findings:** ${r.linkedFindingIds.join(', ')}`, ``, `---`, ``);
165
+ }
166
+ return lines.join('\n');
167
+ }
168
+ // ─── Risk Prioritization report ───────────────────────────────────────────────
169
+ function renderRiskPrioritizationMd(report) {
170
+ var _a, _b, _c;
171
+ const { findings, recommendations } = report;
172
+ const criticalRecs = recommendations.filter((r) => (0, riskScoring_1.scoreToRiskBand)(r.riskScore) === 'Critical');
173
+ const highRecs = recommendations.filter((r) => (0, riskScoring_1.scoreToRiskBand)(r.riskScore) === 'High');
174
+ const byCategory = new Map();
175
+ for (const r of recommendations) {
176
+ const f = findings.find((ff) => r.linkedFindingIds.includes(ff.id));
177
+ const cat = (_a = f === null || f === void 0 ? void 0 : f.category) !== null && _a !== void 0 ? _a : 'unknown';
178
+ if (!byCategory.has(cat))
179
+ byCategory.set(cat, []);
180
+ byCategory.get(cat).push(r);
181
+ }
182
+ const lines = [
183
+ `# Risk Prioritization Report`,
184
+ ``,
185
+ `> Generated: ${report.generatedAt} `,
186
+ `> Project: **${report.projectName}**`,
187
+ ``,
188
+ `## Critical Risks (Score ≥ 75)`,
189
+ ``,
190
+ ];
191
+ if (criticalRecs.length === 0) {
192
+ lines.push('_No critical-risk items detected._', '');
193
+ }
194
+ else {
195
+ criticalRecs.forEach((r) => {
196
+ lines.push(`- 🔴 **[${r.priority}]** ${r.title} — Score: ${r.riskScore}`);
197
+ });
198
+ lines.push('');
199
+ }
200
+ lines.push(`## High Risks (Score 50–74)`, ``);
201
+ if (highRecs.length === 0) {
202
+ lines.push('_No high-risk items detected._', '');
203
+ }
204
+ else {
205
+ highRecs.forEach((r) => {
206
+ lines.push(`- 🟠 **[${r.priority}]** ${r.title} — Score: ${r.riskScore}`);
207
+ });
208
+ lines.push('');
209
+ }
210
+ lines.push(`## Risks by Category`, ``);
211
+ if (byCategory.size === 0) {
212
+ lines.push('_No risks by category detected._', '');
213
+ }
214
+ else {
215
+ for (const [cat, recs] of byCategory.entries()) {
216
+ lines.push(`### ${cat}`, ``);
217
+ recs.forEach((r) => {
218
+ lines.push(`- ${priorityEmoji(r.priority)} **[${r.priority}]** ${r.title} — Score: ${r.riskScore}`);
219
+ });
220
+ lines.push('');
221
+ }
222
+ }
223
+ const byEndpoint = new Map();
224
+ for (const r of recommendations) {
225
+ if (!((_b = r.endpoint) === null || _b === void 0 ? void 0 : _b.path))
226
+ continue;
227
+ const key = `${(_c = r.endpoint.method) !== null && _c !== void 0 ? _c : 'GET'} ${r.endpoint.path}`;
228
+ if (!byEndpoint.has(key))
229
+ byEndpoint.set(key, []);
230
+ byEndpoint.get(key).push(r);
231
+ }
232
+ if (byEndpoint.size > 0) {
233
+ lines.push(`## Risks by Endpoint`, ``);
234
+ for (const [ep, recs] of byEndpoint.entries()) {
235
+ lines.push(`### \`${ep}\``, ``);
236
+ recs.forEach((r) => {
237
+ lines.push(`- ${priorityEmoji(r.priority)} **[${r.priority}]** ${r.title} — Score: ${r.riskScore}`);
238
+ });
239
+ lines.push('');
240
+ }
241
+ }
242
+ return lines.join('\n');
243
+ }
244
+ // ─── Write reports to disk ────────────────────────────────────────────────────
245
+ function writeIntelligenceReports(report, outDir) {
246
+ if (!fs.existsSync(outDir)) {
247
+ fs.mkdirSync(outDir, { recursive: true });
248
+ }
249
+ // coverage-intelligence.json
250
+ fs.writeFileSync(path.join(outDir, 'coverage-intelligence.json'), JSON.stringify(report, null, 2), 'utf-8');
251
+ // coverage-intelligence.md
252
+ fs.writeFileSync(path.join(outDir, 'coverage-intelligence.md'), renderCoverageIntelligenceMd(report), 'utf-8');
253
+ // missing-tests-recommendations.json
254
+ fs.writeFileSync(path.join(outDir, 'missing-tests-recommendations.json'), JSON.stringify({ generatedAt: report.generatedAt, recommendations: report.recommendations }, null, 2), 'utf-8');
255
+ // missing-tests-recommendations.md
256
+ fs.writeFileSync(path.join(outDir, 'missing-tests-recommendations.md'), renderMissingTestsMd(report), 'utf-8');
257
+ // risk-prioritization.json
258
+ fs.writeFileSync(path.join(outDir, 'risk-prioritization.json'), JSON.stringify({
259
+ generatedAt: report.generatedAt,
260
+ summary: report.summary,
261
+ recommendations: report.recommendations,
262
+ }, null, 2), 'utf-8');
263
+ // risk-prioritization.md
264
+ fs.writeFileSync(path.join(outDir, 'risk-prioritization.md'), renderRiskPrioritizationMd(report), 'utf-8');
265
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Coverage Intelligence – Risk Scoring Engine.
3
+ *
4
+ * Implements a deterministic, formula-driven risk score for each functional
5
+ * finding or missing-test recommendation.
6
+ *
7
+ * Formula:
8
+ * Risk Score =
9
+ * 0.30 * SeverityWeight +
10
+ * 0.20 * ExposureWeight +
11
+ * 0.15 * CriticalityWeight +
12
+ * 0.15 * MissingCoverageWeight +
13
+ * 0.10 * SecuritySignalWeight +
14
+ * 0.05 * FlowImpactWeight +
15
+ * 0.05 * ChangeVolatilityWeight
16
+ *
17
+ * All components are normalized to 0–100. Final score is clamped to 0–100
18
+ * and rounded to the nearest integer.
19
+ */
20
+ import type { Severity, RiskBand, RiskScoreComponents, RecommendationPriority, FindingCategory } from './types';
21
+ /** Maps severity label → 0-100 score component. */
22
+ export declare function severityToWeight(severity: Severity | string): number;
23
+ /**
24
+ * Derive default exposure, criticality, and flow-impact values from the
25
+ * finding category and optional endpoint information.
26
+ */
27
+ export declare function defaultExposureWeight(category: FindingCategory | string, endpointPath?: string): number;
28
+ export declare function defaultCriticalityWeight(category: FindingCategory | string, endpointPath?: string): number;
29
+ export declare function defaultFlowImpactWeight(category: FindingCategory | string, endpointPath?: string): number;
30
+ export interface RiskScoreInput {
31
+ severity: Severity | string;
32
+ category: FindingCategory | string;
33
+ endpointPath?: string;
34
+ /** Override individual components (0-100 each) */
35
+ components?: Partial<RiskScoreComponents>;
36
+ /** Whether linked security scanner findings exist */
37
+ hasSecuritySignal?: boolean;
38
+ /** Whether there are zero tests covering this area */
39
+ zeroCoverage?: boolean;
40
+ }
41
+ /**
42
+ * Compute a 0–100 risk score for a finding or recommendation.
43
+ */
44
+ export declare function computeRiskScore(input: RiskScoreInput): number;
45
+ export declare function scoreToRiskBand(score: number): RiskBand;
46
+ /** Derive recommendation priority from risk score, with override rules. */
47
+ export declare function scoreToPriority(score: number, overrides?: {
48
+ isCriticalSecurityFinding?: boolean;
49
+ isMoneyMovementEndpoint?: boolean;
50
+ isAuthGap?: boolean;
51
+ isZeroCoverageCriticalFlow?: boolean;
52
+ }): RecommendationPriority;
53
+ //# sourceMappingURL=riskScoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"riskScoring.d.ts","sourceRoot":"","sources":["../../../src/intelligence/riskScoring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EAChB,MAAM,SAAS,CAAC;AAgBjB,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAQpE;AAID;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,GAAG,MAAM,EAClC,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAaR;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,eAAe,GAAG,MAAM,EAClC,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAmCR;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,eAAe,GAAG,MAAM,EAClC,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAeR;AAID,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,QAAQ,EAAE,eAAe,GAAG,MAAM,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1C,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAqB9D;AAID,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAKvD;AAID,2EAA2E;AAC3E,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE;IACV,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,GACA,sBAAsB,CAuBxB"}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ /**
3
+ * Coverage Intelligence – Risk Scoring Engine.
4
+ *
5
+ * Implements a deterministic, formula-driven risk score for each functional
6
+ * finding or missing-test recommendation.
7
+ *
8
+ * Formula:
9
+ * Risk Score =
10
+ * 0.30 * SeverityWeight +
11
+ * 0.20 * ExposureWeight +
12
+ * 0.15 * CriticalityWeight +
13
+ * 0.15 * MissingCoverageWeight +
14
+ * 0.10 * SecuritySignalWeight +
15
+ * 0.05 * FlowImpactWeight +
16
+ * 0.05 * ChangeVolatilityWeight
17
+ *
18
+ * All components are normalized to 0–100. Final score is clamped to 0–100
19
+ * and rounded to the nearest integer.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.severityToWeight = severityToWeight;
23
+ exports.defaultExposureWeight = defaultExposureWeight;
24
+ exports.defaultCriticalityWeight = defaultCriticalityWeight;
25
+ exports.defaultFlowImpactWeight = defaultFlowImpactWeight;
26
+ exports.computeRiskScore = computeRiskScore;
27
+ exports.scoreToRiskBand = scoreToRiskBand;
28
+ exports.scoreToPriority = scoreToPriority;
29
+ // ─── Component weights ────────────────────────────────────────────────────────
30
+ const WEIGHTS = {
31
+ severity: 0.30,
32
+ exposure: 0.20,
33
+ criticality: 0.15,
34
+ missingCoverage: 0.15,
35
+ securitySignal: 0.10,
36
+ flowImpact: 0.05,
37
+ changeVolatility: 0.05,
38
+ };
39
+ // ─── Severity mapping ─────────────────────────────────────────────────────────
40
+ /** Maps severity label → 0-100 score component. */
41
+ function severityToWeight(severity) {
42
+ switch (severity.toUpperCase()) {
43
+ case 'CRITICAL': return 100;
44
+ case 'HIGH': return 75;
45
+ case 'MEDIUM': return 50;
46
+ case 'LOW': return 25;
47
+ default: return 25;
48
+ }
49
+ }
50
+ // ─── Category-based defaults ──────────────────────────────────────────────────
51
+ /**
52
+ * Derive default exposure, criticality, and flow-impact values from the
53
+ * finding category and optional endpoint information.
54
+ */
55
+ function defaultExposureWeight(category, endpointPath) {
56
+ // Auth/authz gaps are typically on exposed endpoints
57
+ if (category === 'missing-auth-test' || category === 'security-finding-unprotected') {
58
+ return 80;
59
+ }
60
+ // Public endpoint patterns
61
+ if (endpointPath) {
62
+ const lower = endpointPath.toLowerCase();
63
+ if (lower.includes('admin') || lower.includes('internal'))
64
+ return 30;
65
+ if (lower.includes('auth') || lower.includes('login') || lower.includes('token'))
66
+ return 90;
67
+ if (lower.includes('payment') || lower.includes('wallet') || lower.includes('transfer'))
68
+ return 90;
69
+ }
70
+ return 50; // default
71
+ }
72
+ function defaultCriticalityWeight(category, endpointPath) {
73
+ const criticalCategories = [
74
+ 'missing-auth-test',
75
+ 'security-finding-unprotected',
76
+ ];
77
+ if (criticalCategories.includes(category))
78
+ return 90;
79
+ if (endpointPath) {
80
+ const lower = endpointPath.toLowerCase();
81
+ if (lower.includes('payment') ||
82
+ lower.includes('wallet') ||
83
+ lower.includes('transfer') ||
84
+ lower.includes('refund') ||
85
+ lower.includes('debit') ||
86
+ lower.includes('charge')) {
87
+ return 95;
88
+ }
89
+ if (lower.includes('auth') || lower.includes('login') || lower.includes('token'))
90
+ return 90;
91
+ if (lower.includes('profile') || lower.includes('account') || lower.includes('user'))
92
+ return 50;
93
+ }
94
+ switch (category) {
95
+ case 'uncovered-endpoint': return 70;
96
+ case 'missing-business-rule-test': return 75;
97
+ case 'missing-flow-step-test': return 65;
98
+ case 'error-scenario-gap': return 55;
99
+ case 'missing-negative-test': return 60;
100
+ case 'missing-boundary-test': return 45;
101
+ case 'compatibility-risk': return 70;
102
+ case 'performance-risk': return 60;
103
+ case 'high-risk-parameter-gap': return 55;
104
+ default: return 40;
105
+ }
106
+ }
107
+ function defaultFlowImpactWeight(category, endpointPath) {
108
+ if (category === 'missing-flow-step-test')
109
+ return 80;
110
+ if (endpointPath) {
111
+ const lower = endpointPath.toLowerCase();
112
+ if (lower.includes('payment') || lower.includes('checkout') || lower.includes('signup')) {
113
+ return 80;
114
+ }
115
+ }
116
+ switch (category) {
117
+ case 'uncovered-endpoint': return 30;
118
+ case 'missing-business-rule-test': return 50;
119
+ case 'security-finding-unprotected': return 60;
120
+ case 'compatibility-risk': return 60;
121
+ default: return 20;
122
+ }
123
+ }
124
+ /**
125
+ * Compute a 0–100 risk score for a finding or recommendation.
126
+ */
127
+ function computeRiskScore(input) {
128
+ var _a, _b, _c, _d, _e, _f, _g, _h;
129
+ const c = (_a = input.components) !== null && _a !== void 0 ? _a : {};
130
+ const severityW = (_b = c.severityWeight) !== null && _b !== void 0 ? _b : severityToWeight(input.severity);
131
+ const exposureW = (_c = c.exposureWeight) !== null && _c !== void 0 ? _c : defaultExposureWeight(input.category, input.endpointPath);
132
+ const criticalW = (_d = c.criticalityWeight) !== null && _d !== void 0 ? _d : defaultCriticalityWeight(input.category, input.endpointPath);
133
+ const missingCovW = (_e = c.missingCoverageWeight) !== null && _e !== void 0 ? _e : (input.zeroCoverage ? 100 : 75);
134
+ const secSignalW = (_f = c.securitySignalWeight) !== null && _f !== void 0 ? _f : (input.hasSecuritySignal ? 100 : 0);
135
+ const flowImpW = (_g = c.flowImpactWeight) !== null && _g !== void 0 ? _g : defaultFlowImpactWeight(input.category, input.endpointPath);
136
+ const changeVolW = (_h = c.changeVolatilityWeight) !== null && _h !== void 0 ? _h : 40; // default when no git data
137
+ const raw = WEIGHTS.severity * severityW +
138
+ WEIGHTS.exposure * exposureW +
139
+ WEIGHTS.criticality * criticalW +
140
+ WEIGHTS.missingCoverage * missingCovW +
141
+ WEIGHTS.securitySignal * secSignalW +
142
+ WEIGHTS.flowImpact * flowImpW +
143
+ WEIGHTS.changeVolatility * changeVolW;
144
+ return Math.min(100, Math.max(0, Math.round(raw)));
145
+ }
146
+ // ─── Risk band ────────────────────────────────────────────────────────────────
147
+ function scoreToRiskBand(score) {
148
+ if (score >= 75)
149
+ return 'Critical';
150
+ if (score >= 50)
151
+ return 'High';
152
+ if (score >= 25)
153
+ return 'Moderate';
154
+ return 'Low';
155
+ }
156
+ // ─── Priority assignment ──────────────────────────────────────────────────────
157
+ /** Derive recommendation priority from risk score, with override rules. */
158
+ function scoreToPriority(score, overrides) {
159
+ // Override rules: never lower than P1 for high-stakes scenarios
160
+ const mustBeP1OrHigher = (overrides === null || overrides === void 0 ? void 0 : overrides.isCriticalSecurityFinding) ||
161
+ (overrides === null || overrides === void 0 ? void 0 : overrides.isMoneyMovementEndpoint) ||
162
+ (overrides === null || overrides === void 0 ? void 0 : overrides.isAuthGap) ||
163
+ (overrides === null || overrides === void 0 ? void 0 : overrides.isZeroCoverageCriticalFlow);
164
+ let priority;
165
+ if (score >= 85) {
166
+ priority = 'P0';
167
+ }
168
+ else if (score >= 70) {
169
+ priority = 'P1';
170
+ }
171
+ else if (score >= 50) {
172
+ priority = 'P2';
173
+ }
174
+ else {
175
+ priority = 'P3';
176
+ }
177
+ if (mustBeP1OrHigher && (priority === 'P2' || priority === 'P3')) {
178
+ return 'P1';
179
+ }
180
+ return priority;
181
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Coverage Intelligence – shared types.
3
+ *
4
+ * Defines FunctionalFinding, MissingTestRecommendation, and all supporting
5
+ * enumerations used by the linkage engine, risk scorer, and markdown reporter.
6
+ */
7
+ export type FindingSource = 'coverage-gap-analysis' | 'error-coverage' | 'security-coverage' | 'security-scan' | 'integration-flow' | 'parameter-coverage' | 'business-coverage' | 'compatibility' | 'performance-resilience' | 'mcp-analysis' | 'manual-rule';
8
+ export type FindingCategory = 'uncovered-endpoint' | 'missing-negative-test' | 'missing-auth-test' | 'missing-boundary-test' | 'missing-business-rule-test' | 'missing-flow-step-test' | 'security-finding-unprotected' | 'high-risk-parameter-gap' | 'compatibility-risk' | 'performance-risk' | 'error-scenario-gap';
9
+ export type Severity = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
10
+ export interface EndpointRef {
11
+ method?: string;
12
+ path?: string;
13
+ }
14
+ export interface FunctionalFinding {
15
+ id: string;
16
+ source: FindingSource;
17
+ category: FindingCategory;
18
+ severity: Severity;
19
+ title: string;
20
+ description: string;
21
+ endpoint?: EndpointRef;
22
+ filePaths?: string[];
23
+ relatedTests?: string[];
24
+ relatedRules?: string[];
25
+ relatedScanners?: string[];
26
+ relatedFindings?: string[];
27
+ missingTestTypes?: string[];
28
+ frameworkHints?: string[];
29
+ languageHints?: string[];
30
+ tags?: string[];
31
+ }
32
+ export type RecommendationPriority = 'P0' | 'P1' | 'P2' | 'P3';
33
+ export type RecommendedTestType = 'positive-api-test' | 'negative-api-test' | 'auth-test' | 'authz-test' | 'boundary-test' | 'business-rule-test' | 'integration-flow-test' | 'security-test' | 'performance-test' | 'resilience-test' | 'compatibility-test';
34
+ export interface MissingTestRecommendation {
35
+ id: string;
36
+ priority: RecommendationPriority;
37
+ title: string;
38
+ rationale: string;
39
+ recommendedTestType: RecommendedTestType;
40
+ endpoint?: EndpointRef;
41
+ likelyFileTargets?: string[];
42
+ likelyFramework?: string;
43
+ likelyLanguage?: string;
44
+ linkedFindingIds: string[];
45
+ riskScore: number;
46
+ confidence: 'low' | 'medium' | 'high';
47
+ }
48
+ export type RiskBand = 'Low' | 'Moderate' | 'High' | 'Critical';
49
+ export interface RiskScoreComponents {
50
+ /** 0-100: derived from severity */
51
+ severityWeight: number;
52
+ /** 0-100: how exposed is this area */
53
+ exposureWeight: number;
54
+ /** 0-100: business/domain criticality */
55
+ criticalityWeight: number;
56
+ /** 0-100: how uncovered is the area */
57
+ missingCoverageWeight: number;
58
+ /** 0-100: security signal from scanners */
59
+ securitySignalWeight: number;
60
+ /** 0-100: impact on broader integration flow */
61
+ flowImpactWeight: number;
62
+ /** 0-100: change volatility / instability */
63
+ changeVolatilityWeight: number;
64
+ }
65
+ export interface IntelligenceInput {
66
+ /** Coverage results from all analyzers */
67
+ coverageResults: Array<{
68
+ type: string;
69
+ totalItems: number;
70
+ coveredItems: number;
71
+ coveragePercent: number;
72
+ details: unknown;
73
+ }>;
74
+ /** Security scan findings (optional) */
75
+ securityFindings?: Array<{
76
+ id?: string;
77
+ severity: string;
78
+ title: string;
79
+ description?: string;
80
+ category?: string;
81
+ scanner?: string;
82
+ filePath?: string;
83
+ endpoint?: EndpointRef;
84
+ }>;
85
+ /** Detected languages in the project */
86
+ languages?: string[];
87
+ /** Detected test frameworks */
88
+ frameworks?: string[];
89
+ /** Whether MCP is enabled */
90
+ mcpEnabled?: boolean;
91
+ /** Output directory for reports */
92
+ outDir?: string;
93
+ /** Project/service name */
94
+ projectName?: string;
95
+ /** Coverage thresholds */
96
+ thresholds?: Record<string, number | undefined>;
97
+ }
98
+ export interface IntelligenceReport {
99
+ /** Generation timestamp */
100
+ generatedAt: string;
101
+ /** Project/service name */
102
+ projectName: string;
103
+ /** All functional findings discovered */
104
+ findings: FunctionalFinding[];
105
+ /** All missing test recommendations */
106
+ recommendations: MissingTestRecommendation[];
107
+ /** Summary statistics */
108
+ summary: IntelligenceSummary;
109
+ }
110
+ export interface IntelligenceSummary {
111
+ totalFindings: number;
112
+ findingsBySeverity: Record<Severity, number>;
113
+ totalRecommendations: number;
114
+ recommendationsByPriority: Record<RecommendationPriority, number>;
115
+ maxRiskScore: number;
116
+ avgRiskScore: number;
117
+ criticalUncoveredItems: number;
118
+ unprotectedSecurityFindings: number;
119
+ topRiskAreas: string[];
120
+ }
121
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/intelligence/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Coverage Intelligence – shared types.
4
+ *
5
+ * Defines FunctionalFinding, MissingTestRecommendation, and all supporting
6
+ * enumerations used by the linkage engine, risk scorer, and markdown reporter.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });