vika-cli 0.0.0-stage → 0.1.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 (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -2
  3. package/dist/cli.js +32 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/commands/approve-and-create-tickets.js +51 -0
  6. package/dist/commands/approve-and-create-tickets.js.map +1 -0
  7. package/dist/commands/create-tickets-command.js +30 -0
  8. package/dist/commands/create-tickets-command.js.map +1 -0
  9. package/dist/commands/doctor-command.js +59 -0
  10. package/dist/commands/doctor-command.js.map +1 -0
  11. package/dist/commands/init-command.js +21 -0
  12. package/dist/commands/init-command.js.map +1 -0
  13. package/dist/commands/mark-deploy-command.js +59 -0
  14. package/dist/commands/mark-deploy-command.js.map +1 -0
  15. package/dist/commands/report-command.js +40 -0
  16. package/dist/commands/report-command.js.map +1 -0
  17. package/dist/commands/run-cli.js +197 -0
  18. package/dist/commands/run-cli.js.map +1 -0
  19. package/dist/commands/run-exit-code.js +11 -0
  20. package/dist/commands/run-exit-code.js.map +1 -0
  21. package/dist/commands/serve-command.js +49 -0
  22. package/dist/commands/serve-command.js.map +1 -0
  23. package/dist/configuration/configuration-errors.js +43 -0
  24. package/dist/configuration/configuration-errors.js.map +1 -0
  25. package/dist/configuration/configuration-schema.js +69 -0
  26. package/dist/configuration/configuration-schema.js.map +1 -0
  27. package/dist/configuration/database-url-checks.js +43 -0
  28. package/dist/configuration/database-url-checks.js.map +1 -0
  29. package/dist/configuration/describe-configuration-safely.js +20 -0
  30. package/dist/configuration/describe-configuration-safely.js.map +1 -0
  31. package/dist/configuration/hide-secrets.js +44 -0
  32. package/dist/configuration/hide-secrets.js.map +1 -0
  33. package/dist/configuration/load-configuration.js +97 -0
  34. package/dist/configuration/load-configuration.js.map +1 -0
  35. package/dist/configuration/read-environment-file.js +77 -0
  36. package/dist/configuration/read-environment-file.js.map +1 -0
  37. package/dist/dashboard/dashboard-page.js +267 -0
  38. package/dist/dashboard/dashboard-page.js.map +1 -0
  39. package/dist/dashboard/dashboard-server.js +144 -0
  40. package/dist/dashboard/dashboard-server.js.map +1 -0
  41. package/dist/dashboard/github-issue-link.js +23 -0
  42. package/dist/dashboard/github-issue-link.js.map +1 -0
  43. package/dist/dashboard/request-guard.js +34 -0
  44. package/dist/dashboard/request-guard.js.map +1 -0
  45. package/dist/database/database-store.js +425 -0
  46. package/dist/database/database-store.js.map +1 -0
  47. package/dist/database/store-types.js +2 -0
  48. package/dist/database/store-types.js.map +1 -0
  49. package/dist/deploys/check-sha-on-branch.js +21 -0
  50. package/dist/deploys/check-sha-on-branch.js.map +1 -0
  51. package/dist/deploys/commits-in-range.js +31 -0
  52. package/dist/deploys/commits-in-range.js.map +1 -0
  53. package/dist/deploys/marker-deploys.js +18 -0
  54. package/dist/deploys/marker-deploys.js.map +1 -0
  55. package/dist/deploys/merge-log.js +33 -0
  56. package/dist/deploys/merge-log.js.map +1 -0
  57. package/dist/deploys/pull-request-number.js +5 -0
  58. package/dist/deploys/pull-request-number.js.map +1 -0
  59. package/dist/deploys/read-merge-deploys.js +46 -0
  60. package/dist/deploys/read-merge-deploys.js.map +1 -0
  61. package/dist/deploys/record-deploys.js +12 -0
  62. package/dist/deploys/record-deploys.js.map +1 -0
  63. package/dist/deploys/run-git.js +49 -0
  64. package/dist/deploys/run-git.js.map +1 -0
  65. package/dist/deploys/starting-point.js +5 -0
  66. package/dist/deploys/starting-point.js.map +1 -0
  67. package/dist/deploys/utc-timestamp.js +6 -0
  68. package/dist/deploys/utc-timestamp.js.map +1 -0
  69. package/dist/doctor/check-configuration.js +46 -0
  70. package/dist/doctor/check-configuration.js.map +1 -0
  71. package/dist/doctor/check-database.js +30 -0
  72. package/dist/doctor/check-database.js.map +1 -0
  73. package/dist/doctor/check-deploys.js +22 -0
  74. package/dist/doctor/check-deploys.js.map +1 -0
  75. package/dist/doctor/check-service-logs.js +107 -0
  76. package/dist/doctor/check-service-logs.js.map +1 -0
  77. package/dist/doctor/check-service-repository.js +43 -0
  78. package/dist/doctor/check-service-repository.js.map +1 -0
  79. package/dist/doctor/check-tracker.js +20 -0
  80. package/dist/doctor/check-tracker.js.map +1 -0
  81. package/dist/doctor/check-webhook.js +13 -0
  82. package/dist/doctor/check-webhook.js.map +1 -0
  83. package/dist/doctor/doctor-check-types.js +4 -0
  84. package/dist/doctor/doctor-check-types.js.map +1 -0
  85. package/dist/doctor/format-doctor-report.js +15 -0
  86. package/dist/doctor/format-doctor-report.js.map +1 -0
  87. package/dist/doctor/suggest-path-map.js +35 -0
  88. package/dist/doctor/suggest-path-map.js.map +1 -0
  89. package/dist/error-grouping/build-clusters.js +77 -0
  90. package/dist/error-grouping/build-clusters.js.map +1 -0
  91. package/dist/error-grouping/cluster-types.js +3 -0
  92. package/dist/error-grouping/cluster-types.js.map +1 -0
  93. package/dist/error-grouping/exception-type.js +6 -0
  94. package/dist/error-grouping/exception-type.js.map +1 -0
  95. package/dist/error-grouping/fingerprints.js +18 -0
  96. package/dist/error-grouping/fingerprints.js.map +1 -0
  97. package/dist/error-grouping/normalize-message.js +29 -0
  98. package/dist/error-grouping/normalize-message.js.map +1 -0
  99. package/dist/error-grouping/template-miner.js +75 -0
  100. package/dist/error-grouping/template-miner.js.map +1 -0
  101. package/dist/log-parsing/assemble-log-entries.js +49 -0
  102. package/dist/log-parsing/assemble-log-entries.js.map +1 -0
  103. package/dist/log-parsing/build-log-entry.js +33 -0
  104. package/dist/log-parsing/build-log-entry.js.map +1 -0
  105. package/dist/log-parsing/detect-log-format.js +44 -0
  106. package/dist/log-parsing/detect-log-format.js.map +1 -0
  107. package/dist/log-parsing/json-log-format.js +56 -0
  108. package/dist/log-parsing/json-log-format.js.map +1 -0
  109. package/dist/log-parsing/line-readers.js +14 -0
  110. package/dist/log-parsing/line-readers.js.map +1 -0
  111. package/dist/log-parsing/log-entry-types.js +3 -0
  112. package/dist/log-parsing/log-entry-types.js.map +1 -0
  113. package/dist/log-parsing/log-levels.js +21 -0
  114. package/dist/log-parsing/log-levels.js.map +1 -0
  115. package/dist/log-parsing/nginx-log-format.js +56 -0
  116. package/dist/log-parsing/nginx-log-format.js.map +1 -0
  117. package/dist/log-parsing/parse-log-lines.js +11 -0
  118. package/dist/log-parsing/parse-log-lines.js.map +1 -0
  119. package/dist/log-parsing/read-line-timestamp.js +21 -0
  120. package/dist/log-parsing/read-line-timestamp.js.map +1 -0
  121. package/dist/log-parsing/read-log-command.js +68 -0
  122. package/dist/log-parsing/read-log-command.js.map +1 -0
  123. package/dist/log-parsing/read-log-file.js +32 -0
  124. package/dist/log-parsing/read-log-file.js.map +1 -0
  125. package/dist/log-parsing/stack-frames.js +10 -0
  126. package/dist/log-parsing/stack-frames.js.map +1 -0
  127. package/dist/log-parsing/text-log-format.js +24 -0
  128. package/dist/log-parsing/text-log-format.js.map +1 -0
  129. package/dist/log-parsing/timestamps.js +22 -0
  130. package/dist/log-parsing/timestamps.js.map +1 -0
  131. package/dist/pipeline/analyze-service.js +45 -0
  132. package/dist/pipeline/analyze-service.js.map +1 -0
  133. package/dist/pipeline/build-stored-report.js +24 -0
  134. package/dist/pipeline/build-stored-report.js.map +1 -0
  135. package/dist/pipeline/ingest-service-logs.js +39 -0
  136. package/dist/pipeline/ingest-service-logs.js.map +1 -0
  137. package/dist/pipeline/load-deploys-for-service.js +16 -0
  138. package/dist/pipeline/load-deploys-for-service.js.map +1 -0
  139. package/dist/pipeline/prepare-ticket-drafts.js +33 -0
  140. package/dist/pipeline/prepare-ticket-drafts.js.map +1 -0
  141. package/dist/pipeline/read-new-log-lines.js +39 -0
  142. package/dist/pipeline/read-new-log-lines.js.map +1 -0
  143. package/dist/pipeline/run-all-services.js +73 -0
  144. package/dist/pipeline/run-all-services.js.map +1 -0
  145. package/dist/pipeline/timestamp-range.js +20 -0
  146. package/dist/pipeline/timestamp-range.js.map +1 -0
  147. package/dist/project-setup/detect-project.js +76 -0
  148. package/dist/project-setup/detect-project.js.map +1 -0
  149. package/dist/project-setup/write-starter-files.js +68 -0
  150. package/dist/project-setup/write-starter-files.js.map +1 -0
  151. package/dist/redaction/redact-ip-addresses.js +26 -0
  152. package/dist/redaction/redact-ip-addresses.js.map +1 -0
  153. package/dist/redaction/redact-sensitive-text.js +40 -0
  154. package/dist/redaction/redact-sensitive-text.js.map +1 -0
  155. package/dist/redaction/redaction-kinds.js +5 -0
  156. package/dist/redaction/redaction-kinds.js.map +1 -0
  157. package/dist/regression-detection/count-series.js +38 -0
  158. package/dist/regression-detection/count-series.js.map +1 -0
  159. package/dist/regression-detection/detect-regressions.js +162 -0
  160. package/dist/regression-detection/detect-regressions.js.map +1 -0
  161. package/dist/regression-detection/detection-types.js +9 -0
  162. package/dist/regression-detection/detection-types.js.map +1 -0
  163. package/dist/regression-detection/noise-check.js +7 -0
  164. package/dist/regression-detection/noise-check.js.map +1 -0
  165. package/dist/regression-detection/restore-time.js +19 -0
  166. package/dist/regression-detection/restore-time.js.map +1 -0
  167. package/dist/regression-detection/severity.js +12 -0
  168. package/dist/regression-detection/severity.js.map +1 -0
  169. package/dist/regression-detection/time-units.js +12 -0
  170. package/dist/regression-detection/time-units.js.map +1 -0
  171. package/dist/reporting/build-report.js +77 -0
  172. package/dist/reporting/build-report.js.map +1 -0
  173. package/dist/reporting/compute-metrics.js +42 -0
  174. package/dist/reporting/compute-metrics.js.map +1 -0
  175. package/dist/reporting/format-terminal-report.js +104 -0
  176. package/dist/reporting/format-terminal-report.js.map +1 -0
  177. package/dist/reporting/report-schema.js +96 -0
  178. package/dist/reporting/report-schema.js.map +1 -0
  179. package/dist/reporting/report-types.js +2 -0
  180. package/dist/reporting/report-types.js.map +1 -0
  181. package/dist/suspect-attribution/apply-path-map.js +31 -0
  182. package/dist/suspect-attribution/apply-path-map.js.map +1 -0
  183. package/dist/suspect-attribution/attribute-regression.js +176 -0
  184. package/dist/suspect-attribution/attribute-regression.js.map +1 -0
  185. package/dist/suspect-attribution/bot-authors.js +8 -0
  186. package/dist/suspect-attribution/bot-authors.js.map +1 -0
  187. package/dist/suspect-attribution/callee-files.js +53 -0
  188. package/dist/suspect-attribution/callee-files.js.map +1 -0
  189. package/dist/suspect-attribution/changed-file-categories.js +39 -0
  190. package/dist/suspect-attribution/changed-file-categories.js.map +1 -0
  191. package/dist/suspect-attribution/crash-line-inputs.js +81 -0
  192. package/dist/suspect-attribution/crash-line-inputs.js.map +1 -0
  193. package/dist/suspect-attribution/function-names.js +42 -0
  194. package/dist/suspect-attribution/function-names.js.map +1 -0
  195. package/dist/suspect-attribution/git-blame-reader.js +160 -0
  196. package/dist/suspect-attribution/git-blame-reader.js.map +1 -0
  197. package/dist/suspect-attribution/score-suspects.js +100 -0
  198. package/dist/suspect-attribution/score-suspects.js.map +1 -0
  199. package/dist/suspect-attribution/suspect-types.js +2 -0
  200. package/dist/suspect-attribution/suspect-types.js.map +1 -0
  201. package/dist/ticket-trackers/create-tracker.js +21 -0
  202. package/dist/ticket-trackers/create-tracker.js.map +1 -0
  203. package/dist/ticket-trackers/jira-document.js +34 -0
  204. package/dist/ticket-trackers/jira-document.js.map +1 -0
  205. package/dist/ticket-trackers/jira-tracker.js +65 -0
  206. package/dist/ticket-trackers/jira-tracker.js.map +1 -0
  207. package/dist/ticket-trackers/linear-tracker.js +109 -0
  208. package/dist/ticket-trackers/linear-tracker.js.map +1 -0
  209. package/dist/ticket-trackers/send-tracker-request.js +84 -0
  210. package/dist/ticket-trackers/send-tracker-request.js.map +1 -0
  211. package/dist/ticket-trackers/tracker-types.js +3 -0
  212. package/dist/ticket-trackers/tracker-types.js.map +1 -0
  213. package/dist/ticketing/build-ticket-comment.js +14 -0
  214. package/dist/ticketing/build-ticket-comment.js.map +1 -0
  215. package/dist/ticketing/build-ticket-draft.js +172 -0
  216. package/dist/ticketing/build-ticket-draft.js.map +1 -0
  217. package/dist/ticketing/choose-assignee.js +30 -0
  218. package/dist/ticketing/choose-assignee.js.map +1 -0
  219. package/dist/ticketing/create-ticket.js +92 -0
  220. package/dist/ticketing/create-ticket.js.map +1 -0
  221. package/dist/ticketing/describe-ticket-outcome.js +24 -0
  222. package/dist/ticketing/describe-ticket-outcome.js.map +1 -0
  223. package/dist/ticketing/read-code-owners.js +82 -0
  224. package/dist/ticketing/read-code-owners.js.map +1 -0
  225. package/dist/ticketing/render-ticket-text.js +22 -0
  226. package/dist/ticketing/render-ticket-text.js.map +1 -0
  227. package/dist/ticketing/ticket-types.js +2 -0
  228. package/dist/ticketing/ticket-types.js.map +1 -0
  229. package/dist/webhook/build-webhook-payload.js +29 -0
  230. package/dist/webhook/build-webhook-payload.js.map +1 -0
  231. package/dist/webhook/send-regression-webhooks.js +57 -0
  232. package/dist/webhook/send-regression-webhooks.js.map +1 -0
  233. package/dist/webhook/sign-webhook-body.js +16 -0
  234. package/dist/webhook/sign-webhook-body.js.map +1 -0
  235. package/dist/webhook/webhook-payload-schema.js +32 -0
  236. package/dist/webhook/webhook-payload-schema.js.map +1 -0
  237. package/migrations/001_init.sql +66 -0
  238. package/migrations/002_bookmark_history_start.sql +9 -0
  239. package/migrations/003_tickets.sql +20 -0
  240. package/migrations/004_ticket_comment_count.sql +10 -0
  241. package/migrations/005_webhook_events.sql +18 -0
  242. package/migrations/README.md +1 -0
  243. package/package.json +37 -3
@@ -0,0 +1,104 @@
1
+ const COLOR_CODES = { bold: "\u001b[1m", red: "\u001b[31m", yellow: "\u001b[33m", green: "\u001b[32m", dim: "\u001b[2m", reset: "\u001b[0m" };
2
+ const SHORT_SHA_LENGTH = 7;
3
+ // Printable ASCII only (space to "~").
4
+ function toPlainAscii(text) {
5
+ return text.replace(/[^\x20-\x7e]/g, "?");
6
+ }
7
+ function formatPercent(fraction) {
8
+ return `${Math.round(fraction * 1000) / 10}%`;
9
+ }
10
+ function formatMinutes(totalMinutes) {
11
+ const roundedMinutes = Math.round(totalMinutes);
12
+ if (roundedMinutes < 60)
13
+ return `${roundedMinutes} min`;
14
+ const hours = Math.floor(roundedMinutes / 60);
15
+ const minutes = roundedMinutes % 60;
16
+ return minutes === 0 ? `${hours} h` : `${hours} h ${minutes} min`;
17
+ }
18
+ const formatRate = (ratePerHour) => `${Math.round(ratePerHour * 10) / 10} per hour`;
19
+ const shortSha = (sha) => sha.slice(0, SHORT_SHA_LENGTH);
20
+ function plural(count, singular, pluralForm = `${singular}s`) {
21
+ return `${count} ${count === 1 ? singular : pluralForm}`;
22
+ }
23
+ export function formatTerminalReport(report, options) {
24
+ const paint = (colorName, text) => (options.useColor ? `${COLOR_CODES[colorName]}${text}${COLOR_CODES.reset}` : text);
25
+ const severityColor = { high: "red", medium: "yellow", low: "dim" };
26
+ const lines = [];
27
+ const formatMetrics = (metrics, indent) => {
28
+ const { changeFailureRate, medianTimeToRestore, ongoingRegressions } = metrics;
29
+ lines.push(`${indent}Change failure rate (${changeFailureRate.label}): ` +
30
+ (changeFailureRate.value === null
31
+ ? `${changeFailureRate.note} (no judged deploys)`
32
+ : `${paint("bold", formatPercent(changeFailureRate.value))} (${changeFailureRate.failedDeploys} of ${plural(changeFailureRate.judgedDeploys, "judged deploy")})`));
33
+ lines.push(`${indent}Median time to restore (${medianTimeToRestore.label}): ` +
34
+ (medianTimeToRestore.valueMinutes === null
35
+ ? `${medianTimeToRestore.note} (no restored regressions)`
36
+ : `${paint("bold", formatMinutes(medianTimeToRestore.valueMinutes))} (over ${plural(medianTimeToRestore.restoredRegressions, "restored regression")})`));
37
+ lines.push(`${indent}Ongoing regressions (${ongoingRegressions.label}): ${ongoingRegressions.value}`);
38
+ };
39
+ const formatSuspect = (suspect, suspectNumber) => {
40
+ const pullRequest = suspect.prNumber === null ? "no PR" : `PR #${suspect.prNumber}`;
41
+ const location = suspect.lineNumber === null ? suspect.filePath : `${suspect.filePath}:${suspect.lineNumber}`;
42
+ const botNote = suspect.isBot ? " [bot]" : "";
43
+ lines.push(` ${suspectNumber}) ${pullRequest} commit ${shortSha(suspect.commitSha)} ${suspect.author.name} <${suspect.author.email}>${botNote}`);
44
+ lines.push(` ${location || "(no file)"} confidence: ${suspect.confidence} (${suspect.evidenceKind})`);
45
+ lines.push(` why: ${suspect.reason}`);
46
+ };
47
+ const formatRegression = (regression, regressionNumber) => {
48
+ const kindText = regression.kind === "new" ? "NEW error" : "SPIKE in an existing error";
49
+ const deployText = `deploy ${shortSha(regression.deploySha)}${regression.deployTime === null ? "" : ` (${regression.deployTime})`}`;
50
+ lines.push(` ${regressionNumber}. ${kindText} after ${deployText} severity: ${paint(severityColor[regression.severity], regression.severity)}`);
51
+ lines.push(` ${regression.headline}`);
52
+ lines.push(` first seen ${regression.firstSeen}; ${plural(regression.occurrences, "time")} since ` +
53
+ `(${formatRate(regression.postDeployRatePerHour)}; ${formatRate(regression.baselineRatePerHour)} before)`);
54
+ lines.push(` status: ${regression.restoredAt === null ? paint("red", "ongoing") : paint("green", `restored at ${regression.restoredAt}`)}`);
55
+ if (regression.isAmbiguous)
56
+ lines.push(" note: another deploy happened shortly before this one; either could be the cause");
57
+ if (regression.suspects.length === 0) {
58
+ lines.push(` Suspects: ${regression.suspectMessage ?? "none"}`);
59
+ }
60
+ else {
61
+ lines.push(" Suspects:");
62
+ regression.suspects.forEach((suspect, suspectIndex) => formatSuspect(suspect, suspectIndex + 1));
63
+ }
64
+ };
65
+ const formatService = (serviceReport) => {
66
+ lines.push("", paint("bold", `== ${serviceReport.serviceName} ==`));
67
+ for (const note of serviceReport.notes)
68
+ lines.push(`Note: ${note}`);
69
+ if (serviceReport.isSkipped)
70
+ return;
71
+ const judgedCount = serviceReport.deploys.filter((deploy) => deploy.status === "checked").length;
72
+ const failedCount = serviceReport.deploys.filter((deploy) => deploy.isFailed).length;
73
+ lines.push(`Log lines in: ${plural(serviceReport.logEntryCount, "error/warning line")} -> ${plural(serviceReport.errorGroupCount, "error group")}`);
74
+ lines.push(`Deploys: ${serviceReport.deploys.length} (${judgedCount} judged, ${failedCount} failed)`);
75
+ for (const deploy of serviceReport.deploys) {
76
+ if (deploy.status === "insufficient_baseline") {
77
+ lines.push(` deploy ${shortSha(deploy.deploySha)} (${deploy.time}): insufficient baseline (less than 24 hours of logs before it), not judged`);
78
+ }
79
+ }
80
+ lines.push(`Regressions: ${serviceReport.regressions.length}`);
81
+ serviceReport.regressions.forEach((regression, regressionIndex) => formatRegression(regression, regressionIndex + 1));
82
+ formatMetrics(serviceReport.metrics, "");
83
+ };
84
+ // Every string from the report (log-derived or not) is made plain ASCII
85
+ // first; the only escape codes in the output are the ones paint() adds.
86
+ const safeReport = toPlainAsciiEverywhere(report);
87
+ lines.push(paint("bold", "vika report") + ` - as of ${safeReport.asOf ?? "(no logs read yet)"} (the latest log line read)`);
88
+ safeReport.services.forEach(formatService);
89
+ lines.push("", paint("bold", "== All services =="));
90
+ formatMetrics(safeReport.metrics, "");
91
+ return `${lines.join("\n")}\n`;
92
+ }
93
+ // A copy of the value with toPlainAscii applied to every string inside it.
94
+ function toPlainAsciiEverywhere(value) {
95
+ if (typeof value === "string")
96
+ return toPlainAscii(value);
97
+ if (Array.isArray(value))
98
+ return value.map((item) => toPlainAsciiEverywhere(item));
99
+ if (value !== null && typeof value === "object") {
100
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, toPlainAsciiEverywhere(item)]));
101
+ }
102
+ return value;
103
+ }
104
+ //# sourceMappingURL=format-terminal-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-terminal-report.js","sourceRoot":"","sources":["../../src/reporting/format-terminal-report.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAG9I,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,uCAAuC;AACvC,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AAC5C,C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ACtH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,96 @@
1
+ // The report's JSON shape as zod schemas: the documented contract of
2
+ // `vika report --json` and GET /api/report (docs/report-schema.md). The
3
+ // TypeScript types in report-types.ts are made from these, so the code and
4
+ // the documented schema can never drift apart.
5
+ //
6
+ // REPORT_SCHEMA_VERSION changes only when a field is removed or its meaning
7
+ // changes. Adding a field does not change it.
8
+ import { z } from "zod";
9
+ export const REPORT_SCHEMA_VERSION = 1;
10
+ // Every number is derived from logs only (not from incident records), and says so.
11
+ export const LOG_DERIVED = "log-derived";
12
+ export const NOT_ENOUGH_DATA = "not enough data";
13
+ const isoTimestamp = z.string().refine((text) => !Number.isNaN(Date.parse(text)), { error: "must be an ISO timestamp" });
14
+ const commitSha = z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/);
15
+ export const suspectSchema = z.strictObject({
16
+ commitSha,
17
+ prNumber: z.number().int().nullable(),
18
+ confidence: z.enum(["high", "medium", "low"]),
19
+ evidenceKind: z.enum([
20
+ "blamed-line-changed",
21
+ "same-function-changed",
22
+ "call-chain-function-changed",
23
+ "file-changed",
24
+ "dependency-or-config-change",
25
+ "timing-only",
26
+ ]),
27
+ reason: z.string(),
28
+ filePath: z.string(),
29
+ lineNumber: z.number().int().nullable(),
30
+ lineText: z.string().nullable(),
31
+ author: z.strictObject({ name: z.string(), email: z.string() }),
32
+ isInDeployRange: z.literal(true),
33
+ isBot: z.boolean(),
34
+ });
35
+ export const changeFailureRateSchema = z.strictObject({
36
+ label: z.literal(LOG_DERIVED),
37
+ value: z.number().min(0).max(1).nullable(), // failed / judged; null when nothing was judged
38
+ failedDeploys: z.number().int().min(0),
39
+ judgedDeploys: z.number().int().min(0), // not starting points, not cold starts
40
+ note: z.string().nullable(), // "not enough data" when value is null
41
+ });
42
+ export const medianTimeToRestoreSchema = z.strictObject({
43
+ label: z.literal(LOG_DERIVED),
44
+ valueMinutes: z.number().min(0).nullable(), // first seen -> restored, median over restored regressions
45
+ restoredRegressions: z.number().int().min(0),
46
+ note: z.string().nullable(),
47
+ });
48
+ export const ongoingRegressionsSchema = z.strictObject({
49
+ label: z.literal(LOG_DERIVED),
50
+ value: z.number().int().min(0), // regressions not restored by the end of the logs
51
+ });
52
+ export const deliveryMetricsSchema = z.strictObject({
53
+ changeFailureRate: changeFailureRateSchema,
54
+ medianTimeToRestore: medianTimeToRestoreSchema,
55
+ ongoingRegressions: ongoingRegressionsSchema,
56
+ });
57
+ export const reportDeploySchema = z.strictObject({
58
+ deploySha: commitSha,
59
+ time: isoTimestamp,
60
+ status: z.enum(["checked", "insufficient_baseline", "starting_point"]),
61
+ isFailed: z.boolean(), // at least one medium or high regression
62
+ });
63
+ export const reportRegressionSchema = z.strictObject({
64
+ fingerprint: z.string(),
65
+ kind: z.enum(["new", "spike"]),
66
+ severity: z.enum(["high", "medium", "low"]),
67
+ headline: z.string(), // one redacted line describing the error
68
+ exceptionType: z.string().nullable(),
69
+ deploySha: commitSha,
70
+ deployTime: isoTimestamp.nullable(),
71
+ firstSeen: isoTimestamp,
72
+ occurrences: z.number().int().min(0),
73
+ baselineRatePerHour: z.number().min(0),
74
+ postDeployRatePerHour: z.number().min(0),
75
+ isAmbiguous: z.boolean(), // another deploy happened shortly before this one
76
+ restoredAt: isoTimestamp.nullable(), // null = still ongoing at the end of the logs
77
+ suspects: z.array(suspectSchema), // strongest first, at most 3
78
+ suspectMessage: z.string().nullable(), // why there are no suspects, when there are none
79
+ });
80
+ export const serviceReportSchema = z.strictObject({
81
+ serviceName: z.string(),
82
+ isSkipped: z.boolean(), // busy or failed this run; nothing below was computed
83
+ notes: z.array(z.string()),
84
+ logEntryCount: z.number().int().min(0), // error and warning lines stored
85
+ errorGroupCount: z.number().int().min(0),
86
+ deploys: z.array(reportDeploySchema),
87
+ regressions: z.array(reportRegressionSchema),
88
+ metrics: deliveryMetricsSchema,
89
+ });
90
+ export const reportSchema = z.strictObject({
91
+ schemaVersion: z.literal(REPORT_SCHEMA_VERSION),
92
+ asOf: isoTimestamp.nullable(), // the latest log timestamp read, across all services
93
+ services: z.array(serviceReportSchema),
94
+ metrics: deliveryMetricsSchema, // all services rolled up
95
+ });
96
+ //# sourceMappingURL=report-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-schema.js","sourceRoot":"","sources":["../../src/reporting/report-schema.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,wEAAwE;AACxE,2EAA2E;AAC3E,+CAA+C;AAC/C,EAAE;AACF,4EAA4E;AAC5E,8CAA8C;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,mFAAmF;AACnF,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC,CAAC;AACzH,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,YAAY,CAAC;IAC1C,SAAS;IACT,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACrC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7C,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC;QACnB,qBAAqB;QACrB,uBAAuB;QACvB,6BAA6B;QAC7B,cAAc;QACd,6BAA6B;QA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C5C,OAAO,EAAE,qBAAqB;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;IACzC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAC/C,IAAI,EAAE,YAAY,CAAC,QAAQ,EAAE,EAAE,qDAAqD;IACpF,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;IACtC,OAAO,EAAE,qBAAqB,EAAE,yBAAyB;CAC1D,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { LOG_DERIVED, NOT_ENOUGH_DATA, REPORT_SCHEMA_VERSION } from "./report-schema.js";
2
+ //# sourceMappingURL=report-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-types.js","sourceRoot":"","sources":["../../src/reporting/report-types.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,31 @@
1
+ // "./src/a.ts" means "src/a.ts" to git.
2
+ const removeLeadingDotSlash = (filePath) => filePath.replace(/^(?:\.\/)+/, "");
3
+ // A prefix matches a whole folder name, not part of one: "/app" matches
4
+ // "/app/src/a.ts" but not "/application/a.ts".
5
+ function isPrefixOf(prefix, framePath) {
6
+ if (prefix === "" || !framePath.startsWith(prefix))
7
+ return false;
8
+ return prefix.endsWith("/") || framePath.length === prefix.length || framePath[prefix.length] === "/";
9
+ }
10
+ // With several prefixes, the longest matching one wins, so a specific rule
11
+ // ("/app/src/vendor") beats a general one ("/app/src").
12
+ export function applyPathMap(framePath, pathMap) {
13
+ const matchingPrefixes = Object.keys(pathMap ?? {}).filter((prefix) => isPrefixOf(prefix, framePath));
14
+ if (pathMap === undefined || matchingPrefixes.length === 0)
15
+ return removeLeadingDotSlash(framePath);
16
+ const longestPrefix = matchingPrefixes.reduce((longest, prefix) => (prefix.length > longest.length ? prefix : longest));
17
+ const mappedPath = pathMap[longestPrefix] + framePath.slice(longestPrefix.length);
18
+ // A mapped path is relative to the repo, so doubled and leading slashes go.
19
+ return removeLeadingDotSlash(mappedPath.replace(/\/{2,}/g, "/").replace(/^\/+/, ""));
20
+ }
21
+ // Only plain repo-relative paths can be looked up in git. Absolute paths
22
+ // (no path map, or a frame outside the app), "node:internal/..." frames and
23
+ // paths that climb out of the repo are left out.
24
+ export function isRepoRelativePath(filePath) {
25
+ return (filePath !== "" &&
26
+ !filePath.startsWith("/") &&
27
+ !filePath.startsWith("-") &&
28
+ !/^[A-Za-z][\w+.-]*:/.test(filePath) &&
29
+ !filePath.split("/").includes(".."));
30
+ }
31
+ //# sourceMappingURL=apply-path-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-path-map.js","sourceRoot":"","sources":["../../src/suspect-attribution/apply-path-map.ts"],"names":[],"mappings":"AAGA,wCAAwC;AACxC,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEvF,wEAAwE;AACxE,+CAA+C;AAC/C,SAAS,UAAU,CAAC,MAAc,EAAE,SAAiB;IACnD,IAAI,MAAM,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACjE,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC;AACxG,CAAC;AAED,2EAA2E;AAC3E,wDAAwD;AACxD,MAAM,UAAU,YAAY,CAAC,SAAiB,EAAE,OAA4B;IAC1E,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACtG,IAAI,OAAO,KAAK,SAAS,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACpG,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACxH,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAE,GAAG,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACnF,4EAA4E;IAC5E,OAAO,qBAAqB,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,yEAAyE;AACzE,4EAA4E;AAC5E,iDAAiD;AACjD,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,CACL,QAAQ,KAAK,EAAE;QACf,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;QACzB,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;QACzB,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC;QACpC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CACpC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,176 @@
1
+ // Names the suspect commits for one regression: reads the repo at the
2
+ // deployed sha (read-only), collects findings against the commits the
3
+ // deploy shipped, and lets the pure scorer rank them. Deterministic: no
4
+ // LLM, no database, no tickets.
5
+ //
6
+ // What it looks at, for the stack frames that point into the repo:
7
+ // top frame: blame its line; blame the lines that feed it; check the
8
+ // functions whose return values it reads; check its function
9
+ // other frames: check their functions (further down the call chain)
10
+ // every frame: was its file changed in the deploy at all?
11
+ // the whole deploy: lockfiles, config files and migrations it changed
12
+ import { assertSafeRevision } from "../deploys/run-git.js";
13
+ import { applyPathMap, isRepoRelativePath } from "./apply-path-map.js";
14
+ import { findCalleeLocation } from "./callee-files.js";
15
+ import { categorizeChangedFile } from "./changed-file-categories.js";
16
+ import { findCrashLineInputs } from "./crash-line-inputs.js";
17
+ import { findFunctionDefinitionLine, plainFunctionName } from "./function-names.js";
18
+ import { blameLine, listChangedFiles, listChangedFilesByCommit, listCommitsChangingFunction, listCommitsChangingLines, readBlameIgnoreRevisions, readFileAtCommit, } from "./git-blame-reader.js";
19
+ import { scoreSuspects } from "./score-suspects.js";
20
+ export const FIRST_DEPLOY_MESSAGE = "first deploy, nothing to compare";
21
+ // When git can't find a frame's function by name, look at this many lines
22
+ // above and below the frame's line instead.
23
+ const FALLBACK_CONTEXT_LINES = 3;
24
+ function countLines(fileContent) {
25
+ const fileLines = fileContent.split("\n");
26
+ return fileContent.endsWith("\n") ? fileLines.length - 1 : fileLines.length;
27
+ }
28
+ function readLineText(fileContent, lineNumber) {
29
+ return fileContent.split("\n")[lineNumber - 1] ?? null;
30
+ }
31
+ function hasLine(frame, lineNumber) {
32
+ return Number.isInteger(lineNumber) && lineNumber >= 1 && lineNumber <= frame.lineCount;
33
+ }
34
+ // A finding with the fields most findings leave empty already filled in.
35
+ function makeFinding(fields) {
36
+ return { lineNumber: null, lineText: null, functionName: null, calleeName: null, fileCategory: null, ...fields };
37
+ }
38
+ // The frames whose files are in the repo at the deployed sha, in stack order.
39
+ // Others (library code, node internals, unmapped absolute paths) are skipped.
40
+ async function readRepoFrames(input, deploySha) {
41
+ const repoFrames = [];
42
+ for (const [frameIndex, frame] of input.topFrames.entries()) {
43
+ const filePath = applyPathMap(frame.file, input.pathMap);
44
+ if (!isRepoRelativePath(filePath))
45
+ continue;
46
+ const fileContent = await readFileAtCommit(input.repoPath, deploySha, filePath);
47
+ if (fileContent === undefined)
48
+ continue;
49
+ repoFrames.push({
50
+ frameIndex,
51
+ filePath,
52
+ lineNumber: frame.line,
53
+ functionName: plainFunctionName(frame.fn),
54
+ fileContent,
55
+ lineCount: countLines(fileContent),
56
+ });
57
+ }
58
+ return repoFrames;
59
+ }
60
+ // Commits in the range that changed the frame's function, found by name
61
+ // first and by the lines around the frame's line if git can't find the name.
62
+ async function listCommitsChangingFrameFunction(repoPath, previousSha, deploySha, frame) {
63
+ if (frame.functionName !== undefined) {
64
+ const commitShas = await listCommitsChangingFunction(repoPath, previousSha, deploySha, frame.filePath, frame.functionName);
65
+ if (commitShas !== undefined)
66
+ return commitShas;
67
+ }
68
+ if (!hasLine(frame, frame.lineNumber))
69
+ return [];
70
+ const startLine = Math.max(1, frame.lineNumber - FALLBACK_CONTEXT_LINES);
71
+ const endLine = Math.min(frame.lineCount, frame.lineNumber + FALLBACK_CONTEXT_LINES);
72
+ return listCommitsChangingLines(repoPath, previousSha, deploySha, frame.filePath, startLine, endLine);
73
+ }
74
+ // The top frame: its own line, the lines and functions that feed it.
75
+ async function collectTopFrameFindings(repoPath, previousSha, deploySha, topFrame, ignoredRevisions) {
76
+ if (!hasLine(topFrame, topFrame.lineNumber))
77
+ return [];
78
+ const findings = [];
79
+ const frameFields = { frameIndex: topFrame.frameIndex, functionName: topFrame.functionName ?? null };
80
+ const blamedLine = await blameLine(repoPath, deploySha, topFrame.filePath, topFrame.lineNumber, ignoredRevisions);
81
+ findings.push(makeFinding({
82
+ ...frameFields,
83
+ commitSha: blamedLine.commitSha,
84
+ strength: "blamed-line",
85
+ filePath: topFrame.filePath,
86
+ lineNumber: topFrame.lineNumber,
87
+ lineText: blamedLine.lineText,
88
+ }));
89
+ const crashLineInputs = findCrashLineInputs(topFrame.fileContent, topFrame.lineNumber, topFrame.functionName);
90
+ for (const inputLineNumber of crashLineInputs.inputLineNumbers) {
91
+ const blamedInputLine = await blameLine(repoPath, deploySha, topFrame.filePath, inputLineNumber, ignoredRevisions);
92
+ findings.push(makeFinding({
93
+ ...frameFields,
94
+ commitSha: blamedInputLine.commitSha,
95
+ strength: "crash-input-line",
96
+ filePath: topFrame.filePath,
97
+ lineNumber: inputLineNumber,
98
+ lineText: blamedInputLine.lineText,
99
+ }));
100
+ }
101
+ for (const calleeName of crashLineInputs.calleeNames) {
102
+ const calleeLocation = findCalleeLocation(topFrame.fileContent, topFrame.filePath, calleeName);
103
+ if (calleeLocation === undefined)
104
+ continue;
105
+ // The first candidate path that exists at the deployed sha is the file.
106
+ for (const candidatePath of calleeLocation.candidatePaths) {
107
+ const calleeFileContent = await readFileAtCommit(repoPath, deploySha, candidatePath);
108
+ if (calleeFileContent === undefined)
109
+ continue;
110
+ const definitionLine = findFunctionDefinitionLine(calleeFileContent, calleeLocation.definitionName);
111
+ const commitShas = definitionLine
112
+ ? ((await listCommitsChangingFunction(repoPath, previousSha, deploySha, candidatePath, calleeLocation.definitionName)) ?? [])
113
+ : [];
114
+ for (const commitSha of commitShas) {
115
+ findings.push(makeFinding({
116
+ ...frameFields,
117
+ commitSha,
118
+ strength: "crash-input-callee",
119
+ filePath: candidatePath,
120
+ lineNumber: definitionLine.lineNumber,
121
+ lineText: definitionLine.lineText,
122
+ calleeName: calleeLocation.definitionName,
123
+ }));
124
+ }
125
+ break;
126
+ }
127
+ }
128
+ return findings;
129
+ }
130
+ export async function attributeRegression(input) {
131
+ const { repoPath, deploySha, previousSha } = input;
132
+ if (previousSha === null)
133
+ return { suspects: [], message: FIRST_DEPLOY_MESSAGE };
134
+ assertSafeRevision(deploySha, "sha");
135
+ assertSafeRevision(previousSha, "sha");
136
+ const changedFiles = await listChangedFiles(repoPath, previousSha, deploySha);
137
+ const changedFilesByCommit = await listChangedFilesByCommit(repoPath, previousSha, deploySha);
138
+ const ignoredRevisions = await readBlameIgnoreRevisions(repoPath, deploySha);
139
+ const repoFrames = await readRepoFrames(input, deploySha);
140
+ const findings = [];
141
+ // Commits that changed a file, from the per-commit file lists.
142
+ const commitsChangingFile = (filePath) => [...changedFilesByCommit.entries()].filter(([, commitFiles]) => commitFiles.includes(filePath)).map(([commitSha]) => commitSha);
143
+ const topFrame = repoFrames[0];
144
+ if (topFrame !== undefined)
145
+ findings.push(...(await collectTopFrameFindings(repoPath, previousSha, deploySha, topFrame, ignoredRevisions)));
146
+ for (const frame of repoFrames) {
147
+ const frameFields = { frameIndex: frame.frameIndex, filePath: frame.filePath, functionName: frame.functionName ?? null };
148
+ const isTopFrame = frame === topFrame;
149
+ for (const commitSha of await listCommitsChangingFrameFunction(repoPath, previousSha, deploySha, frame)) {
150
+ findings.push(makeFinding({
151
+ ...frameFields,
152
+ commitSha,
153
+ strength: isTopFrame ? "same-function" : "lower-frame-function",
154
+ lineNumber: frame.lineNumber,
155
+ lineText: readLineText(frame.fileContent, frame.lineNumber),
156
+ }));
157
+ }
158
+ // Rule: only files the deploy really changed (git diff), credited to the
159
+ // commits that touched them.
160
+ if (changedFiles.includes(frame.filePath)) {
161
+ for (const commitSha of commitsChangingFile(frame.filePath))
162
+ findings.push(makeFinding({ ...frameFields, commitSha, strength: "file" }));
163
+ }
164
+ }
165
+ // Lockfiles, config files and migrations rank after every stack frame.
166
+ for (const filePath of changedFiles) {
167
+ const fileCategory = categorizeChangedFile(filePath);
168
+ if (fileCategory === undefined)
169
+ continue;
170
+ for (const commitSha of commitsChangingFile(filePath)) {
171
+ findings.push(makeFinding({ commitSha, strength: "dependency-or-config", frameIndex: input.topFrames.length, filePath, fileCategory }));
172
+ }
173
+ }
174
+ return scoreSuspects({ findings, commitsInRange: input.commitsInRange, changedFilesByCommit });
175
+ }
176
+ //# sourceMappingURL=attribute-regression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribute-regression.js","sourceRoot":"","sources":["../../src/suspect-attribution/attribute-regression.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,wEAAwE;AACxE,gCAAgC;AAChC,EAAE;AACF,mEAAmE;AACnE,2EAA2E;AA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KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC;aAC5D,CAAC,CACH,CAAC;QACJ,CAAC;QACD,yEAAyE;QACzE,6BAA6B;QAC7B,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1C,KAAK,MAAM,SAAS,IAAI,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,GAAG,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC3I,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACrD,IAAI,YAAY,KAAK,SAAS;YAAE,SAAS;QACzC,KAAK,MAAM,SAAS,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,sBAAsB,EAAE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;QAC1I,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,oBAAoB,EAAE,CAAC,CAAC;AACjG,CAAC"}
@@ -0,0 +1,8 @@
1
+ // Recognizes commits written by bots (dependency updaters, CI). Bots are
2
+ // still listed as suspects, but flagged, because a person has to own the fix.
3
+ const BOT_MARKERS = ["dependabot", "renovate", "github-actions", "[bot]"];
4
+ export function isBotAuthor(name, email) {
5
+ const nameAndEmail = `${name} ${email}`.toLowerCase();
6
+ return BOT_MARKERS.some((marker) => nameAndEmail.includes(marker));
7
+ }
8
+ //# sourceMappingURL=bot-authors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot-authors.js","sourceRoot":"","sources":["../../src/suspect-attribution/bot-authors.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAE9E,MAAM,WAAW,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAE1E,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,KAAa;IACrD,MAAM,YAAY,GAAG,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC;IACtD,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,53 @@
1
+ // Finds which repo file defines a function the failing code calls, by
2
+ // reading the calling file's imports. JavaScript and TypeScript only.
3
+ import { posix } from "node:path";
4
+ import { findFunctionDefinitionLine } from "./function-names.js";
5
+ const NAMED_IMPORT = /import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g;
6
+ const IMPORTED_NAME = /^(?:type\s+)?([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/;
7
+ // TypeScript projects import "./repo.js" but the source file is "./repo.ts".
8
+ const SOURCE_EXTENSIONS_FOR = {
9
+ ".js": [".ts", ".tsx"],
10
+ ".jsx": [".tsx"],
11
+ ".mjs": [".mts"],
12
+ ".cjs": [".cts"],
13
+ };
14
+ const SOURCE_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
15
+ function resolveImportPaths(importingFilePath, importSpecifier) {
16
+ const resolvedPath = posix.normalize(posix.join(posix.dirname(importingFilePath), importSpecifier));
17
+ if (resolvedPath === ".." || resolvedPath.startsWith("../"))
18
+ return []; // outside the repo
19
+ const extension = posix.extname(resolvedPath);
20
+ const sourceExtensions = SOURCE_EXTENSIONS_FOR[extension];
21
+ if (sourceExtensions !== undefined) {
22
+ const pathWithoutExtension = resolvedPath.slice(0, -extension.length);
23
+ return [...sourceExtensions.map((sourceExtension) => pathWithoutExtension + sourceExtension), resolvedPath];
24
+ }
25
+ if (SOURCE_EXTENSIONS.includes(extension))
26
+ return [resolvedPath];
27
+ return [`${resolvedPath}.ts`, `${resolvedPath}.tsx`, `${resolvedPath}.js`, `${resolvedPath}/index.ts`, `${resolvedPath}/index.js`];
28
+ }
29
+ // Undefined when the function comes from a package (not this repo's code)
30
+ // or can't be found at all.
31
+ export function findCalleeLocation(fileContent, filePath, calleeName) {
32
+ for (const importMatch of fileContent.matchAll(NAMED_IMPORT)) {
33
+ const importSpecifier = importMatch[2];
34
+ for (const importedItem of importMatch[1].split(",")) {
35
+ const nameMatch = IMPORTED_NAME.exec(importedItem.trim());
36
+ if (!nameMatch)
37
+ continue;
38
+ const localName = nameMatch[2] ?? nameMatch[1];
39
+ if (localName !== calleeName)
40
+ continue;
41
+ // Only relative imports point into the repo; anything else is a package.
42
+ if (!importSpecifier.startsWith("."))
43
+ return undefined;
44
+ const candidatePaths = resolveImportPaths(filePath, importSpecifier);
45
+ return candidatePaths.length === 0 ? undefined : { definitionName: nameMatch[1], candidatePaths };
46
+ }
47
+ }
48
+ // Not imported: maybe defined in the same file.
49
+ if (findFunctionDefinitionLine(fileContent, calleeName) !== undefined)
50
+ return { definitionName: calleeName, candidatePaths: [filePath] };
51
+ return undefined;
52
+ }
53
+ //# sourceMappingURL=callee-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callee-files.js","sourceRoot":"","sources":["../../src/suspect-attribution/callee-files.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAOjE,MAAM,YAAY,GAAG,6DAA6D,CAAC;AACnF,MAAM,aAAa,GAAG,iEAAiE,CAAC;AAEx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n.lock",
5
+ "pnpm-lock.yaml",
6
+ "bun.lock",
7
+ "bun.lockb",
8
+ "Gemfile.lock",
9
+ "poetry.lock",
10
+ "Pipfile.lock",
11
+ "uv.lock",
12
+ "Cargo.lock",
13
+ "go.sum",
14
+ "composer.lock",
15
+ ]);
16
+ const CONFIG_FILE_NAMES = new Set(["package.json", "Dockerfile", ".env"]);
17
+ const CONFIG_EXTENSIONS = [".yaml", ".yml", ".toml", ".ini", ".conf", ".cfg", ".properties"];
18
+ const CONFIG_NAME_PATTERNS = [/^\.env\./, /\.config\.(?:js|cjs|mjs|ts|json)$/, /^docker-compose\./];
19
+ const CONFIG_FOLDERS = new Set(["config", "configs", "configuration", "settings"]);
20
+ const MIGRATION_FOLDERS = new Set(["migrations", "migration", "migrate"]);
21
+ // Returns undefined for ordinary source files.
22
+ export function categorizeChangedFile(filePath) {
23
+ const pathParts = filePath.split("/");
24
+ const fileName = pathParts[pathParts.length - 1] ?? "";
25
+ const folderNames = pathParts.slice(0, -1);
26
+ if (LOCKFILE_NAMES.has(fileName))
27
+ return "lockfile";
28
+ // Migrations first: a .sql or .yaml file inside migrations/ is a migration, not config.
29
+ if (folderNames.some((folderName) => MIGRATION_FOLDERS.has(folderName)) || fileName.endsWith(".sql"))
30
+ return "migration";
31
+ if (CONFIG_FILE_NAMES.has(fileName) ||
32
+ CONFIG_EXTENSIONS.some((extension) => fileName.endsWith(extension)) ||
33
+ CONFIG_NAME_PATTERNS.some((pattern) => pattern.test(fileName)) ||
34
+ folderNames.some((folderName) => CONFIG_FOLDERS.has(folderName))) {
35
+ return "config file";
36
+ }
37
+ return undefined;
38
+ }
39
+ //# sourceMappingURL=changed-file-categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changed-file-categories.js","sourceRoot":"","sources":["../../src/suspect-attribution/changed-file-categories.ts"],"names":[],"mappings":"AAIA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,mBAAmB;IACnB,qBAAqB;IACrB,WAAW;I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