@resolveio/server-lib 22.3.196 → 22.3.197

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 (745) hide show
  1. package/.nodemon.json +5 -0
  2. package/.vscode/settings.json +21 -0
  3. package/AGENTS.md +195 -0
  4. package/README.md +22 -0
  5. package/build_package.sh +5 -0
  6. package/compileDTS.pl +64 -0
  7. package/docs/ai-assistant-nightly-eval.md +65 -0
  8. package/docs/ai-assistant-preflight-checklist.md +23 -0
  9. package/docs/ai-assistant-report-builder-bridge-playbook.md +115 -0
  10. package/eslint-plugin-custom/index.js +7 -0
  11. package/eslint-plugin-custom/rules/no-filter-zero-index.js +44 -0
  12. package/eslint.config.js +103 -0
  13. package/gulpfile.js +216 -0
  14. package/methodAndPublicationListGenerator.py +375 -0
  15. package/mongodbensurers.js +2 -0
  16. package/mongostop.js +3 -0
  17. package/package.json +1 -1
  18. package/scripts/cleanup-bypassed-callmethod-logs.js +616 -0
  19. package/settings.development.json +25 -0
  20. package/settings.development.redacted.json +25 -0
  21. package/src/.env +12 -0
  22. package/src/ai/assistant-core-heuristics.ts +379 -0
  23. package/src/ai/resolveio-platform-intelligence-memory-corpus.ts +185 -0
  24. package/src/ai/resolveio-platform-intelligence-memory.ts +325 -0
  25. package/{ai/resolveio-platform-intelligence-types.d.ts → src/ai/resolveio-platform-intelligence-types.ts} +20 -15
  26. package/src/ai/resolveio-platform-intelligence.ts +462 -0
  27. package/src/client-server-app.ts +12 -0
  28. package/src/collections/ai-run.collection.ts +117 -0
  29. package/src/collections/ai-terminal-conversation.collection.ts +91 -0
  30. package/src/collections/ai-terminal-issue-report.collection.ts +99 -0
  31. package/src/collections/ai-terminal-message.collection.ts +77 -0
  32. package/src/collections/app-setting.collection.ts +104 -0
  33. package/src/collections/app-status.collection.ts +58 -0
  34. package/src/collections/communication-metric.collection.ts +84 -0
  35. package/src/collections/counter.collection.ts +56 -0
  36. package/src/collections/cron-job-history.collection.ts +94 -0
  37. package/src/collections/cron-job.collection.ts +92 -0
  38. package/src/collections/customer-notification.collection.ts +131 -0
  39. package/src/collections/customer-portal-password.collection.ts +76 -0
  40. package/src/collections/email-history.collection.ts +134 -0
  41. package/src/collections/email-verified.collection.ts +62 -0
  42. package/src/collections/file.collection.ts +74 -0
  43. package/src/collections/flag-update.collection.ts +57 -0
  44. package/src/collections/flag.collection.ts +57 -0
  45. package/src/collections/log-method-latency.collection.ts +77 -0
  46. package/src/collections/log-subscription.collection.ts +80 -0
  47. package/src/collections/log.collection.ts +93 -0
  48. package/src/collections/logged-in-users.collection.ts +67 -0
  49. package/src/collections/monitor-cpu.collection.ts +65 -0
  50. package/src/collections/monitor-function.collection.ts +74 -0
  51. package/src/collections/monitor-memory.collection.ts +77 -0
  52. package/src/collections/monitor-mongo.collection.ts +71 -0
  53. package/src/collections/notification.collection.ts +57 -0
  54. package/src/collections/openai-usage-ledger.collection.ts +131 -0
  55. package/src/collections/report-builder-dashboard-builder.collection.ts +109 -0
  56. package/src/collections/report-builder-library.collection.ts +89 -0
  57. package/src/collections/report-builder-report.collection.ts +184 -0
  58. package/src/collections/user-group.collection.ts +89 -0
  59. package/src/collections/user-guide.collection.ts +57 -0
  60. package/src/collections/user.collection.ts +181 -0
  61. package/src/cron/cron.ts +117 -0
  62. package/src/fixtures/cron-jobs.ts +95 -0
  63. package/src/fixtures/init.ts +35 -0
  64. package/src/http/auth.ts +818 -0
  65. package/src/http/health.ts +7 -0
  66. package/src/http/home.ts +90 -0
  67. package/src/http/slow-query-publication.ts +49 -0
  68. package/src/index.ts +1 -0
  69. package/src/managers/ai-assistant-codex-manager.manager.ts +1131 -0
  70. package/src/managers/ai-run-evidence.manager.ts +264 -0
  71. package/src/managers/communication-metric.manager.ts +82 -0
  72. package/src/managers/cron.manager.ts +333 -0
  73. package/src/managers/customer-notification-content.manager.ts +236 -0
  74. package/src/managers/diagnostic-manager-bootstrap.ts +165 -0
  75. package/src/managers/error-auto-fix.manager.ts +2767 -0
  76. package/src/managers/local-log.manager.ts +113 -0
  77. package/src/managers/method.manager.ts +1857 -0
  78. package/src/managers/mongo.manager.ts +4575 -0
  79. package/src/managers/monitor.manager.ts +507 -0
  80. package/src/managers/openai-usage-ledger.manager.ts +112 -0
  81. package/src/managers/slow-query-verifier.manager.ts +3590 -0
  82. package/src/managers/slow-query.manager.ts +519 -0
  83. package/src/managers/subscription.manager.ts +3128 -0
  84. package/src/managers/websocket.manager.ts +746 -0
  85. package/src/managers/worker-dispatcher.manager.ts +1360 -0
  86. package/src/managers/worker-server.manager.ts +536 -0
  87. package/src/methods/accounts.ts +532 -0
  88. package/src/methods/ai-terminal.ts +23825 -0
  89. package/src/methods/app-settings.ts +114 -0
  90. package/src/methods/aws.ts +649 -0
  91. package/src/methods/collections.ts +641 -0
  92. package/src/methods/counters.ts +69 -0
  93. package/src/methods/cron-jobs.ts +2614 -0
  94. package/src/methods/customer-notifications.ts +458 -0
  95. package/src/methods/diagnostics.ts +616 -0
  96. package/src/methods/flag-updates.ts +7 -0
  97. package/src/methods/flags.ts +7 -0
  98. package/src/methods/logs.ts +657 -0
  99. package/src/methods/mongo-explorer.ts +1880 -0
  100. package/src/methods/monitor.ts +540 -0
  101. package/src/methods/pdf.ts +1236 -0
  102. package/src/methods/publications.ts +129 -0
  103. package/src/methods/report-builder.ts +3300 -0
  104. package/src/methods/support.ts +335 -0
  105. package/src/models/ai-run.model.ts +27 -0
  106. package/src/models/ai-terminal-conversation.model.ts +19 -0
  107. package/src/models/ai-terminal-issue-report.model.ts +21 -0
  108. package/src/models/ai-terminal-message.model.ts +24 -0
  109. package/src/models/app-setting.model.ts +17 -0
  110. package/{models/app-status.model.d.ts → src/models/app-status.model.ts} +3 -2
  111. package/{models/billing-logged-in-users.model.d.ts → src/models/billing-logged-in-users.model.ts} +5 -4
  112. package/src/models/collection-document.model.ts +24 -0
  113. package/src/models/communication-metric.model.ts +23 -0
  114. package/{models/counter.model.d.ts → src/models/counter.model.ts} +4 -3
  115. package/src/models/cron-job-history.model.ts +16 -0
  116. package/src/models/cron-job.model.ts +15 -0
  117. package/src/models/customer-notification.model.ts +28 -0
  118. package/src/models/customer-portal-password.model.ts +12 -0
  119. package/src/models/dialog.model.ts +25 -0
  120. package/{models/email-history.model.js → src/models/email-history.model.ts} +36 -4
  121. package/{models/email-verified.model.d.ts → src/models/email-verified.model.ts} +6 -5
  122. package/{models/file.model.d.ts → src/models/file.model.ts} +8 -7
  123. package/{models/flag-update.model.d.ts → src/models/flag-update.model.ts} +4 -3
  124. package/{models/flag.model.d.ts → src/models/flag.model.ts} +4 -3
  125. package/src/models/log-method-latency.model.ts +11 -0
  126. package/{models/log-subscription.model.d.ts → src/models/log-subscription.model.ts} +11 -9
  127. package/src/models/log.model.ts +19 -0
  128. package/{models/logged-in-users.model.d.ts → src/models/logged-in-users.model.ts} +6 -5
  129. package/{models/method-response.model.d.ts → src/models/method-response.model.ts} +7 -6
  130. package/src/models/method.model.ts +25 -0
  131. package/{models/monitor-cpu.model.d.ts → src/models/monitor-cpu.model.ts} +9 -7
  132. package/src/models/monitor-function.model.ts +16 -0
  133. package/src/models/monitor-memory.model.ts +17 -0
  134. package/src/models/monitor-mongo.model.ts +15 -0
  135. package/{models/notification.model.d.ts → src/models/notification.model.ts} +6 -4
  136. package/src/models/openai-usage-ledger.model.ts +56 -0
  137. package/src/models/pagination.model.ts +35 -0
  138. package/src/models/permission.model.ts +14 -0
  139. package/src/models/report-builder-dashboard-builder.model.ts +29 -0
  140. package/src/models/report-builder-library.model.ts +20 -0
  141. package/src/models/report-builder-report.model.ts +136 -0
  142. package/src/models/report-builder.model.ts +68 -0
  143. package/src/models/select-data-label.model.ts +9 -0
  144. package/src/models/server-message.model.ts +31 -0
  145. package/src/models/slow-query-report.model.ts +23 -0
  146. package/src/models/subscription.model.ts +73 -0
  147. package/src/models/support-ticket.model.ts +104 -0
  148. package/src/models/user-group.model.ts +24 -0
  149. package/{models/user-guide.model.d.ts → src/models/user-guide.model.ts} +5 -4
  150. package/src/models/user.model.ts +96 -0
  151. package/src/private/images/ResolveIO.png +0 -0
  152. package/src/publications/ai-terminal.ts +73 -0
  153. package/src/publications/app-settings.ts +25 -0
  154. package/src/publications/app-status.ts +13 -0
  155. package/src/publications/cron-jobs.ts +40 -0
  156. package/src/publications/customer-notifications.ts +101 -0
  157. package/src/publications/files.ts +33 -0
  158. package/src/publications/flags-update.ts +19 -0
  159. package/src/publications/flags.ts +19 -0
  160. package/src/publications/logs.ts +163 -0
  161. package/src/publications/notifications.ts +13 -0
  162. package/src/publications/report-builder-dashboard-builders.ts +39 -0
  163. package/src/publications/report-builder-libraries.ts +41 -0
  164. package/src/publications/report-builder-reports.ts +47 -0
  165. package/src/publications/super-admin.ts +13 -0
  166. package/src/publications/user-groups.ts +12 -0
  167. package/src/publications/user-guides.ts +12 -0
  168. package/src/resolveio-server-app.ts +617 -0
  169. package/src/server-app.ts +3354 -0
  170. package/src/services/codex-client.ts +1231 -0
  171. package/src/services/openai-client.ts +265 -0
  172. package/src/types/error-report.ts +26 -0
  173. package/src/types/js-tiktoken.d.ts +11 -0
  174. package/src/types/slow-query-report.ts +28 -0
  175. package/src/util/ai-qa-policy.ts +925 -0
  176. package/src/util/ai-run-evidence-adapters.ts +4642 -0
  177. package/src/util/ai-run-evidence-dashboard.ts +323 -0
  178. package/src/util/ai-run-evidence-eval.ts +1057 -0
  179. package/src/util/ai-run-evidence.ts +1185 -0
  180. package/src/util/ai-runner-artifacts.ts +586 -0
  181. package/src/util/ai-runner-manager-autopilot.ts +961 -0
  182. package/src/util/ai-runner-manager-policy.ts +4806 -0
  183. package/src/util/ai-runner-qa-auth.ts +821 -0
  184. package/src/util/ai-runner-qa-tools.ts +3045 -0
  185. package/src/util/aicoder-runner-v6.ts +2979 -0
  186. package/src/util/common.ts +649 -0
  187. package/src/util/customer-portal-password.ts +183 -0
  188. package/src/util/error-reporter.ts +332 -0
  189. package/src/util/error-tracking.ts +79 -0
  190. package/src/util/openai-usage-cost.ts +114 -0
  191. package/src/util/report-builder-unwinds.ts +180 -0
  192. package/src/util/runner-process-janitor.ts +219 -0
  193. package/src/util/schema-report-builder.ts +448 -0
  194. package/src/util/slow-query-reporter.ts +216 -0
  195. package/src/util/subscription-dependency-context.ts +1096 -0
  196. package/src/util/support-runner-v5.ts +6573 -0
  197. package/src/util/tokenizer.ts +38 -0
  198. package/src/workers/codex-runner.worker.ts +142 -0
  199. package/start_server.sh +5 -0
  200. package/tests/ai-assistant-corpus-build.ts +484 -0
  201. package/tests/ai-assistant-corpus-replay-e2e.ts +774 -0
  202. package/tests/ai-assistant-data-parity-e2e.ts +1989 -0
  203. package/tests/ai-assistant-eval-triage.ts +831 -0
  204. package/tests/ai-assistant-openai-e2e.ts +1061 -0
  205. package/tests/ai-assistant-openai-git-e2e.ts +155 -0
  206. package/tests/ai-assistant-preflight-matrix.ts +215 -0
  207. package/tests/ai-assistant-routing-eval.test.ts +560 -0
  208. package/tests/ai-assistant-snf-live-eval.ts +975 -0
  209. package/tests/ai-assistant-utils.test.ts +3057 -0
  210. package/tests/ai-manager-autopilot-snapshot.test.ts +193 -0
  211. package/tests/ai-manager-recovery-checkpoint.test.ts +1287 -0
  212. package/tests/ai-run-eval.test.ts +132 -0
  213. package/tests/ai-run-evidence.test.ts +2129 -0
  214. package/tests/ai-runner-contract.test.ts +488 -0
  215. package/tests/aicoder-runner-v6.test.ts +751 -0
  216. package/tests/error-reporter.test.ts +145 -0
  217. package/tests/method-publication-generator.test.ts +46 -0
  218. package/tests/report-builder-linking.test.ts +79 -0
  219. package/tests/resolveio-platform-intelligence.test.ts +352 -0
  220. package/tests/server-app-cron-owner.test.ts +127 -0
  221. package/tests/subscription-connect-race.test.ts +158 -0
  222. package/tests/subscription-dependency-context.test.ts +324 -0
  223. package/tests/subscription-manager-collection-tracking.test.ts +86 -0
  224. package/tests/subscription-manager-invalidation.test.ts +86 -0
  225. package/tests/support-runner-v5.test.ts +1473 -0
  226. package/tsconfig.json +34 -0
  227. package/ai/assistant-core-heuristics.d.ts +0 -11
  228. package/ai/assistant-core-heuristics.js +0 -356
  229. package/ai/assistant-core-heuristics.js.map +0 -1
  230. package/ai/resolveio-platform-intelligence-memory-corpus.d.ts +0 -3
  231. package/ai/resolveio-platform-intelligence-memory-corpus.js +0 -214
  232. package/ai/resolveio-platform-intelligence-memory-corpus.js.map +0 -1
  233. package/ai/resolveio-platform-intelligence-memory.d.ts +0 -20
  234. package/ai/resolveio-platform-intelligence-memory.js +0 -341
  235. package/ai/resolveio-platform-intelligence-memory.js.map +0 -1
  236. package/ai/resolveio-platform-intelligence-types.js +0 -4
  237. package/ai/resolveio-platform-intelligence-types.js.map +0 -1
  238. package/ai/resolveio-platform-intelligence.d.ts +0 -6
  239. package/ai/resolveio-platform-intelligence.js +0 -463
  240. package/ai/resolveio-platform-intelligence.js.map +0 -1
  241. package/client-server-app.d.ts +0 -1
  242. package/client-server-app.js +0 -68
  243. package/client-server-app.js.map +0 -1
  244. package/collections/ai-run.collection.d.ts +0 -3
  245. package/collections/ai-run.collection.js +0 -170
  246. package/collections/ai-run.collection.js.map +0 -1
  247. package/collections/ai-terminal-conversation.collection.d.ts +0 -2
  248. package/collections/ai-terminal-conversation.collection.js +0 -140
  249. package/collections/ai-terminal-conversation.collection.js.map +0 -1
  250. package/collections/ai-terminal-issue-report.collection.d.ts +0 -2
  251. package/collections/ai-terminal-issue-report.collection.js +0 -148
  252. package/collections/ai-terminal-issue-report.collection.js.map +0 -1
  253. package/collections/ai-terminal-message.collection.d.ts +0 -2
  254. package/collections/ai-terminal-message.collection.js +0 -121
  255. package/collections/ai-terminal-message.collection.js.map +0 -1
  256. package/collections/app-setting.collection.d.ts +0 -3
  257. package/collections/app-setting.collection.js +0 -103
  258. package/collections/app-setting.collection.js.map +0 -1
  259. package/collections/app-status.collection.d.ts +0 -3
  260. package/collections/app-status.collection.js +0 -57
  261. package/collections/app-status.collection.js.map +0 -1
  262. package/collections/communication-metric.collection.d.ts +0 -2
  263. package/collections/communication-metric.collection.js +0 -133
  264. package/collections/communication-metric.collection.js.map +0 -1
  265. package/collections/counter.collection.d.ts +0 -3
  266. package/collections/counter.collection.js +0 -56
  267. package/collections/counter.collection.js.map +0 -1
  268. package/collections/cron-job-history.collection.d.ts +0 -3
  269. package/collections/cron-job-history.collection.js +0 -137
  270. package/collections/cron-job-history.collection.js.map +0 -1
  271. package/collections/cron-job.collection.d.ts +0 -3
  272. package/collections/cron-job.collection.js +0 -92
  273. package/collections/cron-job.collection.js.map +0 -1
  274. package/collections/customer-notification.collection.d.ts +0 -3
  275. package/collections/customer-notification.collection.js +0 -130
  276. package/collections/customer-notification.collection.js.map +0 -1
  277. package/collections/customer-portal-password.collection.d.ts +0 -3
  278. package/collections/customer-portal-password.collection.js +0 -75
  279. package/collections/customer-portal-password.collection.js.map +0 -1
  280. package/collections/email-history.collection.d.ts +0 -3
  281. package/collections/email-history.collection.js +0 -134
  282. package/collections/email-history.collection.js.map +0 -1
  283. package/collections/email-verified.collection.d.ts +0 -3
  284. package/collections/email-verified.collection.js +0 -62
  285. package/collections/email-verified.collection.js.map +0 -1
  286. package/collections/file.collection.d.ts +0 -3
  287. package/collections/file.collection.js +0 -74
  288. package/collections/file.collection.js.map +0 -1
  289. package/collections/flag-update.collection.d.ts +0 -3
  290. package/collections/flag-update.collection.js +0 -57
  291. package/collections/flag-update.collection.js.map +0 -1
  292. package/collections/flag.collection.d.ts +0 -3
  293. package/collections/flag.collection.js +0 -57
  294. package/collections/flag.collection.js.map +0 -1
  295. package/collections/log-method-latency.collection.d.ts +0 -3
  296. package/collections/log-method-latency.collection.js +0 -77
  297. package/collections/log-method-latency.collection.js.map +0 -1
  298. package/collections/log-subscription.collection.d.ts +0 -3
  299. package/collections/log-subscription.collection.js +0 -80
  300. package/collections/log-subscription.collection.js.map +0 -1
  301. package/collections/log.collection.d.ts +0 -3
  302. package/collections/log.collection.js +0 -93
  303. package/collections/log.collection.js.map +0 -1
  304. package/collections/logged-in-users.collection.d.ts +0 -3
  305. package/collections/logged-in-users.collection.js +0 -67
  306. package/collections/logged-in-users.collection.js.map +0 -1
  307. package/collections/monitor-cpu.collection.d.ts +0 -3
  308. package/collections/monitor-cpu.collection.js +0 -65
  309. package/collections/monitor-cpu.collection.js.map +0 -1
  310. package/collections/monitor-function.collection.d.ts +0 -3
  311. package/collections/monitor-function.collection.js +0 -74
  312. package/collections/monitor-function.collection.js.map +0 -1
  313. package/collections/monitor-memory.collection.d.ts +0 -3
  314. package/collections/monitor-memory.collection.js +0 -77
  315. package/collections/monitor-memory.collection.js.map +0 -1
  316. package/collections/monitor-mongo.collection.d.ts +0 -3
  317. package/collections/monitor-mongo.collection.js +0 -71
  318. package/collections/monitor-mongo.collection.js.map +0 -1
  319. package/collections/notification.collection.d.ts +0 -3
  320. package/collections/notification.collection.js +0 -57
  321. package/collections/notification.collection.js.map +0 -1
  322. package/collections/openai-usage-ledger.collection.d.ts +0 -2
  323. package/collections/openai-usage-ledger.collection.js +0 -188
  324. package/collections/openai-usage-ledger.collection.js.map +0 -1
  325. package/collections/report-builder-dashboard-builder.collection.d.ts +0 -3
  326. package/collections/report-builder-dashboard-builder.collection.js +0 -109
  327. package/collections/report-builder-dashboard-builder.collection.js.map +0 -1
  328. package/collections/report-builder-library.collection.d.ts +0 -3
  329. package/collections/report-builder-library.collection.js +0 -87
  330. package/collections/report-builder-library.collection.js.map +0 -1
  331. package/collections/report-builder-report.collection.d.ts +0 -4
  332. package/collections/report-builder-report.collection.js +0 -184
  333. package/collections/report-builder-report.collection.js.map +0 -1
  334. package/collections/user-group.collection.d.ts +0 -4
  335. package/collections/user-group.collection.js +0 -89
  336. package/collections/user-group.collection.js.map +0 -1
  337. package/collections/user-guide.collection.d.ts +0 -3
  338. package/collections/user-guide.collection.js +0 -57
  339. package/collections/user-guide.collection.js.map +0 -1
  340. package/collections/user.collection.d.ts +0 -4
  341. package/collections/user.collection.js +0 -180
  342. package/collections/user.collection.js.map +0 -1
  343. package/cron/cron.d.ts +0 -14
  344. package/cron/cron.js +0 -216
  345. package/cron/cron.js.map +0 -1
  346. package/fixtures/cron-jobs.d.ts +0 -1
  347. package/fixtures/cron-jobs.js +0 -150
  348. package/fixtures/cron-jobs.js.map +0 -1
  349. package/fixtures/init.d.ts +0 -1
  350. package/fixtures/init.js +0 -91
  351. package/fixtures/init.js.map +0 -1
  352. package/http/auth.d.ts +0 -2
  353. package/http/auth.js +0 -951
  354. package/http/auth.js.map +0 -1
  355. package/http/health.d.ts +0 -1
  356. package/http/health.js +0 -11
  357. package/http/health.js.map +0 -1
  358. package/http/home.d.ts +0 -1
  359. package/http/home.js +0 -134
  360. package/http/home.js.map +0 -1
  361. package/http/slow-query-publication.d.ts +0 -2
  362. package/http/slow-query-publication.js +0 -99
  363. package/http/slow-query-publication.js.map +0 -1
  364. package/index.d.ts +0 -1
  365. package/index.js +0 -19
  366. package/index.js.map +0 -1
  367. package/managers/ai-assistant-codex-manager.manager.d.ts +0 -67
  368. package/managers/ai-assistant-codex-manager.manager.js +0 -1113
  369. package/managers/ai-assistant-codex-manager.manager.js.map +0 -1
  370. package/managers/ai-run-evidence.manager.d.ts +0 -36
  371. package/managers/ai-run-evidence.manager.js +0 -377
  372. package/managers/ai-run-evidence.manager.js.map +0 -1
  373. package/managers/communication-metric.manager.d.ts +0 -16
  374. package/managers/communication-metric.manager.js +0 -134
  375. package/managers/communication-metric.manager.js.map +0 -1
  376. package/managers/cron.manager.d.ts +0 -20
  377. package/managers/cron.manager.js +0 -534
  378. package/managers/cron.manager.js.map +0 -1
  379. package/managers/customer-notification-content.manager.d.ts +0 -55
  380. package/managers/customer-notification-content.manager.js +0 -158
  381. package/managers/customer-notification-content.manager.js.map +0 -1
  382. package/managers/diagnostic-manager-bootstrap.d.ts +0 -9
  383. package/managers/diagnostic-manager-bootstrap.js +0 -260
  384. package/managers/diagnostic-manager-bootstrap.js.map +0 -1
  385. package/managers/error-auto-fix.manager.d.ts +0 -149
  386. package/managers/error-auto-fix.manager.js +0 -3064
  387. package/managers/error-auto-fix.manager.js.map +0 -1
  388. package/managers/local-log.manager.d.ts +0 -18
  389. package/managers/local-log.manager.js +0 -88
  390. package/managers/local-log.manager.js.map +0 -1
  391. package/managers/method.manager.d.ts +0 -84
  392. package/managers/method.manager.js +0 -1964
  393. package/managers/method.manager.js.map +0 -1
  394. package/managers/mongo.manager.d.ts +0 -224
  395. package/managers/mongo.manager.js +0 -5000
  396. package/managers/mongo.manager.js.map +0 -1
  397. package/managers/monitor.manager.d.ts +0 -70
  398. package/managers/monitor.manager.js +0 -550
  399. package/managers/monitor.manager.js.map +0 -1
  400. package/managers/openai-usage-ledger.manager.d.ts +0 -30
  401. package/managers/openai-usage-ledger.manager.js +0 -142
  402. package/managers/openai-usage-ledger.manager.js.map +0 -1
  403. package/managers/slow-query-verifier.manager.d.ts +0 -144
  404. package/managers/slow-query-verifier.manager.js +0 -3857
  405. package/managers/slow-query-verifier.manager.js.map +0 -1
  406. package/managers/slow-query.manager.d.ts +0 -28
  407. package/managers/slow-query.manager.js +0 -468
  408. package/managers/slow-query.manager.js.map +0 -1
  409. package/managers/subscription.manager.d.ts +0 -169
  410. package/managers/subscription.manager.js +0 -3434
  411. package/managers/subscription.manager.js.map +0 -1
  412. package/managers/websocket.manager.d.ts +0 -73
  413. package/managers/websocket.manager.js +0 -673
  414. package/managers/websocket.manager.js.map +0 -1
  415. package/managers/worker-dispatcher.manager.d.ts +0 -120
  416. package/managers/worker-dispatcher.manager.js +0 -1266
  417. package/managers/worker-dispatcher.manager.js.map +0 -1
  418. package/managers/worker-server.manager.d.ts +0 -35
  419. package/managers/worker-server.manager.js +0 -582
  420. package/managers/worker-server.manager.js.map +0 -1
  421. package/methods/accounts.d.ts +0 -2
  422. package/methods/accounts.js +0 -624
  423. package/methods/accounts.js.map +0 -1
  424. package/methods/ai-terminal.d.ts +0 -338
  425. package/methods/ai-terminal.js +0 -23454
  426. package/methods/ai-terminal.js.map +0 -1
  427. package/methods/app-settings.d.ts +0 -2
  428. package/methods/app-settings.js +0 -169
  429. package/methods/app-settings.js.map +0 -1
  430. package/methods/aws.d.ts +0 -2
  431. package/methods/aws.js +0 -877
  432. package/methods/aws.js.map +0 -1
  433. package/methods/collections.d.ts +0 -2
  434. package/methods/collections.js +0 -719
  435. package/methods/collections.js.map +0 -1
  436. package/methods/counters.d.ts +0 -2
  437. package/methods/counters.js +0 -113
  438. package/methods/counters.js.map +0 -1
  439. package/methods/cron-jobs.d.ts +0 -2
  440. package/methods/cron-jobs.js +0 -2475
  441. package/methods/cron-jobs.js.map +0 -1
  442. package/methods/customer-notifications.d.ts +0 -2
  443. package/methods/customer-notifications.js +0 -528
  444. package/methods/customer-notifications.js.map +0 -1
  445. package/methods/diagnostics.d.ts +0 -2
  446. package/methods/diagnostics.js +0 -703
  447. package/methods/diagnostics.js.map +0 -1
  448. package/methods/flag-updates.d.ts +0 -2
  449. package/methods/flag-updates.js +0 -8
  450. package/methods/flag-updates.js.map +0 -1
  451. package/methods/flags.d.ts +0 -2
  452. package/methods/flags.js +0 -8
  453. package/methods/flags.js.map +0 -1
  454. package/methods/logs.d.ts +0 -2
  455. package/methods/logs.js +0 -751
  456. package/methods/logs.js.map +0 -1
  457. package/methods/mongo-explorer.d.ts +0 -2
  458. package/methods/mongo-explorer.js +0 -1808
  459. package/methods/mongo-explorer.js.map +0 -1
  460. package/methods/monitor.d.ts +0 -2
  461. package/methods/monitor.js +0 -543
  462. package/methods/monitor.js.map +0 -1
  463. package/methods/pdf.d.ts +0 -2
  464. package/methods/pdf.js +0 -1216
  465. package/methods/pdf.js.map +0 -1
  466. package/methods/publications.d.ts +0 -1
  467. package/methods/publications.js +0 -183
  468. package/methods/publications.js.map +0 -1
  469. package/methods/report-builder.d.ts +0 -2
  470. package/methods/report-builder.js +0 -3094
  471. package/methods/report-builder.js.map +0 -1
  472. package/methods/support.d.ts +0 -2
  473. package/methods/support.js +0 -430
  474. package/methods/support.js.map +0 -1
  475. package/models/ai-run.model.d.ts +0 -19
  476. package/models/ai-run.model.js +0 -4
  477. package/models/ai-run.model.js.map +0 -1
  478. package/models/ai-terminal-conversation.model.d.ts +0 -17
  479. package/models/ai-terminal-conversation.model.js +0 -4
  480. package/models/ai-terminal-conversation.model.js.map +0 -1
  481. package/models/ai-terminal-issue-report.model.d.ts +0 -19
  482. package/models/ai-terminal-issue-report.model.js +0 -4
  483. package/models/ai-terminal-issue-report.model.js.map +0 -1
  484. package/models/ai-terminal-message.model.d.ts +0 -22
  485. package/models/ai-terminal-message.model.js +0 -4
  486. package/models/ai-terminal-message.model.js.map +0 -1
  487. package/models/app-setting.model.d.ts +0 -16
  488. package/models/app-setting.model.js +0 -4
  489. package/models/app-setting.model.js.map +0 -1
  490. package/models/app-status.model.js +0 -4
  491. package/models/app-status.model.js.map +0 -1
  492. package/models/billing-logged-in-users.model.js +0 -4
  493. package/models/billing-logged-in-users.model.js.map +0 -1
  494. package/models/collection-document.model.d.ts +0 -21
  495. package/models/collection-document.model.js +0 -4
  496. package/models/collection-document.model.js.map +0 -1
  497. package/models/communication-metric.model.d.ts +0 -20
  498. package/models/communication-metric.model.js +0 -4
  499. package/models/communication-metric.model.js.map +0 -1
  500. package/models/counter.model.js +0 -4
  501. package/models/counter.model.js.map +0 -1
  502. package/models/cron-job-history.model.d.ts +0 -15
  503. package/models/cron-job-history.model.js +0 -4
  504. package/models/cron-job-history.model.js.map +0 -1
  505. package/models/cron-job.model.d.ts +0 -14
  506. package/models/cron-job.model.js +0 -4
  507. package/models/cron-job.model.js.map +0 -1
  508. package/models/customer-notification.model.d.ts +0 -26
  509. package/models/customer-notification.model.js +0 -4
  510. package/models/customer-notification.model.js.map +0 -1
  511. package/models/customer-portal-password.model.d.ts +0 -11
  512. package/models/customer-portal-password.model.js +0 -4
  513. package/models/customer-portal-password.model.js.map +0 -1
  514. package/models/dialog.model.d.ts +0 -23
  515. package/models/dialog.model.js +0 -4
  516. package/models/dialog.model.js.map +0 -1
  517. package/models/email-history.model.d.ts +0 -32
  518. package/models/email-history.model.js.map +0 -1
  519. package/models/email-verified.model.js +0 -4
  520. package/models/email-verified.model.js.map +0 -1
  521. package/models/file.model.js +0 -4
  522. package/models/file.model.js.map +0 -1
  523. package/models/flag-update.model.js +0 -4
  524. package/models/flag-update.model.js.map +0 -1
  525. package/models/flag.model.js +0 -4
  526. package/models/flag.model.js.map +0 -1
  527. package/models/log-method-latency.model.d.ts +0 -10
  528. package/models/log-method-latency.model.js +0 -4
  529. package/models/log-method-latency.model.js.map +0 -1
  530. package/models/log-subscription.model.js +0 -4
  531. package/models/log-subscription.model.js.map +0 -1
  532. package/models/log.model.d.ts +0 -17
  533. package/models/log.model.js +0 -4
  534. package/models/log.model.js.map +0 -1
  535. package/models/logged-in-users.model.js +0 -4
  536. package/models/logged-in-users.model.js.map +0 -1
  537. package/models/method-response.model.js +0 -4
  538. package/models/method-response.model.js.map +0 -1
  539. package/models/method.model.d.ts +0 -26
  540. package/models/method.model.js +0 -4
  541. package/models/method.model.js.map +0 -1
  542. package/models/monitor-cpu.model.js +0 -4
  543. package/models/monitor-cpu.model.js.map +0 -1
  544. package/models/monitor-function.model.d.ts +0 -14
  545. package/models/monitor-function.model.js +0 -4
  546. package/models/monitor-function.model.js.map +0 -1
  547. package/models/monitor-memory.model.d.ts +0 -15
  548. package/models/monitor-memory.model.js +0 -4
  549. package/models/monitor-memory.model.js.map +0 -1
  550. package/models/monitor-mongo.model.d.ts +0 -13
  551. package/models/monitor-mongo.model.js +0 -4
  552. package/models/monitor-mongo.model.js.map +0 -1
  553. package/models/notification.model.js +0 -4
  554. package/models/notification.model.js.map +0 -1
  555. package/models/openai-usage-ledger.model.d.ts +0 -30
  556. package/models/openai-usage-ledger.model.js +0 -4
  557. package/models/openai-usage-ledger.model.js.map +0 -1
  558. package/models/pagination.model.d.ts +0 -11
  559. package/models/pagination.model.js +0 -28
  560. package/models/pagination.model.js.map +0 -1
  561. package/models/permission.model.d.ts +0 -12
  562. package/models/permission.model.js +0 -4
  563. package/models/permission.model.js.map +0 -1
  564. package/models/report-builder-dashboard-builder.model.d.ts +0 -25
  565. package/models/report-builder-dashboard-builder.model.js +0 -4
  566. package/models/report-builder-dashboard-builder.model.js.map +0 -1
  567. package/models/report-builder-library.model.d.ts +0 -17
  568. package/models/report-builder-library.model.js +0 -4
  569. package/models/report-builder-library.model.js.map +0 -1
  570. package/models/report-builder-report.model.d.ts +0 -121
  571. package/models/report-builder-report.model.js +0 -4
  572. package/models/report-builder-report.model.js.map +0 -1
  573. package/models/report-builder.model.d.ts +0 -61
  574. package/models/report-builder.model.js +0 -4
  575. package/models/report-builder.model.js.map +0 -1
  576. package/models/select-data-label.model.d.ts +0 -9
  577. package/models/select-data-label.model.js +0 -4
  578. package/models/select-data-label.model.js.map +0 -1
  579. package/models/server-message.model.d.ts +0 -32
  580. package/models/server-message.model.js +0 -4
  581. package/models/server-message.model.js.map +0 -1
  582. package/models/slow-query-report.model.d.ts +0 -23
  583. package/models/slow-query-report.model.js +0 -4
  584. package/models/slow-query-report.model.js.map +0 -1
  585. package/models/subscription.model.d.ts +0 -31
  586. package/models/subscription.model.js +0 -4
  587. package/models/subscription.model.js.map +0 -1
  588. package/models/support-ticket.model.d.ts +0 -87
  589. package/models/support-ticket.model.js +0 -4
  590. package/models/support-ticket.model.js.map +0 -1
  591. package/models/user-group.model.d.ts +0 -20
  592. package/models/user-group.model.js +0 -4
  593. package/models/user-group.model.js.map +0 -1
  594. package/models/user-guide.model.js +0 -4
  595. package/models/user-guide.model.js.map +0 -1
  596. package/models/user.model.d.ts +0 -84
  597. package/models/user.model.js +0 -4
  598. package/models/user.model.js.map +0 -1
  599. package/private/images/ResolveIO.png +0 -0
  600. package/public_api.js +0 -127
  601. package/public_api.js.map +0 -1
  602. package/publications/ai-terminal.d.ts +0 -1
  603. package/publications/ai-terminal.js +0 -122
  604. package/publications/ai-terminal.js.map +0 -1
  605. package/publications/app-settings.d.ts +0 -2
  606. package/publications/app-settings.js +0 -28
  607. package/publications/app-settings.js.map +0 -1
  608. package/publications/app-status.d.ts +0 -2
  609. package/publications/app-status.js +0 -16
  610. package/publications/app-status.js.map +0 -1
  611. package/publications/cron-jobs.d.ts +0 -2
  612. package/publications/cron-jobs.js +0 -88
  613. package/publications/cron-jobs.js.map +0 -1
  614. package/publications/customer-notifications.d.ts +0 -2
  615. package/publications/customer-notifications.js +0 -161
  616. package/publications/customer-notifications.js.map +0 -1
  617. package/publications/files.d.ts +0 -2
  618. package/publications/files.js +0 -36
  619. package/publications/files.js.map +0 -1
  620. package/publications/flags-update.d.ts +0 -2
  621. package/publications/flags-update.js +0 -22
  622. package/publications/flags-update.js.map +0 -1
  623. package/publications/flags.d.ts +0 -2
  624. package/publications/flags.js +0 -22
  625. package/publications/flags.js.map +0 -1
  626. package/publications/logs.d.ts +0 -2
  627. package/publications/logs.js +0 -164
  628. package/publications/logs.js.map +0 -1
  629. package/publications/notifications.d.ts +0 -2
  630. package/publications/notifications.js +0 -16
  631. package/publications/notifications.js.map +0 -1
  632. package/publications/report-builder-dashboard-builders.d.ts +0 -2
  633. package/publications/report-builder-dashboard-builders.js +0 -42
  634. package/publications/report-builder-dashboard-builders.js.map +0 -1
  635. package/publications/report-builder-libraries.d.ts +0 -2
  636. package/publications/report-builder-libraries.js +0 -90
  637. package/publications/report-builder-libraries.js.map +0 -1
  638. package/publications/report-builder-reports.d.ts +0 -2
  639. package/publications/report-builder-reports.js +0 -50
  640. package/publications/report-builder-reports.js.map +0 -1
  641. package/publications/super-admin.d.ts +0 -2
  642. package/publications/super-admin.js +0 -16
  643. package/publications/super-admin.js.map +0 -1
  644. package/publications/user-groups.d.ts +0 -1
  645. package/publications/user-groups.js +0 -16
  646. package/publications/user-groups.js.map +0 -1
  647. package/publications/user-guides.d.ts +0 -1
  648. package/publications/user-guides.js +0 -16
  649. package/publications/user-guides.js.map +0 -1
  650. package/resolveio-server-app.d.ts +0 -70
  651. package/resolveio-server-app.js +0 -801
  652. package/resolveio-server-app.js.map +0 -1
  653. package/server-app.d.ts +0 -228
  654. package/server-app.js +0 -3566
  655. package/server-app.js.map +0 -1
  656. package/services/codex-client.d.ts +0 -128
  657. package/services/codex-client.js +0 -1629
  658. package/services/codex-client.js.map +0 -1
  659. package/services/openai-client.d.ts +0 -46
  660. package/services/openai-client.js +0 -318
  661. package/services/openai-client.js.map +0 -1
  662. package/types/error-report.d.ts +0 -25
  663. package/types/error-report.js +0 -4
  664. package/types/error-report.js.map +0 -1
  665. package/types/slow-query-report.d.ts +0 -27
  666. package/types/slow-query-report.js +0 -6
  667. package/types/slow-query-report.js.map +0 -1
  668. package/util/ai-qa-policy.d.ts +0 -124
  669. package/util/ai-qa-policy.js +0 -736
  670. package/util/ai-qa-policy.js.map +0 -1
  671. package/util/ai-run-evidence-adapters.d.ts +0 -109
  672. package/util/ai-run-evidence-adapters.js +0 -4141
  673. package/util/ai-run-evidence-adapters.js.map +0 -1
  674. package/util/ai-run-evidence-dashboard.d.ts +0 -84
  675. package/util/ai-run-evidence-dashboard.js +0 -336
  676. package/util/ai-run-evidence-dashboard.js.map +0 -1
  677. package/util/ai-run-evidence-eval.d.ts +0 -86
  678. package/util/ai-run-evidence-eval.js +0 -1018
  679. package/util/ai-run-evidence-eval.js.map +0 -1
  680. package/util/ai-run-evidence.d.ts +0 -244
  681. package/util/ai-run-evidence.js +0 -852
  682. package/util/ai-run-evidence.js.map +0 -1
  683. package/util/ai-runner-artifacts.d.ts +0 -82
  684. package/util/ai-runner-artifacts.js +0 -713
  685. package/util/ai-runner-artifacts.js.map +0 -1
  686. package/util/ai-runner-manager-autopilot.d.ts +0 -210
  687. package/util/ai-runner-manager-autopilot.js +0 -642
  688. package/util/ai-runner-manager-autopilot.js.map +0 -1
  689. package/util/ai-runner-manager-policy.d.ts +0 -787
  690. package/util/ai-runner-manager-policy.js +0 -3342
  691. package/util/ai-runner-manager-policy.js.map +0 -1
  692. package/util/ai-runner-qa-auth.d.ts +0 -5
  693. package/util/ai-runner-qa-auth.js +0 -822
  694. package/util/ai-runner-qa-auth.js.map +0 -1
  695. package/util/ai-runner-qa-tools.d.ts +0 -26
  696. package/util/ai-runner-qa-tools.js +0 -3029
  697. package/util/ai-runner-qa-tools.js.map +0 -1
  698. package/util/aicoder-runner-v6.d.ts +0 -424
  699. package/util/aicoder-runner-v6.js +0 -2325
  700. package/util/aicoder-runner-v6.js.map +0 -1
  701. package/util/common.d.ts +0 -31
  702. package/util/common.js +0 -683
  703. package/util/common.js.map +0 -1
  704. package/util/customer-portal-password.d.ts +0 -13
  705. package/util/customer-portal-password.js +0 -209
  706. package/util/customer-portal-password.js.map +0 -1
  707. package/util/error-reporter.d.ts +0 -52
  708. package/util/error-reporter.js +0 -326
  709. package/util/error-reporter.js.map +0 -1
  710. package/util/error-tracking.d.ts +0 -13
  711. package/util/error-tracking.js +0 -120
  712. package/util/error-tracking.js.map +0 -1
  713. package/util/openai-usage-cost.d.ts +0 -6
  714. package/util/openai-usage-cost.js +0 -103
  715. package/util/openai-usage-cost.js.map +0 -1
  716. package/util/report-builder-unwinds.d.ts +0 -15
  717. package/util/report-builder-unwinds.js +0 -156
  718. package/util/report-builder-unwinds.js.map +0 -1
  719. package/util/runner-process-janitor.d.ts +0 -27
  720. package/util/runner-process-janitor.js +0 -208
  721. package/util/runner-process-janitor.js.map +0 -1
  722. package/util/schema-report-builder.d.ts +0 -6
  723. package/util/schema-report-builder.js +0 -481
  724. package/util/schema-report-builder.js.map +0 -1
  725. package/util/slow-query-reporter.d.ts +0 -28
  726. package/util/slow-query-reporter.js +0 -226
  727. package/util/slow-query-reporter.js.map +0 -1
  728. package/util/subscription-dependency-context.d.ts +0 -34
  729. package/util/subscription-dependency-context.js +0 -1283
  730. package/util/subscription-dependency-context.js.map +0 -1
  731. package/util/support-runner-v5.d.ts +0 -1018
  732. package/util/support-runner-v5.js +0 -4615
  733. package/util/support-runner-v5.js.map +0 -1
  734. package/util/tokenizer.d.ts +0 -5
  735. package/util/tokenizer.js +0 -41
  736. package/util/tokenizer.js.map +0 -1
  737. package/workers/codex-runner.worker.d.ts +0 -1
  738. package/workers/codex-runner.worker.js +0 -192
  739. package/workers/codex-runner.worker.js.map +0 -1
  740. /package/{private → src/private}/email-templates/enrollment.html +0 -0
  741. /package/{private → src/private}/email-templates/forgot-password.html +0 -0
  742. /package/{private → src/private}/email-templates/support-ticket-deleted.html +0 -0
  743. /package/{private → src/private}/email-templates/support-ticket-modified.html +0 -0
  744. /package/{private → src/private}/email-templates/support-ticket.html +0 -0
  745. /package/{public_api.d.ts → src/public_api.ts} +0 -0
@@ -1,4615 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __values = (this && this.__values) || function(o) {
14
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
- if (m) return m.call(o);
16
- if (o && typeof o.length === "number") return {
17
- next: function () {
18
- if (o && i >= o.length) o = void 0;
19
- return { value: o && o[i++], done: !o };
20
- }
21
- };
22
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23
- };
24
- var __read = (this && this.__read) || function (o, n) {
25
- var m = typeof Symbol === "function" && o[Symbol.iterator];
26
- if (!m) return o;
27
- var i = m.call(o), r, ar = [], e;
28
- try {
29
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
- }
31
- catch (error) { e = { error: error }; }
32
- finally {
33
- try {
34
- if (r && !r.done && (m = i["return"])) m.call(i);
35
- }
36
- finally { if (e) throw e.error; }
37
- }
38
- return ar;
39
- };
40
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
- if (ar || !(i in from)) {
43
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
- ar[i] = from[i];
45
- }
46
- }
47
- return to.concat(ar || Array.prototype.slice.call(from));
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.evaluateResolveIOSupportPreflightGate = evaluateResolveIOSupportPreflightGate;
51
- exports.selectResolveIOSupportSimilarCaseHints = selectResolveIOSupportSimilarCaseHints;
52
- exports.buildResolveIOSupportDiagnosisEvidencePack = buildResolveIOSupportDiagnosisEvidencePack;
53
- exports.evaluateResolveIOSupportDiagnosisEvidenceQuality = evaluateResolveIOSupportDiagnosisEvidenceQuality;
54
- exports.normalizeResolveIOSupportDiagnosisGate = normalizeResolveIOSupportDiagnosisGate;
55
- exports.extractResolveIOSupportDiagnosisGateFromText = extractResolveIOSupportDiagnosisGateFromText;
56
- exports.validateResolveIOSupportDiagnosisGate = validateResolveIOSupportDiagnosisGate;
57
- exports.evaluateResolveIOSupportBusinessProofReadiness = evaluateResolveIOSupportBusinessProofReadiness;
58
- exports.buildResolveIOSupportClarificationContract = buildResolveIOSupportClarificationContract;
59
- exports.validateResolveIOSupportClarificationContract = validateResolveIOSupportClarificationContract;
60
- exports.buildResolveIOSupportCustomerReplyReadinessContract = buildResolveIOSupportCustomerReplyReadinessContract;
61
- exports.validateResolveIOSupportCustomerReplyReadinessContract = validateResolveIOSupportCustomerReplyReadinessContract;
62
- exports.decideResolveIOSupportCustomerReplyPolicy = decideResolveIOSupportCustomerReplyPolicy;
63
- exports.buildResolveIOSupportIssueClassProbes = buildResolveIOSupportIssueClassProbes;
64
- exports.validateResolveIOSupportIssueClassProbePlan = validateResolveIOSupportIssueClassProbePlan;
65
- exports.buildResolveIOSupportIssueClassProbePlan = buildResolveIOSupportIssueClassProbePlan;
66
- exports.hashResolveIOSupportV5Evidence = hashResolveIOSupportV5Evidence;
67
- exports.decideResolveIOSupportV5RepeatedFailureStop = decideResolveIOSupportV5RepeatedFailureStop;
68
- exports.evaluateResolveIOSupportEvidenceFreshness = evaluateResolveIOSupportEvidenceFreshness;
69
- exports.buildResolveIOSupportContinuationProofCheckpoint = buildResolveIOSupportContinuationProofCheckpoint;
70
- exports.changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles = changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles;
71
- exports.decideResolveIOSupportV5RepairGate = decideResolveIOSupportV5RepairGate;
72
- exports.applyResolveIOSupportDiagnosisGateToMicrotasks = applyResolveIOSupportDiagnosisGateToMicrotasks;
73
- exports.fingerprintResolveIOSupportV5Blocker = fingerprintResolveIOSupportV5Blocker;
74
- exports.buildResolveIOSupportV5Budget = buildResolveIOSupportV5Budget;
75
- exports.buildResolveIOSupportV5PromptBudget = buildResolveIOSupportV5PromptBudget;
76
- exports.buildResolveIOSupportV5ScopeDigest = buildResolveIOSupportV5ScopeDigest;
77
- exports.buildResolveIOSupportV5MicrotaskLedger = buildResolveIOSupportV5MicrotaskLedger;
78
- exports.selectResolveIOSupportV5ActiveMicrotask = selectResolveIOSupportV5ActiveMicrotask;
79
- exports.initializeResolveIOSupportV5State = initializeResolveIOSupportV5State;
80
- exports.recordResolveIOSupportV5Step = recordResolveIOSupportV5Step;
81
- exports.recordResolveIOSupportV5MicrotaskUsage = recordResolveIOSupportV5MicrotaskUsage;
82
- exports.decideResolveIOSupportV5Continuation = decideResolveIOSupportV5Continuation;
83
- exports.decideResolveIOSupportV5AutonomousNextAction = decideResolveIOSupportV5AutonomousNextAction;
84
- exports.buildResolveIOSupportV5DiagnoseFirstPrompt = buildResolveIOSupportV5DiagnoseFirstPrompt;
85
- exports.buildResolveIOSupportV5MicrotaskPrompt = buildResolveIOSupportV5MicrotaskPrompt;
86
- exports.summarizeResolveIOSupportV5MicrotaskUsage = summarizeResolveIOSupportV5MicrotaskUsage;
87
- exports.buildResolveIOSupportV5Incident = buildResolveIOSupportV5Incident;
88
- var ai_runner_manager_policy_1 = require("./ai-runner-manager-policy");
89
- function isoNow(value) {
90
- if (value instanceof Date) {
91
- return value.toISOString();
92
- }
93
- var parsed = value ? new Date(value) : new Date();
94
- if (Number.isFinite(parsed.getTime())) {
95
- return parsed.toISOString();
96
- }
97
- return new Date().toISOString();
98
- }
99
- function cleanText(value, max) {
100
- if (max === void 0) { max = 2000; }
101
- return String(value || '').replace(/\s+/g, ' ').trim().slice(0, max);
102
- }
103
- function cleanList(values, limit, max) {
104
- var e_1, _a;
105
- if (limit === void 0) { limit = 20; }
106
- if (max === void 0) { max = 500; }
107
- if (!Array.isArray(values)) {
108
- return [];
109
- }
110
- var result = [];
111
- try {
112
- for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
113
- var value = values_1_1.value;
114
- var normalized = cleanText(value, max);
115
- if (normalized && !result.includes(normalized)) {
116
- result.push(normalized);
117
- }
118
- if (result.length >= limit) {
119
- break;
120
- }
121
- }
122
- }
123
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
124
- finally {
125
- try {
126
- if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
127
- }
128
- finally { if (e_1) throw e_1.error; }
129
- }
130
- return result;
131
- }
132
- function cleanObject(value) {
133
- return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
134
- }
135
- function normalizeResolveIOSupportPreflightCheckName(value) {
136
- var normalized = cleanText(value, 120)
137
- .toLowerCase()
138
- .replace(/[\s-]+/g, '_');
139
- var aliases = {
140
- puppeteer: 'puppeteer_module',
141
- puppeteer_module: 'puppeteer_module',
142
- chrome: 'chrome_executable',
143
- chrome_path: 'chrome_executable',
144
- chrome_executable: 'chrome_executable',
145
- chrome_launch: 'chrome_launch',
146
- browser_launch: 'chrome_launch',
147
- node: 'node_version',
148
- node_version: 'node_version',
149
- npm: 'npm_install',
150
- npm_install: 'npm_install',
151
- settings: 'settings_file',
152
- settings_file: 'settings_file',
153
- mongo: 'mongo_connection',
154
- mongodb: 'mongo_connection',
155
- mongo_connection: 'mongo_connection',
156
- server: 'server_startup',
157
- server_startup: 'server_startup',
158
- client: 'client_startup',
159
- client_startup: 'client_startup',
160
- port: 'port_availability',
161
- ports: 'port_availability',
162
- port_availability: 'port_availability',
163
- build: 'compile',
164
- compile: 'compile',
165
- cache: 'cache_state',
166
- cache_state: 'cache_state',
167
- seed: 'seed_data',
168
- seed_data: 'seed_data'
169
- };
170
- return aliases[normalized] || 'unknown';
171
- }
172
- function normalizeResolveIOSupportPreflightCheckStatus(value, source) {
173
- var normalized = cleanText(value, 80).toLowerCase();
174
- if (['pass', 'passed', 'ok', 'success', 'ready'].includes(normalized) || source.passed === true || source.ok === true || source.ready === true) {
175
- return 'pass';
176
- }
177
- if (['fail', 'failed', 'failure', 'error'].includes(normalized) || source.passed === false || source.ok === false) {
178
- return 'fail';
179
- }
180
- if (['blocked', 'block', 'missing'].includes(normalized) || source.blocked === true) {
181
- return 'blocked';
182
- }
183
- if (['warn', 'warning'].includes(normalized)) {
184
- return 'warn';
185
- }
186
- return 'unknown';
187
- }
188
- function normalizeResolveIOSupportPreflightFailureClass(name, source, status) {
189
- var normalized = cleanText(source.failureClass || source.failure_class || source.class, 80).toLowerCase();
190
- if (normalized === 'compile' || normalized === 'build') {
191
- return 'compile';
192
- }
193
- if (normalized === 'infra' || normalized === 'infrastructure') {
194
- return 'infra';
195
- }
196
- if (status === 'pass' || status === 'warn') {
197
- return 'unknown';
198
- }
199
- return name === 'compile' ? 'compile' : 'infra';
200
- }
201
- function normalizeResolveIOSupportPreflightCheck(input, now) {
202
- var source = typeof input === 'string'
203
- ? { summary: input, name: 'unknown', status: 'unknown' }
204
- : cleanObject(input);
205
- var name = normalizeResolveIOSupportPreflightCheckName(source.name || source.check || source.checkName || source.id || source.type);
206
- var status = normalizeResolveIOSupportPreflightCheckStatus(source.status || source.state || source.outcome, source);
207
- var artifactPaths = Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(source.artifactPaths || source.artifacts, 20, 500)), false), __read(cleanList(source.artifactPath ? [source.artifactPath] : [], 1, 500)), false)));
208
- var evidence = cleanList(source.evidence || source.logs || source.messages, 20, 500);
209
- return {
210
- name: name,
211
- status: status,
212
- summary: cleanText(source.summary || source.reason || source.error || source.message || source.status || name, 1000),
213
- failureClass: normalizeResolveIOSupportPreflightFailureClass(name, source, status),
214
- command: cleanText(source.command, 500) || undefined,
215
- durationMs: Number.isFinite(Number(source.durationMs || source.duration_ms))
216
- ? Math.max(0, Number(source.durationMs || source.duration_ms))
217
- : undefined,
218
- artifactPaths: artifactPaths,
219
- evidence: evidence,
220
- recordedAt: cleanText(source.recordedAt || source.recorded_at, 80) || now
221
- };
222
- }
223
- function normalizeResolveIOSupportPreflightGateStatus(value) {
224
- var normalized = cleanText(value, 80).toLowerCase();
225
- var aliases = {
226
- passed: 'passed',
227
- pass: 'passed',
228
- ready: 'passed',
229
- missing: 'missing',
230
- infra_failed: 'infra_failed',
231
- infra: 'infra_failed',
232
- infrastructure_failed: 'infra_failed',
233
- compile_failed: 'compile_failed',
234
- build_failed: 'compile_failed',
235
- blocked: 'blocked',
236
- unknown: 'unknown'
237
- };
238
- return aliases[normalized] || '';
239
- }
240
- function evaluateResolveIOSupportPreflightGate(input, nowValue) {
241
- var now = isoNow(nowValue);
242
- var source = cleanObject(input);
243
- var compileResult = cleanObject(source.compileResult || source.compile_result);
244
- var checksInput = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((Array.isArray(source.checks) ? source.checks : [])), false), __read((Array.isArray(source.infraChecks || source.infra_checks) ? (source.infraChecks || source.infra_checks) : [])), false), __read((Array.isArray(source.startupChecks || source.startup_checks) ? (source.startupChecks || source.startup_checks) : [])), false), __read((Object.keys(compileResult).length ? [__assign(__assign({}, compileResult), { name: compileResult.name || 'compile', failureClass: compileResult.failureClass || compileResult.failure_class || 'compile' })] : [])), false);
245
- var checks = checksInput.map(function (check) { return normalizeResolveIOSupportPreflightCheck(check, now); });
246
- var required = source.required === true
247
- || source.requiredBeforeRepair === true
248
- || source.required_before_repair === true
249
- || source.blocksProductRepair === true
250
- || source.blocks_product_repair === true;
251
- var failedChecks = checks.filter(function (check) { return check.status === 'fail' || check.status === 'blocked'; });
252
- var unknownChecks = checks.filter(function (check) { return check.status === 'unknown'; });
253
- var directStatus = normalizeResolveIOSupportPreflightGateStatus(source.status);
254
- var compileFailed = failedChecks.some(function (check) { return check.failureClass === 'compile' || check.name === 'compile'; })
255
- || directStatus === 'compile_failed';
256
- var infraFailed = failedChecks.length > 0 || directStatus === 'infra_failed';
257
- var status;
258
- if (compileFailed) {
259
- status = 'compile_failed';
260
- }
261
- else if (infraFailed) {
262
- status = 'infra_failed';
263
- }
264
- else if (directStatus === 'blocked') {
265
- status = 'blocked';
266
- }
267
- else if (directStatus === 'missing' || (required && checks.length === 0)) {
268
- status = 'missing';
269
- }
270
- else if (directStatus === 'passed' || source.ready === true || (checks.length > 0 && failedChecks.length === 0 && unknownChecks.length === 0)) {
271
- status = 'passed';
272
- }
273
- else {
274
- status = 'unknown';
275
- }
276
- var failureClass = status === 'compile_failed'
277
- ? 'compile'
278
- : (status === 'infra_failed' || status === 'blocked' || status === 'missing')
279
- ? 'infra'
280
- : 'unknown';
281
- var artifactPaths = Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(source.artifactPaths || source.artifacts, 40, 500)), false), __read(checks.flatMap(function (check) { return check.artifactPaths; })), false))).slice(0, 80);
282
- var blockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(source.blockers, 20, 500)), false), __read(failedChecks.map(function (check) { return "".concat(check.name, ": ").concat(check.summary); })), false), __read((status === 'missing' ? ['Deterministic support preflight is required before product-code repair.'] : [])), false), __read((status === 'blocked' ? ['Support preflight is blocked and must be cleared before product-code repair.'] : [])), false).filter(Boolean))).slice(0, 30);
283
- var requiredEvidence = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(source.requiredEvidence || source.required_evidence, 20, 500)), false), __read((status === 'compile_failed' ? ['compile command output', 'artifact path or build log', 'new compile evidence hash or pass'] : [])), false), __read((status === 'infra_failed' ? ['Puppeteer/Chrome/server/client/Mongo preflight log', 'new infra evidence hash or pass'] : [])), false), __read((status === 'missing' || status === 'blocked' || (required && status === 'unknown') ? ['support preflight result with Puppeteer, Chrome, compile, startup, Mongo, port, and settings status'] : [])), false))).slice(0, 30);
284
- var blocksProductRepair = status === 'compile_failed'
285
- || status === 'infra_failed'
286
- || status === 'blocked'
287
- || status === 'missing'
288
- || (required && status === 'unknown');
289
- var nextCommand = status === 'compile_failed'
290
- ? 'run_support_v5_compile_repair'
291
- : status === 'infra_failed' || status === 'blocked'
292
- ? 'run_support_v5_infra_repair'
293
- : status === 'missing' || (required && status === 'unknown')
294
- ? 'run_support_v5_preflight'
295
- : 'continue_to_diagnosis';
296
- var evidenceHash = cleanText(source.evidenceHash || source.evidence_hash, 80)
297
- || hashResolveIOSupportV5Evidence({
298
- status: status,
299
- required: required,
300
- failedChecks: failedChecks.map(function (check) { return ({
301
- name: check.name,
302
- status: check.status,
303
- summary: check.summary,
304
- failureClass: check.failureClass
305
- }); }),
306
- artifactPaths: artifactPaths
307
- });
308
- return {
309
- ready: blocksProductRepair ? false : status === 'passed',
310
- required: required,
311
- status: status,
312
- failureClass: failureClass,
313
- checks: checks,
314
- failedChecks: failedChecks,
315
- blockers: blockers,
316
- requiredEvidence: requiredEvidence,
317
- artifactPaths: artifactPaths,
318
- nextCommand: nextCommand,
319
- blocksProductRepair: blocksProductRepair,
320
- blocksModelRepair: blocksProductRepair,
321
- evidenceHash: evidenceHash,
322
- recordedAt: cleanText(source.recordedAt || source.recorded_at, 80) || now
323
- };
324
- }
325
- function pickText(source, fields, max) {
326
- var e_2, _a;
327
- if (max === void 0) { max = 1000; }
328
- try {
329
- for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
330
- var field = fields_1_1.value;
331
- var normalized = cleanText(source === null || source === void 0 ? void 0 : source[field], max);
332
- if (normalized) {
333
- return normalized;
334
- }
335
- }
336
- }
337
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
338
- finally {
339
- try {
340
- if (fields_1_1 && !fields_1_1.done && (_a = fields_1.return)) _a.call(fields_1);
341
- }
342
- finally { if (e_2) throw e_2.error; }
343
- }
344
- return '';
345
- }
346
- function normalizeIssueClass(value) {
347
- var normalized = cleanText(value, 80)
348
- .toLowerCase()
349
- .replace(/[\s-]+/g, '_');
350
- var aliases = {
351
- no_op: 'no_op_submit',
352
- no_op_submit: 'no_op_submit',
353
- submit_noop: 'no_op_submit',
354
- missing_data: 'missing_wrong_data',
355
- wrong_data: 'missing_wrong_data',
356
- missing_wrong_data: 'missing_wrong_data',
357
- filter_mismatch: 'filter_query_mismatch',
358
- query_mismatch: 'filter_query_mismatch',
359
- filter_query_mismatch: 'filter_query_mismatch',
360
- invoice_pdf_export: 'invoice_pdf_export',
361
- pdf_export: 'invoice_pdf_export',
362
- export: 'invoice_pdf_export',
363
- upload: 'upload_import',
364
- import: 'upload_import',
365
- upload_import: 'upload_import',
366
- route_auth: 'route_auth_hydration',
367
- auth_hydration: 'route_auth_hydration',
368
- route_auth_hydration: 'route_auth_hydration',
369
- slow_query: 'slow_query_performance',
370
- performance: 'slow_query_performance',
371
- slow_query_performance: 'slow_query_performance'
372
- };
373
- return aliases[normalized] || '';
374
- }
375
- function normalizeReproductionStatus(value) {
376
- var normalized = cleanText(value, 80).toLowerCase();
377
- if (/blocked|unable|cannot/.test(normalized)) {
378
- return 'blocked';
379
- }
380
- if (/classif|triag|inferred/.test(normalized)) {
381
- return 'classified';
382
- }
383
- return 'reproduced';
384
- }
385
- function normalizeSupportDiagnosisEvidence(values) {
386
- var allowed = new Set(['ticket', 'browser', 'mongo', 'log', 'code', 'commit', 'qa', 'other']);
387
- if (!Array.isArray(values)) {
388
- var summary = cleanText(values, 1200);
389
- return summary ? [{ type: 'other', summary: summary }] : [];
390
- }
391
- var stringEvidence = values
392
- .filter(function (entry) { return typeof entry === 'string'; })
393
- .map(function (entry) { return ({
394
- type: 'other',
395
- summary: cleanText(entry, 1200)
396
- }); });
397
- var objectEvidence = values
398
- .filter(function (entry) { return entry && typeof entry === 'object' && !Array.isArray(entry); })
399
- .map(function (entry) {
400
- var type = cleanText(entry.type, 80).toLowerCase();
401
- return {
402
- type: (allowed.has(type) ? type : 'other'),
403
- summary: cleanText(entry.summary || entry.message || entry.evidence || entry.reason, 1200),
404
- artifactPath: cleanText(entry.artifactPath || entry.path || entry.file, 500)
405
- };
406
- });
407
- return stringEvidence.concat(objectEvidence)
408
- .filter(function (entry) { return entry.summary; })
409
- .slice(0, 20);
410
- }
411
- function normalizeSupportDiagnosisHints(values) {
412
- return (Array.isArray(values) ? values : [])
413
- .map(function (entry) {
414
- if (typeof entry === 'string') {
415
- return { reason: cleanText(entry, 500) };
416
- }
417
- var value = cleanObject(entry);
418
- return {
419
- id: cleanText(value.id || value._id, 160),
420
- ticketNumber: cleanText(value.ticketNumber || value.ticket_number || value.sourceTicketNumber, 80),
421
- title: cleanText(value.title || value.summary, 300),
422
- outcome: cleanText(value.outcome || value.status, 80),
423
- issueClass: cleanText(value.issueClass || value.issue_class, 80),
424
- ownerFiles: cleanList(value.ownerFiles || value.owner_files || value.files, 8, 240),
425
- commitSha: cleanText(value.commitSha || value.commit_sha, 80),
426
- commitMessage: cleanText(value.commitMessage || value.commit_message, 300),
427
- reason: cleanText(value.reason || value.matchReason || value.match_reason, 500)
428
- };
429
- })
430
- .filter(function (entry) { return entry.id || entry.ticketNumber || entry.title || entry.reason || entry.commitSha; })
431
- .slice(0, 8);
432
- }
433
- function normalizeSupportSimilarCaseSource(value) {
434
- var normalized = cleanText(value, 80).toLowerCase();
435
- if (/commit|git/.test(normalized)) {
436
- return 'git_commit';
437
- }
438
- if (/ticket/.test(normalized)) {
439
- return 'support_ticket';
440
- }
441
- if (/airun|ai_run|run/.test(normalized)) {
442
- return 'airun';
443
- }
444
- return 'manual';
445
- }
446
- function supportOutcomeLooksAccepted(value) {
447
- return /^(accepted|pass|passed|complete|completed|merged|released)$/i.test(cleanText(value, 80));
448
- }
449
- function supportOutcomeLooksRejected(value) {
450
- return /\b(reject|rejected|false_pass|failed|failure|blocked|unknown|stopped|manual_handoff)\b/i.test(cleanText(value, 120));
451
- }
452
- function supportOwnerFileDirectory(value) {
453
- var normalized = normalizeOwnerFilePath(value);
454
- var parts = normalized.split('/').filter(Boolean);
455
- return parts.length > 1 ? parts.slice(0, -1).join('/') : normalized;
456
- }
457
- function supportTextTokens(value) {
458
- var stop = new Set(['the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'when', 'where', 'what', 'have', 'has', 'had', 'not', 'but', 'are', 'was', 'were', 'issue', 'ticket', 'support']);
459
- return Array.from(new Set(cleanText(value, 3000).toLowerCase()
460
- .split(/[^a-z0-9_/-]+/g)
461
- .map(function (token) { return token.trim(); })
462
- .filter(function (token) { return token.length >= 3 && !stop.has(token); })))
463
- .slice(0, 80);
464
- }
465
- function normalizeResolveIOSupportSimilarCaseCandidate(value) {
466
- var _a, _b;
467
- var source = cleanObject(value);
468
- if (!Object.keys(source).length && typeof value !== 'string') {
469
- return undefined;
470
- }
471
- if (typeof value === 'string') {
472
- var summary = cleanText(value, 500);
473
- return summary ? {
474
- source: 'manual',
475
- title: summary,
476
- summary: summary,
477
- keywords: supportTextTokens(summary)
478
- } : undefined;
479
- }
480
- var metadata = cleanObject(source.metadata);
481
- var runSourceIds = cleanObject(source.sourceIds || source.source_ids || metadata.sourceIds || metadata.source_ids);
482
- var diagnosis = cleanObject(source.diagnosisGate || source.diagnosis_gate || source.supportV5DiagnosisGate || source.support_v5_diagnosis_gate || metadata.diagnosisGate || metadata.diagnosis_gate);
483
- var sourceIds = cleanObject(source.sourceIds || source.source_ids || metadata.sourceIds || metadata.source_ids);
484
- var sourceText = [
485
- source.title,
486
- source.summary,
487
- source.message,
488
- source.description,
489
- source.reason,
490
- source.commitMessage,
491
- source.commit_message,
492
- (_a = diagnosis.issue_case) === null || _a === void 0 ? void 0 : _a.customer_complaint,
493
- (_b = diagnosis.accepted_hypothesis) === null || _b === void 0 ? void 0 : _b.statement
494
- ].filter(Boolean).join(' ');
495
- var ownerFiles = cleanList(source.ownerFiles
496
- || source.owner_files
497
- || source.files
498
- || diagnosis.owner_files
499
- || diagnosis.ownerFiles
500
- || metadata.ownerFiles
501
- || metadata.owner_files, 12, 300).map(normalizeOwnerFilePath).filter(Boolean);
502
- var issueClass = cleanText(source.issueClass
503
- || source.issue_class
504
- || diagnosis.issue_class
505
- || diagnosis.issueClass
506
- || metadata.issueClass
507
- || metadata.issue_class, 80);
508
- var candidate = {
509
- source: normalizeSupportSimilarCaseSource(source.source || source.type || source.runSource),
510
- id: cleanText(source.id || source._id || source.runId || source.run_id, 160),
511
- ticketNumber: cleanText(source.ticketNumber || source.ticket_number || source.sourceTicketNumber || sourceIds.ticketNumber || runSourceIds.ticketNumber, 80),
512
- title: cleanText(source.title || source.name || source.summary, 300),
513
- outcome: cleanText(source.outcome || source.status || source.outcomeLabel || source.outcome_label, 80),
514
- issueClass: normalizeIssueClass(issueClass) || cleanText(issueClass, 80),
515
- ownerFiles: ownerFiles,
516
- commitSha: cleanText(source.commitSha || source.commit_sha || source.sha || source.sourceCommitSha || source.source_commit_sha, 80),
517
- commitMessage: cleanText(source.commitMessage || source.commit_message || source.message, 300),
518
- reason: cleanText(source.reason || source.matchReason || source.match_reason, 500),
519
- summary: cleanText(source.summary || source.description || source.message || sourceText, 800),
520
- keywords: cleanList(source.keywords || source.tags, 20, 80).concat(supportTextTokens(sourceText)).slice(0, 40),
521
- updatedAt: isoNow(source.updatedAt || source.updated_at || source.recordedAt || source.recorded_at || source.createdAt || source.created_at),
522
- metadata: metadata
523
- };
524
- if (!candidate.id && !candidate.ticketNumber && !candidate.title && !candidate.commitSha && !candidate.summary) {
525
- return undefined;
526
- }
527
- if (candidate.commitSha && candidate.source === 'manual') {
528
- candidate.source = 'git_commit';
529
- }
530
- if (candidate.ticketNumber && candidate.source === 'manual') {
531
- candidate.source = 'support_ticket';
532
- }
533
- return candidate;
534
- }
535
- function selectResolveIOSupportSimilarCaseHints(input) {
536
- var e_3, _a;
537
- if (input === void 0) { input = {}; }
538
- var issueClass = normalizeIssueClass(input.issueClass);
539
- var ownerFiles = cleanList(input.ownerFiles, 12, 300).map(normalizeOwnerFilePath).filter(Boolean);
540
- var ownerFileSet = new Set(ownerFiles);
541
- var ownerDirs = new Set(ownerFiles.map(supportOwnerFileDirectory).filter(Boolean));
542
- var textTokens = new Set(supportTextTokens(input.text));
543
- var limit = Math.max(1, Math.min(12, Number(input.limit || 6)));
544
- var normalized = (Array.isArray(input.candidates) ? input.candidates : [])
545
- .map(normalizeResolveIOSupportSimilarCaseCandidate)
546
- .filter(function (candidate) { return !!candidate; });
547
- var ranked = [];
548
- var ignoredCount = 0;
549
- try {
550
- for (var normalized_1 = __values(normalized), normalized_1_1 = normalized_1.next(); !normalized_1_1.done; normalized_1_1 = normalized_1.next()) {
551
- var candidate = normalized_1_1.value;
552
- var outcomeKnown = !!candidate.outcome;
553
- var accepted = supportOutcomeLooksAccepted(candidate.outcome) || (!!candidate.commitSha && !supportOutcomeLooksRejected(candidate.outcome));
554
- if (outcomeKnown && !accepted) {
555
- ignoredCount += 1;
556
- continue;
557
- }
558
- var signals = [];
559
- var score = accepted ? 100 : 40;
560
- var candidateIssueClass = normalizeIssueClass(candidate.issueClass);
561
- if (issueClass && candidateIssueClass && issueClass === candidateIssueClass) {
562
- score += 45;
563
- signals.push("issue_class:".concat(issueClass));
564
- }
565
- var exactOwnerOverlap = candidate.ownerFiles.filter(function (file) { return ownerFileSet.has(normalizeOwnerFilePath(file)); });
566
- if (exactOwnerOverlap.length) {
567
- score += 35 + Math.min(20, exactOwnerOverlap.length * 5);
568
- signals.push("owner_file_overlap:".concat(exactOwnerOverlap.slice(0, 3).join(',')));
569
- }
570
- var directoryOverlap = candidate.ownerFiles
571
- .map(supportOwnerFileDirectory)
572
- .filter(function (dir) { return dir && ownerDirs.has(dir); });
573
- if (directoryOverlap.length && !exactOwnerOverlap.length) {
574
- score += 18;
575
- signals.push("owner_dir_overlap:".concat(Array.from(new Set(directoryOverlap)).slice(0, 2).join(',')));
576
- }
577
- var candidateTokens = new Set(__spreadArray(__spreadArray([], __read((candidate.keywords || [])), false), __read(supportTextTokens([candidate.title, candidate.summary, candidate.commitMessage].join(' '))), false));
578
- var tokenOverlap = Array.from(candidateTokens).filter(function (token) { return textTokens.has(token); }).slice(0, 6);
579
- if (tokenOverlap.length) {
580
- score += Math.min(18, tokenOverlap.length * 3);
581
- signals.push("weak_text_overlap:".concat(tokenOverlap.join(',')));
582
- }
583
- if (candidate.commitSha) {
584
- score += 8;
585
- signals.push('commit_linked');
586
- }
587
- if (!signals.length && score < 100) {
588
- ignoredCount += 1;
589
- continue;
590
- }
591
- ranked.push({
592
- id: candidate.id,
593
- ticketNumber: candidate.ticketNumber,
594
- title: candidate.title,
595
- outcome: candidate.outcome || (candidate.commitSha ? 'commit_hint' : ''),
596
- issueClass: candidateIssueClass || candidate.issueClass,
597
- ownerFiles: candidate.ownerFiles.slice(0, 8),
598
- commitSha: candidate.commitSha,
599
- commitMessage: candidate.commitMessage,
600
- reason: signals.join('; '),
601
- source: candidate.source,
602
- score: score,
603
- structuredSignals: signals,
604
- advisoryOnly: true
605
- });
606
- }
607
- }
608
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
609
- finally {
610
- try {
611
- if (normalized_1_1 && !normalized_1_1.done && (_a = normalized_1.return)) _a.call(normalized_1);
612
- }
613
- finally { if (e_3) throw e_3.error; }
614
- }
615
- var sorted = ranked
616
- .sort(function (a, b) { return b.score - a.score || String(b.ticketNumber || b.commitSha || '').localeCompare(String(a.ticketNumber || a.commitSha || '')); })
617
- .slice(0, limit);
618
- return {
619
- ranked: sorted,
620
- similarTickets: sorted.filter(function (hint) { return hint.source !== 'git_commit'; }).slice(0, limit),
621
- similarCommits: sorted.filter(function (hint) { return hint.source === 'git_commit' || !!hint.commitSha; }).slice(0, limit),
622
- ignoredCount: ignoredCount,
623
- generatedAt: isoNow(input.now)
624
- };
625
- }
626
- var SUPPORT_DIAGNOSIS_GATE_REQUIRED_FIELDS = [
627
- 'issue_case',
628
- 'issue_class',
629
- 'accepted_hypothesis',
630
- 'rejected_alternatives',
631
- 'failing_path',
632
- 'owner_files',
633
- 'proof_plan',
634
- 'evidence',
635
- 'status'
636
- ];
637
- var SUPPORT_DIAGNOSIS_REQUIRED_EVIDENCE = [
638
- 'customer complaint, expected result, observed result, route/module, and account/customer context',
639
- 'reproduction proof or blocked-reproduction reason',
640
- 'one accepted falsifiable root-cause hypothesis with evidence',
641
- 'rejected alternatives showing the runner did not guess',
642
- 'frontend/backend/shared failing path',
643
- 'small exact owner_files set',
644
- 'before/action/after business proof plan',
645
- 'AIQaBusinessAssertion acceptance requirement'
646
- ];
647
- var SUPPORT_DIAGNOSIS_FORBIDDEN_ACTIONS = [
648
- 'Do not edit source, package, generated, fixture, QA artifact, or local data files while building the diagnosis gate.',
649
- 'Do not use similar tickets or commits as proof; they are advisory hints only.',
650
- 'Do not broaden owner_files from similar hints without fresh evidence from the current ticket.',
651
- 'Do not accept route load, screenshot, scorecard, wow score, or model claim as ticket acceptance.',
652
- 'Do not run product-code repair until SupportDiagnosisGate validates.'
653
- ];
654
- var SUPPORT_ISSUE_CLASS_PROBE_CATALOG = [{
655
- issue_class: 'no_op_submit',
656
- probe_type: 'issue_class_probe',
657
- failure_class: 'business',
658
- action: 'Submit the reported form/action and prove a persisted state change or expected validation result.',
659
- proof_required: 'Before/action/after DOM or data proof that the submit is no longer a no-op.',
660
- required_artifacts: ['before form state', 'submit action trace', 'post-submit DOM/data proof', 'method or network result'],
661
- acceptance_gate: 'aiqa_business_assertion',
662
- false_pass_blockers: ['route loaded only', 'button clicked without persisted result', 'model claim without DOM/data proof']
663
- }, {
664
- issue_class: 'missing_wrong_data',
665
- probe_type: 'issue_class_probe',
666
- failure_class: 'business',
667
- action: 'Load the named record/list and compare visible data to the expected persisted source.',
668
- proof_required: 'Visible data and persisted data match the customer expectation.',
669
- required_artifacts: ['expected source record', 'visible DOM/data snapshot', 'persisted data comparison'],
670
- acceptance_gate: 'aiqa_business_assertion',
671
- false_pass_blockers: ['non-empty page only', 'wrong account/customer context', 'sample substitute for named record']
672
- }, {
673
- issue_class: 'filter_query_mismatch',
674
- probe_type: 'issue_class_probe',
675
- failure_class: 'business',
676
- action: 'Apply the reported filter/query inputs and assert included/excluded rows or counts.',
677
- proof_required: 'Returned rows/counts match the expected dataset and exclude the wrong records.',
678
- required_artifacts: ['filter input trace', 'included/excluded row proof', 'query or publication result proof'],
679
- acceptance_gate: 'aiqa_business_assertion',
680
- false_pass_blockers: ['filter control visible only', 'route screenshot without row proof']
681
- }, {
682
- issue_class: 'invoice_pdf_export',
683
- probe_type: 'issue_class_probe',
684
- failure_class: 'business',
685
- action: 'Generate the invoice/PDF/export and inspect the generated artifact.',
686
- proof_required: 'Generated artifact contains the expected customer-visible rows, totals, fields, or file output.',
687
- required_artifacts: ['export trigger trace', 'generated file artifact path', 'parsed artifact content proof'],
688
- acceptance_gate: 'aiqa_business_assertion',
689
- false_pass_blockers: ['download button visible only', 'unparsed file exists only']
690
- }, {
691
- issue_class: 'upload_import',
692
- probe_type: 'issue_class_probe',
693
- failure_class: 'business',
694
- action: 'Run the upload/import workflow with a representative file and assert parsed plus persisted results.',
695
- proof_required: 'Import result message and persisted rows/counts changed as expected.',
696
- required_artifacts: ['input file fixture', 'import result message', 'persisted row/count delta'],
697
- acceptance_gate: 'aiqa_business_assertion',
698
- false_pass_blockers: ['file picker opens only', 'upload toast without persisted delta']
699
- }, {
700
- issue_class: 'route_auth_hydration',
701
- probe_type: 'issue_class_probe',
702
- failure_class: 'route',
703
- action: 'Open the route as the affected user and prove authenticated hydration reaches the functional screen.',
704
- proof_required: 'Hydrated route shows required controls/data for the affected account and no shell-only fallback.',
705
- required_artifacts: ['auth context', 'hydrated DOM proof', 'console/network error log'],
706
- acceptance_gate: 'aiqa_business_assertion',
707
- false_pass_blockers: ['home route proof', 'login shell proof', 'header-only screenshot']
708
- }, {
709
- issue_class: 'slow_query_performance',
710
- probe_type: 'issue_class_probe',
711
- failure_class: 'business',
712
- action: 'Run the reported query/workflow with timing/log evidence before and after the fix.',
713
- proof_required: 'Timing improves or meets target while result equivalence is preserved.',
714
- required_artifacts: ['before timing', 'after timing', 'result equivalence proof', 'query/log trace'],
715
- acceptance_gate: 'aiqa_business_assertion',
716
- false_pass_blockers: ['compile pass only', 'single timing without before/after comparison']
717
- }];
718
- function normalizeSupportSimilarCaseSelection(value, input) {
719
- var object = cleanObject(value);
720
- if (Array.isArray(value)) {
721
- return selectResolveIOSupportSimilarCaseHints(__assign(__assign({}, input), { candidates: value }));
722
- }
723
- if (object.ranked || object.similarTickets || object.similar_tickets || object.similarCommits || object.similar_commits) {
724
- var normalizeRanked = function (entries) { return (Array.isArray(entries) ? entries : [])
725
- .map(function (entry) {
726
- var candidate = normalizeResolveIOSupportSimilarCaseCandidate(entry);
727
- if (!candidate) {
728
- return undefined;
729
- }
730
- var signals = cleanList((entry || {}).structuredSignals || (entry || {}).structured_signals, 10, 160);
731
- return {
732
- id: candidate.id,
733
- ticketNumber: candidate.ticketNumber,
734
- title: candidate.title,
735
- outcome: candidate.outcome,
736
- issueClass: normalizeIssueClass(candidate.issueClass) || candidate.issueClass,
737
- ownerFiles: candidate.ownerFiles.slice(0, 8),
738
- commitSha: candidate.commitSha,
739
- commitMessage: candidate.commitMessage,
740
- reason: cleanText((entry || {}).reason || signals.join('; '), 500),
741
- source: candidate.source,
742
- score: Number((entry || {}).score || 0),
743
- structuredSignals: signals,
744
- advisoryOnly: true
745
- };
746
- })
747
- .filter(function (entry) { return Boolean(entry); })
748
- .slice(0, Math.max(1, Math.min(12, Number(input.limit || 6)))); };
749
- var rankedHints = normalizeRanked(object.ranked);
750
- var ticketHints = normalizeRanked(object.similarTickets || object.similar_tickets);
751
- var commitHints = normalizeRanked(object.similarCommits || object.similar_commits);
752
- var merged = rankedHints.length
753
- ? rankedHints
754
- : __spreadArray(__spreadArray([], __read(ticketHints), false), __read(commitHints), false).sort(function (a, b) { return b.score - a.score; })
755
- .slice(0, Math.max(1, Math.min(12, Number(input.limit || 6))));
756
- return {
757
- ranked: merged,
758
- similarTickets: ticketHints.length ? ticketHints : merged.filter(function (hint) { return hint.source !== 'git_commit'; }),
759
- similarCommits: commitHints.length ? commitHints : merged.filter(function (hint) { return hint.source === 'git_commit' || !!hint.commitSha; }),
760
- ignoredCount: Number(object.ignoredCount || object.ignored_count || 0),
761
- generatedAt: cleanText(object.generatedAt || object.generated_at, 120) || isoNow(input.now)
762
- };
763
- }
764
- return selectResolveIOSupportSimilarCaseHints(input);
765
- }
766
- function buildResolveIOSupportDiagnosisEvidencePack(input) {
767
- var _a, _b, _c, _d, _e, _f, _g, _h;
768
- if (input === void 0) { input = {}; }
769
- var bundle = input.bundle;
770
- var activeMicrotask = bundle
771
- ? selectResolveIOSupportV5ActiveMicrotask(bundle.supportV5MicrotaskLedger || [], bundle.supportV5ActiveMicrotaskId)
772
- : undefined;
773
- var diagnosisSource = input.diagnosisGate || (bundle === null || bundle === void 0 ? void 0 : bundle.supportV5DiagnosisGate);
774
- var validation = validateResolveIOSupportDiagnosisGate(diagnosisSource);
775
- var normalizedDiagnosis = validation.normalized;
776
- var ownerFileHints = cleanList(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(input.ownerFiles, 16, 500)), false), __read(cleanList(normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.owner_files, 16, 500)), false), __read(cleanList(activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.targetFiles, 8, 500)), false), 16, 500).map(normalizeOwnerFilePath).filter(Boolean);
777
- var issueClassHint = normalizeIssueClass(input.issueClass || (normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.issue_class));
778
- var text = cleanText([
779
- input.text,
780
- bundle === null || bundle === void 0 ? void 0 : bundle.supportV5ScopeDigest,
781
- (_a = bundle === null || bundle === void 0 ? void 0 : bundle.supportV5SupervisorState) === null || _a === void 0 ? void 0 : _a.currentGoal,
782
- (_b = input.ticketContext) === null || _b === void 0 ? void 0 : _b.title,
783
- (_c = input.ticketContext) === null || _c === void 0 ? void 0 : _c.subject,
784
- (_d = input.ticketContext) === null || _d === void 0 ? void 0 : _d.summary
785
- ].filter(Boolean).join(' '), 3000);
786
- var similarInput = {
787
- issueClass: issueClassHint || (normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.issue_class),
788
- ownerFiles: ownerFileHints,
789
- text: text,
790
- candidates: Array.isArray(input.similarCaseHints) ? input.similarCaseHints : [],
791
- limit: 6,
792
- now: input.now
793
- };
794
- var similarCaseSelection = normalizeSupportSimilarCaseSelection(input.similarCaseHints, similarInput);
795
- var status = validation.valid
796
- ? 'diagnosis_ready'
797
- : validation.status === 'blocked'
798
- ? 'blocked'
799
- : 'needs_diagnosis';
800
- var generatedAt = isoNow(input.now);
801
- return {
802
- packId: "support-diagnosis-pack-".concat(hashResolveIOSupportV5Evidence({
803
- status: status,
804
- issueClassHint: issueClassHint,
805
- ownerFileHints: ownerFileHints,
806
- blockers: validation.blockers,
807
- text: text,
808
- activeMicrotaskId: activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId
809
- })),
810
- status: status,
811
- readOnly: true,
812
- sourceEditsAllowed: false,
813
- rootCauseFirstRequired: true,
814
- requiredOutputKey: 'support_diagnosis_gate',
815
- requiredFields: SUPPORT_DIAGNOSIS_GATE_REQUIRED_FIELDS,
816
- requiredEvidence: SUPPORT_DIAGNOSIS_REQUIRED_EVIDENCE,
817
- forbiddenActions: SUPPORT_DIAGNOSIS_FORBIDDEN_ACTIONS,
818
- diagnosisValid: validation.valid,
819
- diagnosisStatus: validation.status,
820
- validationBlockers: validation.blockers,
821
- issueClassHint: issueClassHint || undefined,
822
- ownerFileHints: ownerFileHints.slice(0, 12),
823
- activeMicrotaskId: activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId,
824
- similarCaseSelection: similarCaseSelection,
825
- issueClassProbeCatalog: SUPPORT_ISSUE_CLASS_PROBE_CATALOG,
826
- structuredFacts: {
827
- currentDiagnosisStatus: validation.status,
828
- currentDiagnosisValid: validation.valid,
829
- reproductionStatus: normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.issue_case.reproduction_status,
830
- evidenceTypes: ((_e = validation.evidenceQuality) === null || _e === void 0 ? void 0 : _e.evidenceTypes) || [],
831
- reproductionEvidenceTypes: ((_f = validation.evidenceQuality) === null || _f === void 0 ? void 0 : _f.reproductionEvidenceTypes) || [],
832
- rootCauseEvidenceTypes: ((_g = validation.evidenceQuality) === null || _g === void 0 ? void 0 : _g.rootCauseEvidenceTypes) || [],
833
- artifactBackedEvidenceCount: ((_h = validation.evidenceQuality) === null || _h === void 0 ? void 0 : _h.artifactBackedEvidenceCount) || 0,
834
- similarHintCount: similarCaseSelection.ranked.length,
835
- similarHintsAdvisoryOnly: true,
836
- productRepairBlockedUntilDiagnosisPassed: validation.valid !== true
837
- },
838
- generatedAt: generatedAt
839
- };
840
- }
841
- function normalizeSupportDiagnosisBusinessProofContract(value, issueClassHint) {
842
- var source = cleanObject(value);
843
- if (!Object.keys(source).length) {
844
- return undefined;
845
- }
846
- var issueClass = normalizeIssueClass(source.issue_class || source.issueClass || issueClassHint)
847
- || normalizeIssueClass(issueClassHint)
848
- || 'missing_wrong_data';
849
- return {
850
- issue_class: issueClass,
851
- setup_state: pickText(source, ['setup_state', 'setupState', 'before', 'precondition'], 1000),
852
- action_under_test: pickText(source, ['action_under_test', 'actionUnderTest', 'action', 'steps'], 1000),
853
- expected_business_state_change: pickText(source, ['expected_business_state_change', 'expectedBusinessStateChange', 'expected_change', 'expectedChange', 'after'], 1000),
854
- prohibited_false_pass: pickText(source, ['prohibited_false_pass', 'prohibitedFalsePass', 'false_pass', 'falsePass'], 1000),
855
- proof_artifacts: cleanList(source.proof_artifacts || source.proofArtifacts || source.artifacts || source.artifact_paths || source.artifactPaths, 10, 500),
856
- data_or_dom_assertion: pickText(source, ['data_or_dom_assertion', 'dataOrDomAssertion', 'data_assertion', 'dataAssertion', 'dom_assertion', 'domAssertion', 'assertion'], 1000)
857
- };
858
- }
859
- function normalizeOwnerFilePath(value) {
860
- return cleanText(value, 500)
861
- .replace(/\\/g, '/')
862
- .replace(/^\.\/+/, '')
863
- .replace(/^\/+/, '')
864
- .replace(/\s+$/g, '');
865
- }
866
- function ownerFileLooksBroad(value) {
867
- var normalized = normalizeOwnerFilePath(value);
868
- return !normalized
869
- || normalized.includes('*')
870
- || normalized.endsWith('/')
871
- || !/\.[a-z0-9]+$/i.test(normalized)
872
- || /^(\.|src|server|angular|client|app|lib|packages?)$/i.test(normalized)
873
- || /(^|\/)(node_modules|dist|build|coverage|\.git)(\/|$)/i.test(normalized);
874
- }
875
- function proofPlanLooksRouteOnly(proofPlan) {
876
- var assertionText = cleanText([
877
- proofPlan.business_assertion,
878
- proofPlan.action,
879
- proofPlan.after,
880
- proofPlan.data_assertion,
881
- proofPlan.artifact_expectation
882
- ].filter(Boolean).join(' '), 3000).toLowerCase();
883
- if (!assertionText) {
884
- return false;
885
- }
886
- var routeOnlySignal = /\b(route|page|screen|dashboard|url|component|shell)\b/.test(assertionText)
887
- && /\b(loads?|loaded|renders?|rendered|opens?|opened|visible|visibility|hydrates?|hydrated|screenshot)\b/.test(assertionText);
888
- var businessSignal = /\b(save|saved|persist|persisted|create|created|update|updated|delete|deleted|filter|filtered|exclude|excluded|include|included|row|rows|record|records|count|counts|total|totals|value|values|data|mongo|query|result|results|invoice|pdf|export|download|upload|import|dropdown|selection|selected|form|submit|submitted|validation|error message|customer|account|user|permission|auth|control|button|status|calculation|performance|duration|latency)\b/.test(assertionText);
889
- return routeOnlySignal && !businessSignal;
890
- }
891
- var SUPPORT_REPRODUCTION_EVIDENCE_TYPES = new Set(['browser', 'mongo', 'log', 'qa']);
892
- var SUPPORT_ROOT_CAUSE_EVIDENCE_TYPES = new Set(['browser', 'mongo', 'log', 'code', 'commit', 'qa']);
893
- var SUPPORT_ARTIFACT_RECOMMENDED_EVIDENCE_TYPES = new Set(['browser', 'mongo', 'log', 'qa']);
894
- function evaluateResolveIOSupportDiagnosisEvidenceQuality(value) {
895
- var normalized = normalizeResolveIOSupportDiagnosisGate(value);
896
- if (!normalized) {
897
- return {
898
- valid: false,
899
- blockers: ['SupportDiagnosisGate is missing.'],
900
- evidenceTypes: [],
901
- reproductionEvidenceTypes: [],
902
- rootCauseEvidenceTypes: [],
903
- artifactBackedEvidenceCount: 0,
904
- hasTicketContext: false,
905
- hasRootCauseEvidence: false,
906
- hasReproductionEvidence: false
907
- };
908
- }
909
- var evidence = normalized.evidence || [];
910
- var evidenceTypes = Array.from(new Set(evidence.map(function (entry) { return entry.type; })));
911
- var reproductionEvidenceTypes = Array.from(new Set(evidence
912
- .filter(function (entry) { return SUPPORT_REPRODUCTION_EVIDENCE_TYPES.has(entry.type); })
913
- .map(function (entry) { return entry.type; })));
914
- var rootCauseEvidenceTypes = Array.from(new Set(evidence
915
- .filter(function (entry) { return SUPPORT_ROOT_CAUSE_EVIDENCE_TYPES.has(entry.type); })
916
- .map(function (entry) { return entry.type; })));
917
- var artifactBackedEvidenceCount = evidence.filter(function (entry) { return !!entry.artifactPath; }).length;
918
- var hasTicketContext = evidence.some(function (entry) { return entry.type === 'ticket'; })
919
- || Boolean(normalized.issue_case.customer_complaint && normalized.issue_case.account_customer_context);
920
- var hasRootCauseEvidence = rootCauseEvidenceTypes.length > 0;
921
- var hasReproductionEvidence = reproductionEvidenceTypes.length > 0;
922
- var blockers = [];
923
- if (!evidence.length) {
924
- blockers.push('Diagnosis evidence must include typed ticket/code/browser/log/Mongo/QA proof.');
925
- }
926
- if (!hasRootCauseEvidence) {
927
- blockers.push('Diagnosis evidence must include at least one non-ticket root-cause proof item: code, commit, browser, Mongo, log, or QA.');
928
- }
929
- if (!hasTicketContext) {
930
- blockers.push('Diagnosis evidence must preserve the customer/ticket context used for reproduction.');
931
- }
932
- if (normalized.issue_case.reproduction_status === 'reproduced' && !hasReproductionEvidence) {
933
- blockers.push('Diagnosis reproduced issue_case requires browser, Mongo, log, or QA reproduction evidence before repair.');
934
- }
935
- if (normalized.issue_case.reproduction_status === 'blocked'
936
- && !normalized.issue_case.reproduction_blocker) {
937
- blockers.push('Diagnosis blocked reproduction requires issue_case.reproduction_blocker.');
938
- }
939
- var unartifactedRuntimeEvidence = evidence.filter(function (entry) { return SUPPORT_ARTIFACT_RECOMMENDED_EVIDENCE_TYPES.has(entry.type) && !entry.artifactPath; });
940
- if (unartifactedRuntimeEvidence.length) {
941
- blockers.push("Diagnosis runtime evidence must include artifactPath for replayable proof: ".concat(unartifactedRuntimeEvidence.map(function (entry) { return entry.type; }).join(', '), "."));
942
- }
943
- if (normalized.issue_case.reproduction_status === 'reproduced' && artifactBackedEvidenceCount < 1) {
944
- blockers.push('Diagnosis reproduced issue_case requires at least one artifact-backed evidence item.');
945
- }
946
- return {
947
- valid: blockers.length === 0,
948
- blockers: blockers,
949
- evidenceTypes: evidenceTypes,
950
- reproductionEvidenceTypes: reproductionEvidenceTypes,
951
- rootCauseEvidenceTypes: rootCauseEvidenceTypes,
952
- artifactBackedEvidenceCount: artifactBackedEvidenceCount,
953
- hasTicketContext: hasTicketContext,
954
- hasRootCauseEvidence: hasRootCauseEvidence,
955
- hasReproductionEvidence: hasReproductionEvidence
956
- };
957
- }
958
- function normalizeResolveIOSupportDiagnosisGate(value, now) {
959
- var source = cleanObject(value);
960
- if (!Object.keys(source).length) {
961
- return undefined;
962
- }
963
- var issueCaseSource = cleanObject(source.issue_case || source.issueCase);
964
- var hypothesisSource = cleanObject(source.accepted_hypothesis || source.acceptedHypothesis);
965
- var failingPathSource = cleanObject(source.failing_path || source.failingPath);
966
- var proofPlanSource = cleanObject(source.proof_plan || source.proofPlan);
967
- var issueClass = normalizeIssueClass(source.issue_class || source.issueClass);
968
- var businessProofContract = normalizeSupportDiagnosisBusinessProofContract(proofPlanSource.business_proof_contract || proofPlanSource.businessProofContract || source.business_proof_contract || source.businessProofContract, issueClass || source.issue_class || source.issueClass);
969
- var ownerFiles = cleanList(source.owner_files || source.ownerFiles, 20, 500)
970
- .map(normalizeOwnerFilePath)
971
- .filter(Boolean);
972
- var gate = {
973
- issue_case: {
974
- customer_complaint: pickText(issueCaseSource, ['customer_complaint', 'customerComplaint', 'complaint', 'request', 'summary'], 1200),
975
- expected_result: pickText(issueCaseSource, ['expected_result', 'expectedResult', 'expected'], 1000),
976
- observed_result: pickText(issueCaseSource, ['observed_result', 'observedResult', 'observed', 'actual'], 1000),
977
- route_module: pickText(issueCaseSource, ['route_module', 'routeModule', 'route', 'module', 'screen'], 500),
978
- account_customer_context: pickText(issueCaseSource, ['account_customer_context', 'accountCustomerContext', 'account', 'customer', 'user', 'context'], 800),
979
- reproduction_status: normalizeReproductionStatus(issueCaseSource.reproduction_status || issueCaseSource.reproductionStatus || source.reproduction_status),
980
- reproduction_blocker: pickText(issueCaseSource, ['reproduction_blocker', 'reproductionBlocker', 'blocked_reason', 'blockedReason'], 1000)
981
- },
982
- issue_class: issueClass || 'missing_wrong_data',
983
- accepted_hypothesis: {
984
- statement: pickText(hypothesisSource, ['statement', 'hypothesis', 'root_cause', 'rootCause', 'summary'], 1200)
985
- || (typeof source.accepted_hypothesis === 'string' ? cleanText(source.accepted_hypothesis, 1200) : ''),
986
- falsifiable_test: pickText(hypothesisSource, ['falsifiable_test', 'falsifiableTest', 'test', 'proof', 'falsifier'], 1000),
987
- evidence: cleanList(hypothesisSource.evidence || source.hypothesis_evidence || source.hypothesisEvidence, 10, 800)
988
- },
989
- rejected_alternatives: cleanList(source.rejected_alternatives || source.rejectedAlternatives, 10, 700),
990
- failing_path: {
991
- frontend: pickText(failingPathSource, ['frontend', 'frontend_path', 'frontendPath', 'eventPath'], 700),
992
- backend: pickText(failingPathSource, ['backend', 'backend_path', 'backendPath', 'methodPublicationPath'], 700),
993
- shared_library: pickText(failingPathSource, ['shared_library', 'sharedLibrary', 'library', 'lib'], 700),
994
- data_query: pickText(failingPathSource, ['data_query', 'dataQuery', 'query'], 700),
995
- description: pickText(failingPathSource, ['description', 'path', 'summary'], 1200) || cleanText(source.failing_path, 1200)
996
- },
997
- owner_files: ownerFiles,
998
- proof_plan: {
999
- before: pickText(proofPlanSource, ['before', 'before_state', 'beforeState', 'precondition'], 1000),
1000
- before_state_unavailable_reason: pickText(proofPlanSource, ['before_state_unavailable_reason', 'beforeStateUnavailableReason', 'before_unavailable_reason'], 1000),
1001
- action: pickText(proofPlanSource, ['action', 'browser_action', 'browserAction', 'steps'], 1000),
1002
- after: pickText(proofPlanSource, ['after', 'after_state', 'afterState', 'expected_after'], 1000),
1003
- business_assertion: pickText(proofPlanSource, ['business_assertion', 'businessAssertion', 'assertion'], 1000),
1004
- route: pickText(proofPlanSource, ['route', 'url'], 500),
1005
- data_assertion: pickText(proofPlanSource, ['data_assertion', 'dataAssertion', 'mongo_delta', 'mongoDelta'], 1000),
1006
- artifact_expectation: pickText(proofPlanSource, ['artifact_expectation', 'artifactExpectation', 'artifact', 'screenshot'], 1000),
1007
- business_proof_contract: businessProofContract
1008
- },
1009
- similar_tickets: normalizeSupportDiagnosisHints(source.similar_tickets || source.similarTickets),
1010
- similar_commits: normalizeSupportDiagnosisHints(source.similar_commits || source.similarCommits),
1011
- evidence: normalizeSupportDiagnosisEvidence(source.evidence),
1012
- status: cleanText(source.status, 80).toLowerCase() || 'incomplete',
1013
- updatedAt: isoNow(now || source.updatedAt || source.updated_at)
1014
- };
1015
- if (!['missing', 'incomplete', 'blocked', 'passed'].includes(gate.status)) {
1016
- gate.status = 'incomplete';
1017
- }
1018
- return gate;
1019
- }
1020
- function extractResolveIOSupportDiagnosisGateFromText(value, now) {
1021
- var e_4, _a;
1022
- var text = String(value || '').trim();
1023
- if (!text) {
1024
- return undefined;
1025
- }
1026
- var candidates = [];
1027
- var fenced = Array.from(text.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi)).map(function (match) { return match[1]; });
1028
- candidates.push.apply(candidates, __spreadArray([], __read(fenced), false));
1029
- var jsonBlock = text.match(/\{[\s\S]*\}/);
1030
- if (jsonBlock) {
1031
- candidates.push(jsonBlock[0]);
1032
- }
1033
- try {
1034
- for (var candidates_1 = __values(candidates), candidates_1_1 = candidates_1.next(); !candidates_1_1.done; candidates_1_1 = candidates_1.next()) {
1035
- var candidate = candidates_1_1.value;
1036
- try {
1037
- var parsed = JSON.parse(candidate);
1038
- var wrapped = (parsed === null || parsed === void 0 ? void 0 : parsed.support_diagnosis_gate) || (parsed === null || parsed === void 0 ? void 0 : parsed.supportDiagnosisGate) || (parsed === null || parsed === void 0 ? void 0 : parsed.diagnosis_gate) || (parsed === null || parsed === void 0 ? void 0 : parsed.diagnosisGate) || parsed;
1039
- var normalized = normalizeResolveIOSupportDiagnosisGate(wrapped, now);
1040
- if (normalized) {
1041
- return normalized;
1042
- }
1043
- }
1044
- catch (_b) {
1045
- // Continue trying less exact JSON candidates.
1046
- }
1047
- }
1048
- }
1049
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1050
- finally {
1051
- try {
1052
- if (candidates_1_1 && !candidates_1_1.done && (_a = candidates_1.return)) _a.call(candidates_1);
1053
- }
1054
- finally { if (e_4) throw e_4.error; }
1055
- }
1056
- return undefined;
1057
- }
1058
- function validateResolveIOSupportDiagnosisGate(value, options) {
1059
- if (options === void 0) { options = {}; }
1060
- var normalized = normalizeResolveIOSupportDiagnosisGate(value);
1061
- if (!normalized) {
1062
- return { valid: false, status: 'missing', blockers: ['SupportDiagnosisGate is missing.'] };
1063
- }
1064
- var blockers = [];
1065
- var maxOwnerFiles = Math.max(1, Number(options.maxOwnerFiles || 8) || 8);
1066
- if (!normalized.issue_case.customer_complaint) {
1067
- blockers.push('Diagnosis issue_case.customer_complaint is required.');
1068
- }
1069
- if (!normalized.issue_case.expected_result) {
1070
- blockers.push('Diagnosis issue_case.expected_result is required.');
1071
- }
1072
- if (!normalized.issue_case.observed_result) {
1073
- blockers.push('Diagnosis issue_case.observed_result is required.');
1074
- }
1075
- if (!normalized.issue_case.route_module) {
1076
- blockers.push('Diagnosis issue_case.route_module is required.');
1077
- }
1078
- if (!normalized.issue_case.account_customer_context) {
1079
- blockers.push('Diagnosis issue_case.account_customer_context is required.');
1080
- }
1081
- if (normalized.issue_case.reproduction_status === 'blocked' && !normalized.issue_case.reproduction_blocker) {
1082
- blockers.push('Diagnosis blocked reproduction requires issue_case.reproduction_blocker.');
1083
- }
1084
- if (!normalizeIssueClass(normalized.issue_class)) {
1085
- blockers.push('Diagnosis issue_class must be one of the supported issue-class probes.');
1086
- }
1087
- if (!normalized.accepted_hypothesis.statement) {
1088
- blockers.push('Diagnosis accepted_hypothesis.statement is required.');
1089
- }
1090
- if (!normalized.accepted_hypothesis.falsifiable_test) {
1091
- blockers.push('Diagnosis accepted_hypothesis.falsifiable_test is required.');
1092
- }
1093
- if (!normalized.accepted_hypothesis.evidence.length) {
1094
- blockers.push('Diagnosis accepted_hypothesis.evidence must cite proof.');
1095
- }
1096
- if (!normalized.rejected_alternatives.length) {
1097
- blockers.push('Diagnosis rejected_alternatives must include at least one rejected theory.');
1098
- }
1099
- if (!normalized.failing_path.description
1100
- && !normalized.failing_path.frontend
1101
- && !normalized.failing_path.backend
1102
- && !normalized.failing_path.shared_library
1103
- && !normalized.failing_path.data_query) {
1104
- blockers.push('Diagnosis failing_path must identify frontend, backend, query, shared library, or path description.');
1105
- }
1106
- if (!normalized.owner_files.length) {
1107
- blockers.push('Diagnosis owner_files must contain the small editable file set.');
1108
- }
1109
- if (normalized.owner_files.length > maxOwnerFiles) {
1110
- blockers.push("Diagnosis owner_files has ".concat(normalized.owner_files.length, " entries; maximum is ").concat(maxOwnerFiles, "."));
1111
- }
1112
- var broadFiles = normalized.owner_files.filter(ownerFileLooksBroad);
1113
- if (broadFiles.length) {
1114
- blockers.push("Diagnosis owner_files contains broad or unsafe path(s): ".concat(broadFiles.join(', '), "."));
1115
- }
1116
- if (!normalized.proof_plan.before && !normalized.proof_plan.before_state_unavailable_reason) {
1117
- blockers.push('Diagnosis proof_plan.before is required unless proof_plan.before_state_unavailable_reason explains why before-state proof is impossible.');
1118
- }
1119
- if (!normalized.proof_plan.action) {
1120
- blockers.push('Diagnosis proof_plan.action is required.');
1121
- }
1122
- if (!normalized.proof_plan.after) {
1123
- blockers.push('Diagnosis proof_plan.after is required.');
1124
- }
1125
- if (!normalized.proof_plan.business_assertion) {
1126
- blockers.push('Diagnosis proof_plan.business_assertion is required.');
1127
- }
1128
- if (proofPlanLooksRouteOnly(normalized.proof_plan)) {
1129
- blockers.push('Diagnosis proof_plan cannot be route-load, screen-visible, or screenshot-only; it must name the business state/data/control change that proves the issue is fixed.');
1130
- }
1131
- var proofContract = normalized.proof_plan.business_proof_contract;
1132
- if (!proofContract) {
1133
- blockers.push('Diagnosis proof_plan.business_proof_contract is required.');
1134
- }
1135
- else {
1136
- if (proofContract.issue_class !== normalized.issue_class) {
1137
- blockers.push("Diagnosis proof_plan.business_proof_contract.issue_class (".concat(proofContract.issue_class, ") must match diagnosis issue_class (").concat(normalized.issue_class, ")."));
1138
- }
1139
- if (!proofContract.setup_state) {
1140
- blockers.push('Diagnosis proof_plan.business_proof_contract.setup_state is required.');
1141
- }
1142
- if (!proofContract.action_under_test) {
1143
- blockers.push('Diagnosis proof_plan.business_proof_contract.action_under_test is required.');
1144
- }
1145
- if (!proofContract.expected_business_state_change) {
1146
- blockers.push('Diagnosis proof_plan.business_proof_contract.expected_business_state_change is required.');
1147
- }
1148
- if (!proofContract.prohibited_false_pass) {
1149
- blockers.push('Diagnosis proof_plan.business_proof_contract.prohibited_false_pass is required.');
1150
- }
1151
- if (!proofContract.proof_artifacts.length) {
1152
- blockers.push('Diagnosis proof_plan.business_proof_contract.proof_artifacts must include at least one required artifact.');
1153
- }
1154
- if (!proofContract.data_or_dom_assertion) {
1155
- blockers.push('Diagnosis proof_plan.business_proof_contract.data_or_dom_assertion is required.');
1156
- }
1157
- }
1158
- if (!normalized.evidence.length) {
1159
- blockers.push('Diagnosis evidence must include ticket/code/browser/log/Mongo proof.');
1160
- }
1161
- var evidenceQuality = evaluateResolveIOSupportDiagnosisEvidenceQuality(normalized);
1162
- blockers.push.apply(blockers, __spreadArray([], __read(evidenceQuality.blockers), false));
1163
- normalized.status = blockers.length ? 'incomplete' : 'passed';
1164
- return {
1165
- valid: blockers.length === 0,
1166
- status: normalized.status,
1167
- blockers: blockers,
1168
- normalized: normalized,
1169
- evidenceQuality: evidenceQuality
1170
- };
1171
- }
1172
- function normalizeSupportConfidenceLevel(value) {
1173
- var _a, _b;
1174
- var normalized = cleanText((value === null || value === void 0 ? void 0 : value.level) || (value === null || value === void 0 ? void 0 : value.confidenceLevel) || (value === null || value === void 0 ? void 0 : value.confidence_level) || (value === null || value === void 0 ? void 0 : value.category) || value, 80).toLowerCase();
1175
- if (/^high$|^strong$|^accepted$|^a\+?$/.test(normalized)) {
1176
- return 'high';
1177
- }
1178
- if (/^medium$|^moderate$|^review$/.test(normalized)) {
1179
- return 'medium';
1180
- }
1181
- if (/^low$|^weak$|^blocked$|^unknown$/.test(normalized)) {
1182
- return normalized === 'unknown' ? 'unknown' : 'low';
1183
- }
1184
- var score = Number((_b = (_a = value === null || value === void 0 ? void 0 : value.score) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.confidenceScore) !== null && _b !== void 0 ? _b : value === null || value === void 0 ? void 0 : value.confidence_score);
1185
- if (Number.isFinite(score)) {
1186
- if (score >= 0.8) {
1187
- return 'high';
1188
- }
1189
- if (score >= 0.55) {
1190
- return 'medium';
1191
- }
1192
- return 'low';
1193
- }
1194
- return normalized ? 'unknown' : 'unknown';
1195
- }
1196
- function supportReleaseLooksBlocked(value) {
1197
- return /\b(fail|failed|error|blocked|missing|empty|stale|denied|timeout)\b/i.test(cleanText(value, 200));
1198
- }
1199
- function supportStatusLooksPassed(value) {
1200
- return /\b(pass|passed|success|succeeded|complete|completed|ready|not_required|not required)\b/i.test(cleanText(value, 200));
1201
- }
1202
- function nestedObject(source) {
1203
- var e_5, _a;
1204
- var keys = [];
1205
- for (var _i = 1; _i < arguments.length; _i++) {
1206
- keys[_i - 1] = arguments[_i];
1207
- }
1208
- try {
1209
- for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
1210
- var key = keys_1_1.value;
1211
- var value = cleanObject(source[key]);
1212
- if (Object.keys(value).length) {
1213
- return value;
1214
- }
1215
- }
1216
- }
1217
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1218
- finally {
1219
- try {
1220
- if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
1221
- }
1222
- finally { if (e_5) throw e_5.error; }
1223
- }
1224
- return {};
1225
- }
1226
- function resolveSupportReplyReleaseGate(input) {
1227
- var e_6, _a;
1228
- var _b;
1229
- var releaseEvidence = cleanObject(input.releaseEvidence);
1230
- var releaseStatus = cleanText(input.releaseStatus
1231
- || releaseEvidence.status
1232
- || releaseEvidence.releaseStatus
1233
- || releaseEvidence.release_status
1234
- || nestedObject(releaseEvidence, 'deploy_production', 'production').status
1235
- || nestedObject(releaseEvidence, 'deploy_dev', 'dev').status
1236
- || nestedObject(releaseEvidence, 'push_master', 'pushMaster').status, 200);
1237
- var hotfixEvidenceContainer = nestedObject(releaseEvidence, 'hotfix_evidence', 'hotfixEvidence');
1238
- var currentHotfixEvidence = nestedObject(hotfixEvidenceContainer, 'current');
1239
- var hotfixEvidence = cleanObject(input.hotfixEvidence
1240
- || hotfixEvidenceContainer.normalized
1241
- || hotfixEvidenceContainer.evidence
1242
- || currentHotfixEvidence.evidence
1243
- || currentHotfixEvidence.normalized
1244
- || hotfixEvidenceContainer.current_evidence
1245
- || hotfixEvidenceContainer.currentEvidence);
1246
- var hotfixCommitProof = nestedObject(releaseEvidence, 'hotfix_commit_proof', 'hotfixCommitProof');
1247
- var hotfixDurabilityContract = nestedObject(releaseEvidence, 'hotfix_durability_contract', 'hotfixDurabilityContract');
1248
- var hotfixCommitGuard = cleanObject(hotfixCommitProof.github_commit_guard
1249
- || hotfixCommitProof.githubCommitGuard
1250
- || hotfixDurabilityContract.hotfix_commit_guard
1251
- || hotfixDurabilityContract.hotfixCommitGuard
1252
- || hotfixEvidenceContainer.github_commit_guard
1253
- || hotfixEvidenceContainer.githubCommitGuard);
1254
- var hotfixEvidenceStatus = cleanText(hotfixEvidenceContainer.status || currentHotfixEvidence.status || hotfixEvidence.status, 120);
1255
- var releaseGateStatus = cleanText(hotfixEvidence.releaseGateStatus
1256
- || hotfixEvidence.release_gate_status
1257
- || hotfixEvidenceContainer.release_gate_status
1258
- || hotfixEvidenceContainer.releaseGateStatus
1259
- || releaseEvidence.releaseGateStatus
1260
- || releaseEvidence.release_gate_status, 160);
1261
- var releaseGatePassed = input.releaseGatePassed === true
1262
- || supportStatusLooksPassed(releaseGateStatus);
1263
- var missingCommitProofFields = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(hotfixCommitProof.missing_fields || hotfixCommitProof.missingFields, 12, 160)), false), __read(cleanList(hotfixEvidenceContainer.missing_fields || hotfixEvidenceContainer.missingFields, 12, 160)), false), __read(cleanList(hotfixDurabilityContract.missing_commit_proof_fields || hotfixDurabilityContract.missingCommitProofFields, 12, 160)), false), __read(cleanList(hotfixCommitGuard.missing_fields || hotfixCommitGuard.missingFields, 12, 160)), false).filter(Boolean)));
1264
- var commitProofRequired = hotfixCommitProof.required === true
1265
- || hotfixEvidenceContainer.github_commit_required === true
1266
- || hotfixEvidenceContainer.githubCommitRequired === true
1267
- || hotfixCommitGuard.required === true
1268
- || hotfixDurabilityContract.required === true;
1269
- var commitProofPassed = hotfixCommitProof.passed === true
1270
- || hotfixEvidenceContainer.github_commit_proof_passed === true
1271
- || hotfixEvidenceContainer.githubCommitProofPassed === true
1272
- || hotfixCommitGuard.passed === true;
1273
- var commitProofBlocked = hotfixCommitProof.blocked === true
1274
- || hotfixEvidenceContainer.manager_must_commit_before_hotfix === true
1275
- || hotfixEvidenceContainer.managerMustCommitBeforeHotfix === true
1276
- || hotfixDurabilityContract.live_hotfix_blocked_until_commit === true
1277
- || hotfixDurabilityContract.liveHotfixBlockedUntilCommit === true
1278
- || hotfixCommitGuard.manager_must_commit_before_hotfix === true
1279
- || hotfixCommitGuard.managerMustCommitBeforeHotfix === true
1280
- || (commitProofRequired && !commitProofPassed)
1281
- || missingCommitProofFields.length > 0;
1282
- var statusBlocked = supportReleaseLooksBlocked(releaseStatus)
1283
- || supportReleaseLooksBlocked(hotfixEvidenceStatus)
1284
- || supportReleaseLooksBlocked(releaseGateStatus);
1285
- var blockers = [];
1286
- if (statusBlocked) {
1287
- blockers.push("release_status=".concat(releaseStatus || hotfixEvidenceStatus || releaseGateStatus || 'blocked'));
1288
- }
1289
- if (commitProofBlocked) {
1290
- blockers.push('hotfix_commit_proof_missing_or_blocked');
1291
- }
1292
- try {
1293
- for (var missingCommitProofFields_1 = __values(missingCommitProofFields), missingCommitProofFields_1_1 = missingCommitProofFields_1.next(); !missingCommitProofFields_1_1.done; missingCommitProofFields_1_1 = missingCommitProofFields_1.next()) {
1294
- var field = missingCommitProofFields_1_1.value;
1295
- blockers.push("missing_".concat(field));
1296
- }
1297
- }
1298
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1299
- finally {
1300
- try {
1301
- if (missingCommitProofFields_1_1 && !missingCommitProofFields_1_1.done && (_a = missingCommitProofFields_1.return)) _a.call(missingCommitProofFields_1);
1302
- }
1303
- finally { if (e_6) throw e_6.error; }
1304
- }
1305
- var shouldEvaluateHotfix = statusBlocked || commitProofRequired || Object.keys(hotfixEvidence).length > 0;
1306
- var hotfixContinuation = shouldEvaluateHotfix
1307
- ? (0, ai_runner_manager_policy_1.decideResolveIOAIManagerHotfixContinuation)({
1308
- evidence: hotfixEvidence,
1309
- policy: input.releasePolicy,
1310
- releaseGatePassed: releaseGatePassed,
1311
- failureClass: 'release',
1312
- blocker: blockers.join('; ') || releaseStatus || hotfixEvidenceStatus || releaseGateStatus,
1313
- now: undefined
1314
- })
1315
- : undefined;
1316
- if (hotfixContinuation && hotfixContinuation.action !== 'continue_runner' && (statusBlocked || commitProofBlocked || hotfixContinuation.action === 'record_hotfix_evidence' || hotfixContinuation.action === 'rerun_release_gate')) {
1317
- blockers.push("hotfix_next_action=".concat(hotfixContinuation.action));
1318
- }
1319
- var uniqueBlockers = Array.from(new Set(blockers.filter(Boolean)));
1320
- return {
1321
- blocked: uniqueBlockers.length > 0,
1322
- reason: uniqueBlockers.length
1323
- ? 'support_reply_release_or_hotfix_evidence_blocked'
1324
- : 'support_reply_release_or_hotfix_evidence_clear',
1325
- status: releaseStatus || hotfixEvidenceStatus || releaseGateStatus || '',
1326
- blockers: uniqueBlockers,
1327
- requiredEvidence: [
1328
- 'release status passed or explicitly not required',
1329
- 'hotfix commit proof clear when hotfix evidence is required',
1330
- 'sourceCommitSha, githubCommitUrl, gitCommitStatus=passed, gitPushStatus=passed when backend hotfix was used',
1331
- 'release gate passed when hotfix evidence requires gate rerun'
1332
- ],
1333
- nextCommands: ((_b = hotfixContinuation === null || hotfixContinuation === void 0 ? void 0 : hotfixContinuation.nextCommands) === null || _b === void 0 ? void 0 : _b.length)
1334
- ? hotfixContinuation.nextCommands
1335
- : ['record_hotfix_evidence', 'commit_and_push_hotfix_to_github', 'rerun_release_gate_once'],
1336
- hotfixContinuation: hotfixContinuation
1337
- };
1338
- }
1339
- function supportBusinessAssertionPassed(value) {
1340
- return /^(pass|passed|accepted|business_assertion_passed)$/i.test(cleanText(value, 80));
1341
- }
1342
- function supportBusinessAssertionFailed(value) {
1343
- return /^(fail|failed|blocked|needs_repair|business_assertion_failed)$/i.test(cleanText(value, 80));
1344
- }
1345
- function supportBusinessAssertionRouteOnly(value) {
1346
- return /^(route_probe_pass|route_only_pass|route_pass|route_probe|route_loaded)$/i.test(cleanText(value, 80));
1347
- }
1348
- function normalizeSupportBusinessProofAssertions(input) {
1349
- var e_7, _a;
1350
- var gate = normalizeResolveIOSupportDiagnosisGate(input.diagnosisGate);
1351
- var proofPlan = gate === null || gate === void 0 ? void 0 : gate.proof_plan;
1352
- var proofContract = proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.business_proof_contract;
1353
- var artifactPaths = cleanList(input.businessProofArtifacts, 30, 500);
1354
- var assertions = [];
1355
- try {
1356
- for (var _b = __values(Array.isArray(input.businessAssertions) ? input.businessAssertions : []), _c = _b.next(); !_c.done; _c = _b.next()) {
1357
- var entry = _c.value;
1358
- var source = cleanObject(entry);
1359
- if (!Object.keys(source).length) {
1360
- continue;
1361
- }
1362
- var metadata = cleanObject(source.metadata);
1363
- assertions.push({
1364
- assertion: pickText(source, ['assertion', 'name', 'workflow', 'expected'], 1000) || (proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.business_assertion) || 'business assertion',
1365
- status: cleanText(source.status || source.outcome || source.result, 80),
1366
- workflow: pickText(source, ['workflow', 'workflowName'], 400),
1367
- route: pickText(source, ['route', 'url'], 500),
1368
- before: pickText(source, ['before', 'before_state', 'beforeState'], 1000),
1369
- action: pickText(source, ['action', 'action_under_test', 'actionUnderTest'], 1000),
1370
- expected: pickText(source, ['expected', 'expected_business_state_change', 'expectedBusinessStateChange'], 1000),
1371
- after: pickText(source, ['after', 'after_state', 'afterState'], 1000),
1372
- observed: pickText(source, ['observed', 'actual'], 1000),
1373
- dataProof: pickText(source, ['dataProof', 'data_proof', 'proof', 'domProof', 'dom_proof'], 1400),
1374
- mongoDelta: cleanObject(source.mongoDelta || source.mongo_delta),
1375
- artifactPaths: cleanList(source.artifactPaths || source.artifact_paths || source.artifacts, 30, 500),
1376
- message: pickText(source, ['message', 'reason', 'summary'], 1000),
1377
- acceptanceBlocked: source.acceptanceBlocked === true || source.acceptance_blocked === true || metadata.acceptanceBlocked === true || metadata.acceptance_blocked === true,
1378
- routeOnly: source.routeOnly === true || source.route_only === true || source.outcome === 'route_only_pass' || source.status === 'route_probe_pass' || metadata.routeOnly === true || metadata.route_only === true,
1379
- metadata: metadata
1380
- });
1381
- }
1382
- }
1383
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1384
- finally {
1385
- try {
1386
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1387
- }
1388
- finally { if (e_7) throw e_7.error; }
1389
- }
1390
- var status = cleanText(input.businessAssertionStatus || input.outcomeLabel, 80);
1391
- if (!assertions.length && (supportBusinessAssertionPassed(status) || supportBusinessAssertionRouteOnly(status) || supportBusinessAssertionFailed(status))) {
1392
- assertions.push({
1393
- assertion: (proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.business_assertion) || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion) || 'business assertion',
1394
- status: status,
1395
- workflow: proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test,
1396
- route: (proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.route) || (gate === null || gate === void 0 ? void 0 : gate.issue_case.route_module),
1397
- before: proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.before,
1398
- action: (proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.action) || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test),
1399
- expected: (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || (proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.after),
1400
- after: proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.after,
1401
- observed: '',
1402
- dataProof: (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion) || (proofPlan === null || proofPlan === void 0 ? void 0 : proofPlan.data_assertion) || '',
1403
- mongoDelta: {},
1404
- artifactPaths: artifactPaths,
1405
- message: '',
1406
- acceptanceBlocked: supportBusinessAssertionRouteOnly(status),
1407
- routeOnly: supportBusinessAssertionRouteOnly(status),
1408
- metadata: {}
1409
- });
1410
- }
1411
- return assertions;
1412
- }
1413
- function supportBusinessProofAssertionText(assertion) {
1414
- return cleanText([
1415
- assertion.assertion,
1416
- assertion.workflow,
1417
- assertion.before,
1418
- assertion.action,
1419
- assertion.expected,
1420
- assertion.after,
1421
- assertion.observed,
1422
- assertion.dataProof,
1423
- assertion.message
1424
- ].filter(Boolean).join(' '), 4000);
1425
- }
1426
- function supportBusinessProofAssertionMatchesContract(assertion, gate) {
1427
- var e_8, _a;
1428
- if (!gate) {
1429
- return false;
1430
- }
1431
- var metadata = assertion.metadata || {};
1432
- if (metadata.supportDiagnosisProof === true
1433
- || metadata.support_diagnosis_proof === true
1434
- || metadata.diagnosisProofPlanMatched === true
1435
- || metadata.diagnosis_proof_plan_matched === true
1436
- || metadata.proofPlanMatched === true
1437
- || metadata.proof_plan_matched === true) {
1438
- return true;
1439
- }
1440
- var proofPlan = gate.proof_plan;
1441
- var proofContract = proofPlan.business_proof_contract;
1442
- var requiredParts = [
1443
- proofPlan.business_assertion,
1444
- proofPlan.after,
1445
- proofPlan.data_assertion,
1446
- proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change,
1447
- proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion
1448
- ].map(function (part) { return cleanText(part, 1000).toLowerCase(); }).filter(function (part) { return part.length >= 12; });
1449
- var assertionText = supportBusinessProofAssertionText(assertion).toLowerCase();
1450
- if (!requiredParts.length) {
1451
- return false;
1452
- }
1453
- if (requiredParts.some(function (part) { return assertionText.includes(part); })) {
1454
- return true;
1455
- }
1456
- var proofWords = new Set(requiredParts.join(' ').split(/[^a-z0-9]+/g).filter(function (word) { return word.length >= 5; }));
1457
- var assertionWords = new Set(assertionText.split(/[^a-z0-9]+/g).filter(function (word) { return word.length >= 5; }));
1458
- var overlap = 0;
1459
- try {
1460
- for (var proofWords_1 = __values(proofWords), proofWords_1_1 = proofWords_1.next(); !proofWords_1_1.done; proofWords_1_1 = proofWords_1.next()) {
1461
- var word = proofWords_1_1.value;
1462
- if (assertionWords.has(word)) {
1463
- overlap += 1;
1464
- }
1465
- }
1466
- }
1467
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
1468
- finally {
1469
- try {
1470
- if (proofWords_1_1 && !proofWords_1_1.done && (_a = proofWords_1.return)) _a.call(proofWords_1);
1471
- }
1472
- finally { if (e_8) throw e_8.error; }
1473
- }
1474
- return overlap >= Math.min(5, Math.max(3, Math.ceil(proofWords.size * 0.45)));
1475
- }
1476
- function supportBusinessProofArtifactFingerprint(paths) {
1477
- var normalized = cleanList(paths, 80, 500).sort();
1478
- return normalized.length ? hashResolveIOSupportV5Evidence({ artifacts: normalized }) : '';
1479
- }
1480
- function supportBusinessProofFingerprint(gate, assertion, artifactPaths) {
1481
- var _a;
1482
- if (artifactPaths === void 0) { artifactPaths = []; }
1483
- if (!gate || !assertion) {
1484
- return '';
1485
- }
1486
- var proofPlan = gate.proof_plan;
1487
- var proofContract = proofPlan.business_proof_contract;
1488
- return hashResolveIOSupportV5Evidence({
1489
- issueClass: gate.issue_class,
1490
- proofPlan: {
1491
- before: proofPlan.before,
1492
- action: proofPlan.action,
1493
- after: proofPlan.after,
1494
- businessAssertion: proofPlan.business_assertion,
1495
- dataAssertion: proofPlan.data_assertion,
1496
- contractAction: proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test,
1497
- contractExpected: proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change,
1498
- contractAssertion: proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion
1499
- },
1500
- assertion: {
1501
- assertion: assertion.assertion,
1502
- status: assertion.status,
1503
- workflow: assertion.workflow,
1504
- route: assertion.route,
1505
- before: assertion.before,
1506
- action: assertion.action,
1507
- expected: assertion.expected,
1508
- after: assertion.after,
1509
- observed: assertion.observed,
1510
- dataProof: assertion.dataProof,
1511
- mongoDelta: assertion.mongoDelta
1512
- },
1513
- artifacts: cleanList(((_a = assertion.artifactPaths) === null || _a === void 0 ? void 0 : _a.length) ? assertion.artifactPaths : artifactPaths, 80, 500).sort()
1514
- });
1515
- }
1516
- function defaultSupportBusinessProofReadinessFields(values) {
1517
- if (values === void 0) { values = {}; }
1518
- var artifactPaths = cleanList(values.artifactPaths, 80, 500);
1519
- return {
1520
- artifactPaths: artifactPaths,
1521
- proofFingerprint: cleanText(values.proofFingerprint, 160),
1522
- artifactFingerprint: cleanText(values.artifactFingerprint, 160) || supportBusinessProofArtifactFingerprint(artifactPaths),
1523
- proofFreshness: values.proofFreshness || (artifactPaths.length ? 'unknown' : 'missing')
1524
- };
1525
- }
1526
- function evaluateResolveIOSupportBusinessProofReadiness(input) {
1527
- if (input === void 0) { input = {}; }
1528
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.diagnosisGate);
1529
- var gate = diagnosisValidation.normalized;
1530
- var requiredEvidence = [
1531
- 'valid SupportDiagnosisGate proof_plan',
1532
- 'AIQaBusinessAssertion status=pass',
1533
- 'business assertion maps to diagnosis proof_plan/business_proof_contract',
1534
- 'artifact path for browser/data proof',
1535
- 'DOM/data proof or Mongo delta for the expected business state change'
1536
- ];
1537
- if (!diagnosisValidation.valid || !gate) {
1538
- return __assign({ ready: false, status: 'blocked', reason: 'support_business_proof_waiting_on_valid_diagnosis', blockers: diagnosisValidation.blockers.length ? diagnosisValidation.blockers : ['Valid SupportDiagnosisGate is required before business proof can accept the ticket.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields());
1539
- }
1540
- var assertions = normalizeSupportBusinessProofAssertions(input);
1541
- if (!assertions.length) {
1542
- return __assign({ ready: false, status: 'missing', reason: 'support_business_proof_missing_aiqa_business_assertion', blockers: ['No AIQaBusinessAssertion was recorded for the diagnosis proof_plan.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields());
1543
- }
1544
- var artifactPaths = Array.from(new Set(assertions.flatMap(function (assertion) { return assertion.artifactPaths || []; })));
1545
- var artifactFingerprint = supportBusinessProofArtifactFingerprint(artifactPaths);
1546
- var failed = assertions.find(function (assertion) { return supportBusinessAssertionFailed(assertion.status); });
1547
- if (failed) {
1548
- var failedFingerprint = supportBusinessProofFingerprint(gate, failed, artifactPaths);
1549
- return __assign(__assign({ ready: false, status: 'failed', reason: 'support_business_proof_assertion_failed', blockers: [failed.message || failed.observed || failed.assertion || 'Business assertion failed.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields({
1550
- artifactPaths: artifactPaths,
1551
- proofFingerprint: failedFingerprint,
1552
- artifactFingerprint: artifactFingerprint,
1553
- proofFreshness: 'fresh'
1554
- })), { matchedAssertion: failed });
1555
- }
1556
- var routeOnly = assertions.find(function (assertion) { return assertion.routeOnly || assertion.acceptanceBlocked || supportBusinessAssertionRouteOnly(assertion.status) || proofPlanLooksRouteOnly({
1557
- before: assertion.before || '',
1558
- action: assertion.action || '',
1559
- after: assertion.after || assertion.expected || '',
1560
- business_assertion: assertion.assertion || assertion.message || '',
1561
- data_assertion: assertion.dataProof || '',
1562
- artifact_expectation: assertion.artifactPaths.join(', ')
1563
- }); });
1564
- if (routeOnly) {
1565
- var routeOnlyFingerprint = supportBusinessProofFingerprint(gate, routeOnly, artifactPaths);
1566
- return __assign(__assign({ ready: false, status: 'route_only', reason: 'support_business_proof_route_only_or_acceptance_blocked', blockers: ['Route probe, shell/screenshot, or acceptance_blocked proof cannot accept the ticket. Run the issue-class business assertion.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields({
1567
- artifactPaths: artifactPaths,
1568
- proofFingerprint: routeOnlyFingerprint,
1569
- artifactFingerprint: artifactFingerprint,
1570
- proofFreshness: 'fresh'
1571
- })), { matchedAssertion: routeOnly });
1572
- }
1573
- var passedAssertions = assertions.filter(function (assertion) { return supportBusinessAssertionPassed(assertion.status); });
1574
- var matched = passedAssertions.find(function (assertion) { return supportBusinessProofAssertionMatchesContract(assertion, gate); });
1575
- if (!matched) {
1576
- return __assign({ ready: false, status: 'weak', reason: 'support_business_proof_does_not_match_diagnosis_contract', blockers: ['A passed assertion exists, but it does not map to the diagnosis proof_plan/business_proof_contract.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields({ artifactPaths: artifactPaths, artifactFingerprint: artifactFingerprint }));
1577
- }
1578
- var proofArtifactPaths = matched.artifactPaths.length ? matched.artifactPaths : artifactPaths;
1579
- var proofFingerprint = supportBusinessProofFingerprint(gate, matched, proofArtifactPaths);
1580
- var matchedArtifactFingerprint = supportBusinessProofArtifactFingerprint(proofArtifactPaths);
1581
- var previousProofFingerprint = cleanText(input.previousProofFingerprint, 160);
1582
- var previousArtifactFingerprint = cleanText(input.previousArtifactFingerprint, 160);
1583
- var sameProofAsPrevious = !!previousProofFingerprint && previousProofFingerprint === proofFingerprint;
1584
- var sameArtifactAsPrevious = !!previousArtifactFingerprint && previousArtifactFingerprint === matchedArtifactFingerprint;
1585
- if (sameProofAsPrevious || sameArtifactAsPrevious) {
1586
- return __assign(__assign({ ready: false, status: 'stale', reason: sameProofAsPrevious
1587
- ? 'support_business_proof_same_fingerprint_as_previous'
1588
- : 'support_business_proof_same_artifact_fingerprint_as_previous', blockers: ['Business proof did not produce a new proof/artifact fingerprint for this run. Rerun the issue-specific assertion and record fresh artifact proof.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields({
1589
- artifactPaths: proofArtifactPaths,
1590
- proofFingerprint: proofFingerprint,
1591
- artifactFingerprint: matchedArtifactFingerprint,
1592
- proofFreshness: sameProofAsPrevious ? 'same_as_previous' : 'stale_artifact'
1593
- })), { matchedAssertion: matched });
1594
- }
1595
- if (!matched.artifactPaths.length && !artifactPaths.length) {
1596
- return __assign(__assign({ ready: false, status: 'weak', reason: 'support_business_proof_missing_artifact_path', blockers: ['Business proof must include at least one artifact path.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields({
1597
- artifactPaths: artifactPaths,
1598
- proofFingerprint: proofFingerprint,
1599
- artifactFingerprint: matchedArtifactFingerprint
1600
- })), { matchedAssertion: matched });
1601
- }
1602
- var hasDataOrDomProof = !!cleanText(matched.dataProof, 50)
1603
- || Object.keys(cleanObject(matched.mongoDelta)).length > 0
1604
- || !!cleanText(matched.observed, 80)
1605
- || !!cleanText(matched.after, 80);
1606
- if (!hasDataOrDomProof) {
1607
- return __assign(__assign({ ready: false, status: 'weak', reason: 'support_business_proof_missing_dom_or_data_proof', blockers: ['Business proof must include DOM/data proof, observed result, after-state, or Mongo delta.'], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields({
1608
- artifactPaths: proofArtifactPaths,
1609
- proofFingerprint: proofFingerprint,
1610
- artifactFingerprint: matchedArtifactFingerprint
1611
- })), { matchedAssertion: matched });
1612
- }
1613
- return __assign(__assign({ ready: true, status: 'passed', reason: 'support_business_proof_ready', blockers: [], requiredEvidence: requiredEvidence }, defaultSupportBusinessProofReadinessFields({
1614
- artifactPaths: proofArtifactPaths,
1615
- proofFingerprint: proofFingerprint,
1616
- artifactFingerprint: matchedArtifactFingerprint,
1617
- proofFreshness: 'fresh'
1618
- })), { matchedAssertion: matched });
1619
- }
1620
- function buildSupportClarificationQuestion(gate, blockers) {
1621
- if ((gate === null || gate === void 0 ? void 0 : gate.issue_case.reproduction_status) === 'blocked' && gate.issue_case.reproduction_blocker) {
1622
- return "Can you provide the missing detail needed to reproduce this issue: ".concat(gate.issue_case.reproduction_blocker, "?");
1623
- }
1624
- if (blockers.some(function (blocker) { return /expected_result/.test(blocker); })) {
1625
- return 'What result did you expect to see in this workflow?';
1626
- }
1627
- if (blockers.some(function (blocker) { return /observed_result/.test(blocker); })) {
1628
- return 'What exact result are you seeing instead, including the affected record or screen if possible?';
1629
- }
1630
- if (blockers.some(function (blocker) { return /account_customer_context/.test(blocker); })) {
1631
- return 'Which customer/account/user context should we use to reproduce this issue?';
1632
- }
1633
- return 'Can you send one concrete example record, screen, or action path where this issue still occurs?';
1634
- }
1635
- function resolveSupportClarificationMissingField(gate, blockers) {
1636
- if ((gate === null || gate === void 0 ? void 0 : gate.issue_case.reproduction_status) === 'blocked' && gate.issue_case.reproduction_blocker) {
1637
- return 'reproduction_blocker';
1638
- }
1639
- if (blockers.some(function (blocker) { return /expected_result/.test(blocker); })) {
1640
- return 'expected_result';
1641
- }
1642
- if (blockers.some(function (blocker) { return /observed_result/.test(blocker); })) {
1643
- return 'observed_result';
1644
- }
1645
- if (blockers.some(function (blocker) { return /account_customer_context/.test(blocker); })) {
1646
- return 'account_customer_context';
1647
- }
1648
- return 'example_record_or_action_path';
1649
- }
1650
- function buildResolveIOSupportClarificationContract(gate, blockers, now) {
1651
- if (blockers === void 0) { blockers = []; }
1652
- var sourceBlockers = cleanList(blockers, 20, 500);
1653
- var missingField = resolveSupportClarificationMissingField(gate, sourceBlockers);
1654
- var question = buildSupportClarificationQuestion(gate, sourceBlockers);
1655
- var createdAt = isoNow(now);
1656
- return {
1657
- contractId: "support-clarification-".concat(hashResolveIOSupportV5Evidence({
1658
- missingField: missingField,
1659
- question: question,
1660
- sourceBlockers: sourceBlockers,
1661
- ticketRoute: gate === null || gate === void 0 ? void 0 : gate.issue_case.route_module,
1662
- createdAt: createdAt.slice(0, 16)
1663
- }).slice(0, 16)),
1664
- status: 'ready',
1665
- missingField: missingField,
1666
- question: question,
1667
- sourceBlockers: sourceBlockers,
1668
- oneQuestionOnly: (question.match(/\?/g) || []).length === 1,
1669
- customerFacingDraftAllowed: true,
1670
- customerSendAllowed: false,
1671
- parksTicketUntilCustomerReply: true,
1672
- nextCommands: ['review_customer_clarification', 'send_after_human_review', 'park_ticket_until_customer_reply'],
1673
- forbiddenActions: [
1674
- 'Do not run product repair from a guessed reproduction path.',
1675
- 'Do not ask multiple customer questions in one automated clarification.',
1676
- 'Do not mark the ticket resolved from a clarification draft.'
1677
- ],
1678
- requiredEvidence: [
1679
- "missing_field=".concat(missingField),
1680
- 'one customer-facing question',
1681
- 'human approval before send',
1682
- 'park_ticket_until_customer_reply'
1683
- ],
1684
- createdAt: createdAt
1685
- };
1686
- }
1687
- function validateResolveIOSupportClarificationContract(value) {
1688
- var source = cleanObject(value);
1689
- var missingField = cleanText(source.missingField || source.missing_field, 120);
1690
- var question = cleanText(source.question, 1000);
1691
- var sourceBlockers = cleanList(source.sourceBlockers || source.source_blockers, 20, 500);
1692
- var questionMarkCount = (question.match(/\?/g) || []).length;
1693
- var normalized = {
1694
- contractId: cleanText(source.contractId || source.contract_id, 160),
1695
- status: source.status === 'ready' ? 'ready' : 'blocked',
1696
- missingField: missingField,
1697
- question: question,
1698
- sourceBlockers: sourceBlockers,
1699
- oneQuestionOnly: source.oneQuestionOnly === true || source.one_question_only === true || questionMarkCount === 1,
1700
- customerFacingDraftAllowed: source.customerFacingDraftAllowed === true || source.customer_facing_draft_allowed === true,
1701
- customerSendAllowed: source.customerSendAllowed === true || source.customer_send_allowed === true,
1702
- parksTicketUntilCustomerReply: source.parksTicketUntilCustomerReply === true || source.parks_ticket_until_customer_reply === true,
1703
- nextCommands: cleanList(source.nextCommands || source.next_commands, 12, 200),
1704
- forbiddenActions: cleanList(source.forbiddenActions || source.forbidden_actions, 12, 500),
1705
- requiredEvidence: cleanList(source.requiredEvidence || source.required_evidence, 12, 500),
1706
- createdAt: cleanText(source.createdAt || source.created_at, 120)
1707
- };
1708
- var validMissingFields = [
1709
- 'reproduction_blocker',
1710
- 'expected_result',
1711
- 'observed_result',
1712
- 'account_customer_context',
1713
- 'example_record_or_action_path'
1714
- ];
1715
- var blockers = [
1716
- normalized.contractId ? '' : 'Clarification contract is missing contractId.',
1717
- validMissingFields.includes(normalized.missingField) ? '' : 'Clarification contract is missing a valid missingField.',
1718
- question.length >= 20 && question.length <= 500 ? '' : 'Clarification question must be 20-500 characters.',
1719
- questionMarkCount === 1 && normalized.oneQuestionOnly ? '' : 'Clarification contract must contain exactly one customer question.',
1720
- normalized.customerFacingDraftAllowed === true ? '' : 'Clarification draft must be customer-facing so the operator can review it.',
1721
- normalized.customerSendAllowed === false ? '' : 'Clarification contract must never allow automatic customer send.',
1722
- normalized.parksTicketUntilCustomerReply === true ? '' : 'Clarification contract must park the ticket until customer reply.',
1723
- normalized.nextCommands.includes('park_ticket_until_customer_reply') ? '' : 'Clarification nextCommands must include park_ticket_until_customer_reply.',
1724
- normalized.forbiddenActions.length ? '' : 'Clarification contract must include forbiddenActions.'
1725
- ].filter(Boolean);
1726
- normalized.status = blockers.length ? 'blocked' : 'ready';
1727
- return {
1728
- valid: blockers.length === 0,
1729
- status: normalized.status,
1730
- blockers: blockers,
1731
- normalized: normalized
1732
- };
1733
- }
1734
- function buildResolveIOSupportHumanReviewPacket(input) {
1735
- return {
1736
- reviewType: input.reviewType,
1737
- title: cleanText(input.title, 200) || 'Review Support Runner Action',
1738
- summary: cleanText(input.summary || input.reason, 1000),
1739
- primaryAction: cleanText(input.primaryAction, 160) || 'review_support_runner_action',
1740
- question: cleanText(input.question, 1000) || undefined,
1741
- customerFacingDraftAllowed: input.customerFacingDraftAllowed === true,
1742
- customerSendAllowed: false,
1743
- requiresHumanApproval: input.requiresHumanApproval !== false,
1744
- safety: input.safety || 'internal_hold',
1745
- reason: cleanText(input.reason, 500),
1746
- blockers: cleanList(input.blockers, 20, 500),
1747
- requiredEvidence: cleanList(input.requiredEvidence, 30, 500),
1748
- evidenceRefs: cleanList(input.evidenceRefs, 40, 500),
1749
- nextCommands: cleanList(input.nextCommands, 20, 200),
1750
- forbiddenActions: Array.from(new Set(__spreadArray([
1751
- 'Do not send customer email without explicit human approval.'
1752
- ], __read(cleanList(input.forbiddenActions, 20, 500)), false))),
1753
- costRisk: input.costRisk || 'small_model_or_qa',
1754
- createdAt: isoNow(input.now)
1755
- };
1756
- }
1757
- function supportCustomerReplyReadinessStatusFromReason(reason) {
1758
- var statusByReason = {
1759
- support_reply_clarification_contract_invalid: 'internal_blocked',
1760
- support_reply_waiting_on_customer_reproduction_detail: 'clarification_required',
1761
- support_reply_blocked_until_diagnosis_gate_validates: 'blocked_until_diagnosis',
1762
- support_reply_requires_valid_issue_class_probe_plan: 'blocked_until_probe_plan',
1763
- support_reply_blocked_by_confidence_gate: 'blocked_until_confidence',
1764
- support_reply_requires_high_confidence: 'blocked_until_confidence',
1765
- support_reply_blocked_by_unresolved_runner_blocker: 'blocked_until_runner_blocker',
1766
- support_reply_blocked_until_release_or_hotfix_gate_finishes: 'blocked_until_release_hotfix',
1767
- support_reply_rejects_route_only_business_proof: 'blocked_until_business_proof',
1768
- support_reply_requires_business_assertion_pass: 'blocked_until_business_proof',
1769
- support_reply_requires_business_proof_contract_artifact: 'blocked_until_business_proof_artifact',
1770
- support_reply_resolution_draft_allowed_after_business_proof: 'draft_ready'
1771
- };
1772
- return statusByReason[reason] || 'internal_blocked';
1773
- }
1774
- function supportCustomerReplyReadinessDefaultPrimaryCommand(status, policy) {
1775
- var reviewPacket = policy.humanReviewPacket;
1776
- var preferred = cleanText(reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.primaryAction, 160);
1777
- if (preferred) {
1778
- return preferred;
1779
- }
1780
- switch (status) {
1781
- case 'draft_ready':
1782
- return 'review_customer_reply';
1783
- case 'clarification_required':
1784
- return 'review_customer_clarification';
1785
- case 'blocked_until_diagnosis':
1786
- return 'run_support_v5_read_only_diagnosis_gate';
1787
- case 'blocked_until_probe_plan':
1788
- return 'repair_support_issue_class_probe_plan';
1789
- case 'blocked_until_confidence':
1790
- return 'review_support_confidence_evidence';
1791
- case 'blocked_until_release_hotfix':
1792
- return 'repair_release_hotfix_first';
1793
- case 'blocked_until_business_proof':
1794
- return 'run_support_v5_business_proof_qa_row';
1795
- case 'blocked_until_business_proof_artifact':
1796
- return 'record_business_proof_artifact';
1797
- case 'blocked_until_runner_blocker':
1798
- return 'review_support_runner_blocker';
1799
- case 'blocked_until_human_approval':
1800
- return 'review_customer_reply';
1801
- case 'internal_blocked':
1802
- default:
1803
- return 'review_support_runner_blocker';
1804
- }
1805
- }
1806
- function buildResolveIOSupportCustomerReplyReadinessContract(input) {
1807
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1808
- var policy = input.policy;
1809
- var reviewPacket = policy.humanReviewPacket;
1810
- var reason = cleanText(policy.reason, 500);
1811
- var rawCanSend = policy.canSendCustomerReply === true || (reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.customerSendAllowed) === true;
1812
- var businessProofReady = ((_a = input.businessProofReadiness) === null || _a === void 0 ? void 0 : _a.ready) === true
1813
- || (policy.action === 'draft_resolution_reply' && (((_b = policy.draftBasis) === null || _b === void 0 ? void 0 : _b.artifactCount) || 0) > 0);
1814
- var releaseReady = ((_c = input.releaseGate) === null || _c === void 0 ? void 0 : _c.blocked) !== true;
1815
- var diagnosisReady = ((_d = input.diagnosisValidation) === null || _d === void 0 ? void 0 : _d.valid) === true || policy.action === 'draft_resolution_reply';
1816
- var issueClassProbePlanReady = ((_e = input.issueClassProbePlanValidation) === null || _e === void 0 ? void 0 : _e.valid) === true
1817
- || ((_f = policy.draftBasis) === null || _f === void 0 ? void 0 : _f.issueClassProbePlanStatus) === 'ready';
1818
- var initialStatus = supportCustomerReplyReadinessStatusFromReason(reason);
1819
- var status = rawCanSend
1820
- ? 'blocked_until_human_approval'
1821
- : initialStatus;
1822
- var canDraft = policy.canDraftCustomerReply === true
1823
- && !rawCanSend
1824
- && (status === 'draft_ready' || status === 'clarification_required');
1825
- var requiresHumanApproval = true;
1826
- var primaryCommand = supportCustomerReplyReadinessDefaultPrimaryCommand(status, policy);
1827
- var blockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.blockers, 20, 500)), false), __read(cleanList((_g = input.businessProofReadiness) === null || _g === void 0 ? void 0 : _g.blockers, 20, 500)), false), __read(cleanList((_h = input.releaseGate) === null || _h === void 0 ? void 0 : _h.blockers, 20, 500)), false), __read((rawCanSend ? ['automatic_customer_send_not_allowed'] : [])), false), __read((status === 'draft_ready' ? [] : [reason || status])), false).filter(Boolean)));
1828
- var requiredEvidence = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(policy.requiredEvidence, 30, 500)), false), __read(cleanList(reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.requiredEvidence, 30, 500)), false), __read(cleanList((_j = input.businessProofReadiness) === null || _j === void 0 ? void 0 : _j.requiredEvidence, 30, 500)), false), __read(cleanList((_k = input.releaseGate) === null || _k === void 0 ? void 0 : _k.requiredEvidence, 30, 500)), false).filter(Boolean)));
1829
- var evidenceRefs = Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.evidenceRefs, 40, 500)), false), __read(cleanList((_l = input.businessProofReadiness) === null || _l === void 0 ? void 0 : _l.artifactPaths, 40, 500)), false).filter(Boolean)));
1830
- var nextCommands = Array.from(new Set(__spreadArray(__spreadArray([
1831
- primaryCommand
1832
- ], __read(cleanList(reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.nextCommands, 20, 200)), false), __read(cleanList((_m = input.releaseGate) === null || _m === void 0 ? void 0 : _m.nextCommands, 20, 200)), false).filter(Boolean)));
1833
- var forbiddenActions = Array.from(new Set(__spreadArray([
1834
- 'Do not send customer email without explicit human approval.',
1835
- 'Do not claim a fix is live until release or hotfix evidence is clear.',
1836
- 'Do not draft a resolution reply from route-load, screenshot-only, scorecard-only, or model-claim proof.'
1837
- ], __read(cleanList(reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.forbiddenActions, 20, 500)), false)));
1838
- var createdAt = isoNow(input.now || (reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.createdAt));
1839
- return {
1840
- contractId: "support-customer-reply-".concat(hashResolveIOSupportV5Evidence({
1841
- status: status,
1842
- policyAction: policy.action,
1843
- reason: reason,
1844
- primaryCommand: primaryCommand,
1845
- blockers: blockers,
1846
- artifactFingerprint: (_o = input.businessProofReadiness) === null || _o === void 0 ? void 0 : _o.artifactFingerprint,
1847
- proofFingerprint: (_p = input.businessProofReadiness) === null || _p === void 0 ? void 0 : _p.proofFingerprint,
1848
- createdAt: createdAt.slice(0, 16)
1849
- }).slice(0, 16)),
1850
- status: status,
1851
- policyAction: policy.action,
1852
- reviewType: (reviewPacket === null || reviewPacket === void 0 ? void 0 : reviewPacket.reviewType) || (policy.action === 'draft_resolution_reply' ? 'customer_resolution_reply' : policy.action === 'ask_clarification' ? 'customer_clarification' : 'internal_hold'),
1853
- primaryCommand: primaryCommand,
1854
- canDraftCustomerReply: canDraft,
1855
- canSendCustomerReply: false,
1856
- requiresHumanApproval: requiresHumanApproval,
1857
- proofBacked: status === 'draft_ready' && businessProofReady && evidenceRefs.length > 0,
1858
- businessProofReady: businessProofReady,
1859
- releaseReady: releaseReady,
1860
- diagnosisReady: diagnosisReady,
1861
- issueClassProbePlanReady: issueClassProbePlanReady,
1862
- clarificationRequired: status === 'clarification_required',
1863
- reason: reason,
1864
- blockers: blockers,
1865
- requiredEvidence: requiredEvidence,
1866
- evidenceRefs: evidenceRefs,
1867
- nextCommands: nextCommands,
1868
- forbiddenActions: forbiddenActions,
1869
- createdAt: createdAt
1870
- };
1871
- }
1872
- function validateResolveIOSupportCustomerReplyReadinessContract(value) {
1873
- var source = cleanObject(value);
1874
- var validStatuses = [
1875
- 'draft_ready',
1876
- 'clarification_required',
1877
- 'blocked_until_diagnosis',
1878
- 'blocked_until_probe_plan',
1879
- 'blocked_until_confidence',
1880
- 'blocked_until_runner_blocker',
1881
- 'blocked_until_release_hotfix',
1882
- 'blocked_until_business_proof',
1883
- 'blocked_until_business_proof_artifact',
1884
- 'blocked_until_human_approval',
1885
- 'internal_blocked'
1886
- ];
1887
- var status = cleanText(source.status, 120);
1888
- var normalized = {
1889
- contractId: cleanText(source.contractId || source.contract_id, 180),
1890
- status: validStatuses.includes(status) ? status : 'internal_blocked',
1891
- policyAction: cleanText(source.policyAction || source.policy_action, 120),
1892
- reviewType: cleanText(source.reviewType || source.review_type, 120),
1893
- primaryCommand: cleanText(source.primaryCommand || source.primary_command, 180),
1894
- canDraftCustomerReply: source.canDraftCustomerReply === true || source.can_draft_customer_reply === true,
1895
- canSendCustomerReply: source.canSendCustomerReply === true || source.can_send_customer_reply === true,
1896
- requiresHumanApproval: source.requiresHumanApproval !== false && source.requires_human_approval !== false,
1897
- proofBacked: source.proofBacked === true || source.proof_backed === true,
1898
- businessProofReady: source.businessProofReady === true || source.business_proof_ready === true,
1899
- releaseReady: source.releaseReady === true || source.release_ready === true,
1900
- diagnosisReady: source.diagnosisReady === true || source.diagnosis_ready === true,
1901
- issueClassProbePlanReady: source.issueClassProbePlanReady === true || source.issue_class_probe_plan_ready === true,
1902
- clarificationRequired: source.clarificationRequired === true || source.clarification_required === true,
1903
- reason: cleanText(source.reason, 500),
1904
- blockers: cleanList(source.blockers, 24, 500),
1905
- requiredEvidence: cleanList(source.requiredEvidence || source.required_evidence, 30, 500),
1906
- evidenceRefs: cleanList(source.evidenceRefs || source.evidence_refs, 40, 500),
1907
- nextCommands: cleanList(source.nextCommands || source.next_commands, 24, 200),
1908
- forbiddenActions: cleanList(source.forbiddenActions || source.forbidden_actions, 24, 500),
1909
- createdAt: cleanText(source.createdAt || source.created_at, 120)
1910
- };
1911
- var blockers = [
1912
- normalized.contractId ? '' : 'Customer reply readiness contract is missing contractId.',
1913
- validStatuses.includes(status) ? '' : 'Customer reply readiness contract has an invalid status.',
1914
- normalized.policyAction ? '' : 'Customer reply readiness contract is missing policyAction.',
1915
- normalized.primaryCommand ? '' : 'Customer reply readiness contract is missing primaryCommand.',
1916
- normalized.requiresHumanApproval ? '' : 'Customer reply readiness must require human approval.',
1917
- normalized.canSendCustomerReply === false ? '' : 'Customer reply readiness must never allow automatic customer send.',
1918
- normalized.requiredEvidence.length ? '' : 'Customer reply readiness contract is missing requiredEvidence.',
1919
- normalized.forbiddenActions.length ? '' : 'Customer reply readiness contract is missing forbiddenActions.',
1920
- normalized.status === 'draft_ready' && !normalized.canDraftCustomerReply ? 'Draft-ready customer reply must allow draft creation.' : '',
1921
- normalized.status === 'draft_ready' && !normalized.proofBacked ? 'Draft-ready customer reply must be proof-backed.' : '',
1922
- normalized.status === 'draft_ready' && !normalized.businessProofReady ? 'Draft-ready customer reply requires businessProofReady=true.' : '',
1923
- normalized.status === 'draft_ready' && !normalized.releaseReady ? 'Draft-ready customer reply requires releaseReady=true.' : '',
1924
- normalized.status === 'draft_ready' && normalized.reviewType !== 'customer_resolution_reply' ? 'Draft-ready customer reply requires reviewType=customer_resolution_reply.' : '',
1925
- normalized.status === 'clarification_required' && !normalized.clarificationRequired ? 'Clarification readiness must set clarificationRequired=true.' : '',
1926
- normalized.status === 'clarification_required' && normalized.reviewType !== 'customer_clarification' ? 'Clarification readiness requires reviewType=customer_clarification.' : '',
1927
- normalized.status !== 'draft_ready' && normalized.status !== 'clarification_required' && normalized.canDraftCustomerReply ? 'Blocked customer reply readiness cannot allow draft creation.' : ''
1928
- ].filter(Boolean);
1929
- return {
1930
- valid: blockers.length === 0,
1931
- status: blockers.length ? 'blocked' : normalized.status,
1932
- blockers: blockers,
1933
- normalized: normalized
1934
- };
1935
- }
1936
- function supportAutonomousReviewTypeForAction(action) {
1937
- switch (action) {
1938
- case 'run_diagnosis_gate':
1939
- return 'diagnosis_gate';
1940
- case 'ask_customer_clarification':
1941
- return 'customer_clarification';
1942
- case 'run_owner_scoped_repair':
1943
- case 'revise_diagnosis_scope':
1944
- return 'owner_scoped_repair';
1945
- case 'run_business_proof_qa':
1946
- return 'business_proof_qa';
1947
- case 'repair_release_hotfix_first':
1948
- case 'ready_for_release_gate':
1949
- return 'release_hotfix';
1950
- case 'draft_customer_reply':
1951
- return 'customer_resolution_reply';
1952
- case 'collect_new_evidence':
1953
- return 'new_evidence';
1954
- case 'repair_infra_only':
1955
- case 'park_manual':
1956
- default:
1957
- return 'internal_hold';
1958
- }
1959
- }
1960
- function decideResolveIOSupportCustomerReplyPolicy(input) {
1961
- var _a, _b, _c;
1962
- if (input === void 0) { input = {}; }
1963
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.diagnosisGate);
1964
- var gate = diagnosisValidation.normalized;
1965
- var confidenceLevel = normalizeSupportConfidenceLevel(input.confidence);
1966
- var shouldBlockConfidence = ((_a = input.confidence) === null || _a === void 0 ? void 0 : _a.shouldBlockPr) === true
1967
- || ((_b = input.confidence) === null || _b === void 0 ? void 0 : _b.should_block_pr) === true
1968
- || ((_c = input.confidence) === null || _c === void 0 ? void 0 : _c.blocked) === true;
1969
- var businessProofReadiness = evaluateResolveIOSupportBusinessProofReadiness({
1970
- diagnosisGate: input.diagnosisGate,
1971
- outcomeLabel: input.outcomeLabel,
1972
- businessAssertionStatus: input.businessAssertionStatus,
1973
- businessAssertions: input.businessAssertions,
1974
- businessProofArtifacts: input.businessProofArtifacts,
1975
- previousProofFingerprint: input.previousProofFingerprint,
1976
- previousArtifactFingerprint: input.previousArtifactFingerprint
1977
- });
1978
- var artifactCount = businessProofReadiness.artifactPaths.length;
1979
- var unresolvedBlockers = cleanList(input.unresolvedBlockers, 20, 500);
1980
- var releaseGate = resolveSupportReplyReleaseGate(input);
1981
- var requiredEvidence = [
1982
- 'valid SupportDiagnosisGate',
1983
- 'validated IssueClassProbePlan',
1984
- 'high confidence with shouldBlockPr=false',
1985
- 'accepted outcome or passed business assertion',
1986
- 'business proof contract and artifact evidence',
1987
- 'no unresolved blocker or release blocker'
1988
- ];
1989
- var withReadiness = function (policy, issueClassProbePlanValidation) {
1990
- var normalizedPolicy = policy;
1991
- return __assign(__assign({}, normalizedPolicy), { readinessContract: buildResolveIOSupportCustomerReplyReadinessContract({
1992
- policy: normalizedPolicy,
1993
- diagnosisValidation: diagnosisValidation,
1994
- issueClassProbePlanValidation: issueClassProbePlanValidation,
1995
- businessProofReadiness: businessProofReadiness,
1996
- releaseGate: releaseGate
1997
- }) });
1998
- };
1999
- if (!diagnosisValidation.valid) {
2000
- var canAskCustomer = (gate === null || gate === void 0 ? void 0 : gate.issue_case.reproduction_status) === 'blocked'
2001
- || diagnosisValidation.blockers.some(function (blocker) { return /expected_result|observed_result|account_customer_context/.test(blocker); });
2002
- if (canAskCustomer) {
2003
- var clarificationValidation = validateResolveIOSupportClarificationContract(buildResolveIOSupportClarificationContract(gate, diagnosisValidation.blockers));
2004
- var clarificationContract = clarificationValidation.normalized;
2005
- if (!clarificationValidation.valid) {
2006
- return withReadiness({
2007
- action: 'hold_internal',
2008
- canDraftCustomerReply: false,
2009
- canSendCustomerReply: false,
2010
- confidenceLevel: confidenceLevel,
2011
- safety: 'internal_hold',
2012
- reason: 'support_reply_clarification_contract_invalid',
2013
- requiredEvidence: requiredEvidence,
2014
- clarificationContract: clarificationContract,
2015
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2016
- reviewType: 'internal_hold',
2017
- title: 'Repair Clarification Contract',
2018
- summary: 'Customer clarification is blocked until the one-question clarification contract validates.',
2019
- primaryAction: 'repair_support_clarification_contract',
2020
- safety: 'internal_hold',
2021
- reason: 'support_reply_clarification_contract_invalid',
2022
- blockers: clarificationValidation.blockers,
2023
- requiredEvidence: requiredEvidence,
2024
- nextCommands: ['repair_clarification_contract', 'rerun_reply_policy'],
2025
- forbiddenActions: ['Do not send a malformed or multi-question clarification.'],
2026
- costRisk: 'free_or_deterministic'
2027
- })
2028
- });
2029
- }
2030
- return withReadiness({
2031
- action: 'ask_clarification',
2032
- canDraftCustomerReply: true,
2033
- canSendCustomerReply: false,
2034
- confidenceLevel: confidenceLevel,
2035
- safety: 'needs_clarification',
2036
- reason: 'support_reply_waiting_on_customer_reproduction_detail',
2037
- requiredEvidence: Array.from(new Set(__spreadArray(__spreadArray([], __read(requiredEvidence), false), __read(clarificationContract.requiredEvidence), false))),
2038
- clarificationQuestion: clarificationContract.question,
2039
- clarificationContract: clarificationContract,
2040
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2041
- reviewType: 'customer_clarification',
2042
- title: 'Review Customer Clarification',
2043
- summary: 'The runner needs one customer detail before it can reproduce or continue safely.',
2044
- primaryAction: 'review_customer_clarification',
2045
- question: clarificationContract.question,
2046
- customerFacingDraftAllowed: clarificationContract.customerFacingDraftAllowed,
2047
- safety: 'needs_clarification',
2048
- reason: 'support_reply_waiting_on_customer_reproduction_detail',
2049
- blockers: clarificationContract.sourceBlockers,
2050
- requiredEvidence: clarificationContract.requiredEvidence,
2051
- nextCommands: clarificationContract.nextCommands,
2052
- forbiddenActions: clarificationContract.forbiddenActions,
2053
- costRisk: 'release_or_customer_send'
2054
- })
2055
- });
2056
- }
2057
- return withReadiness({
2058
- action: 'hold_internal',
2059
- canDraftCustomerReply: false,
2060
- canSendCustomerReply: false,
2061
- confidenceLevel: confidenceLevel,
2062
- safety: 'internal_hold',
2063
- reason: 'support_reply_blocked_until_diagnosis_gate_validates',
2064
- requiredEvidence: requiredEvidence,
2065
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2066
- reviewType: 'internal_hold',
2067
- title: 'Complete Diagnosis Gate',
2068
- summary: 'Customer reply is blocked until the diagnosis gate validates.',
2069
- primaryAction: 'run_support_v5_read_only_diagnosis_gate',
2070
- safety: 'internal_hold',
2071
- reason: 'support_reply_blocked_until_diagnosis_gate_validates',
2072
- blockers: diagnosisValidation.blockers,
2073
- requiredEvidence: requiredEvidence,
2074
- nextCommands: ['retrieve_similar_tickets_and_commits', 'run_reproduction_or_classification_probe', 'write_support_diagnosis_gate_json'],
2075
- forbiddenActions: ['Do not draft a resolution reply before root-cause diagnosis validates.'],
2076
- costRisk: 'expensive_model'
2077
- })
2078
- });
2079
- }
2080
- var explicitProbePlan = cleanObject(input.issueClassProbePlan);
2081
- var generatedProbePlan = gate
2082
- ? buildResolveIOSupportIssueClassProbePlan(gate)
2083
- : undefined;
2084
- var issueClassProbePlanValidation = validateResolveIOSupportIssueClassProbePlan(Object.keys(explicitProbePlan).length ? explicitProbePlan : generatedProbePlan, gate);
2085
- var issueClassProbePlan = issueClassProbePlanValidation.normalized || generatedProbePlan;
2086
- if (!issueClassProbePlanValidation.valid) {
2087
- return withReadiness({
2088
- action: 'hold_internal',
2089
- canDraftCustomerReply: false,
2090
- canSendCustomerReply: false,
2091
- confidenceLevel: confidenceLevel,
2092
- safety: 'internal_hold',
2093
- reason: 'support_reply_requires_valid_issue_class_probe_plan',
2094
- requiredEvidence: requiredEvidence,
2095
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2096
- reviewType: 'business_proof_qa',
2097
- title: 'Repair Issue-Class Probe Plan',
2098
- summary: 'Customer reply is blocked until the IssueClassProbePlan validates against the diagnosis proof plan.',
2099
- primaryAction: 'repair_support_issue_class_probe_plan',
2100
- safety: 'internal_hold',
2101
- reason: 'support_reply_requires_valid_issue_class_probe_plan',
2102
- blockers: issueClassProbePlanValidation.blockers,
2103
- requiredEvidence: requiredEvidence,
2104
- evidenceRefs: (issueClassProbePlan === null || issueClassProbePlan === void 0 ? void 0 : issueClassProbePlan.requiredArtifacts) || [],
2105
- nextCommands: ['repair_issue_class_probe_plan', 'rerun_business_proof_qa', 'rerun_reply_policy'],
2106
- forbiddenActions: ['Do not draft a customer resolution from business proof that is not mapped to a validated IssueClassProbePlan.'],
2107
- costRisk: 'free_or_deterministic'
2108
- })
2109
- }, issueClassProbePlanValidation);
2110
- }
2111
- if (shouldBlockConfidence || confidenceLevel !== 'high') {
2112
- return withReadiness({
2113
- action: 'hold_internal',
2114
- canDraftCustomerReply: false,
2115
- canSendCustomerReply: false,
2116
- confidenceLevel: confidenceLevel,
2117
- safety: 'internal_hold',
2118
- reason: shouldBlockConfidence ? 'support_reply_blocked_by_confidence_gate' : 'support_reply_requires_high_confidence',
2119
- requiredEvidence: requiredEvidence,
2120
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2121
- reviewType: 'internal_hold',
2122
- title: 'Review Confidence Gate',
2123
- summary: 'Customer reply is blocked until confidence is high and the confidence gate is not blocking.',
2124
- primaryAction: 'review_support_confidence_evidence',
2125
- safety: 'internal_hold',
2126
- reason: shouldBlockConfidence ? 'support_reply_blocked_by_confidence_gate' : 'support_reply_requires_high_confidence',
2127
- requiredEvidence: requiredEvidence,
2128
- nextCommands: ['inspect_confidence_basis', 'collect_missing_business_or_release_evidence'],
2129
- forbiddenActions: ['Do not draft a customer resolution from medium or low confidence.'],
2130
- costRisk: 'free_or_deterministic'
2131
- })
2132
- }, issueClassProbePlanValidation);
2133
- }
2134
- if (unresolvedBlockers.length) {
2135
- return withReadiness({
2136
- action: 'hold_internal',
2137
- canDraftCustomerReply: false,
2138
- canSendCustomerReply: false,
2139
- confidenceLevel: confidenceLevel,
2140
- safety: 'internal_hold',
2141
- reason: 'support_reply_blocked_by_unresolved_runner_blocker',
2142
- requiredEvidence: requiredEvidence,
2143
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2144
- reviewType: 'internal_hold',
2145
- title: 'Resolve Runner Blocker',
2146
- summary: 'Customer reply is blocked by unresolved runner blockers.',
2147
- primaryAction: 'review_support_runner_blocker',
2148
- safety: 'internal_hold',
2149
- reason: 'support_reply_blocked_by_unresolved_runner_blocker',
2150
- blockers: unresolvedBlockers,
2151
- requiredEvidence: requiredEvidence,
2152
- nextCommands: ['classify_blocker', 'collect_new_evidence_or_repair_smallest_gate'],
2153
- forbiddenActions: ['Do not send customer status as resolved while blockers remain.'],
2154
- costRisk: 'small_model_or_qa'
2155
- })
2156
- }, issueClassProbePlanValidation);
2157
- }
2158
- if (releaseGate.blocked) {
2159
- var releaseRequiredEvidence = Array.from(new Set(__spreadArray(__spreadArray([], __read(requiredEvidence), false), __read(releaseGate.requiredEvidence), false)));
2160
- return withReadiness({
2161
- action: 'hold_internal',
2162
- canDraftCustomerReply: false,
2163
- canSendCustomerReply: false,
2164
- confidenceLevel: confidenceLevel,
2165
- safety: 'internal_hold',
2166
- reason: 'support_reply_blocked_until_release_or_hotfix_gate_finishes',
2167
- requiredEvidence: releaseRequiredEvidence,
2168
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2169
- reviewType: 'release_hotfix',
2170
- title: 'Finish Release Or Hotfix Gate',
2171
- summary: 'Business proof exists, but the customer reply is blocked until release or hotfix evidence is complete.',
2172
- primaryAction: 'repair_release_hotfix_first',
2173
- safety: 'internal_hold',
2174
- reason: 'support_reply_blocked_until_release_or_hotfix_gate_finishes',
2175
- blockers: releaseGate.blockers,
2176
- requiredEvidence: releaseRequiredEvidence,
2177
- nextCommands: releaseGate.nextCommands,
2178
- forbiddenActions: ['Do not tell the customer the fix is live before release evidence passes.'],
2179
- costRisk: 'release_or_customer_send'
2180
- })
2181
- }, issueClassProbePlanValidation);
2182
- }
2183
- if (!businessProofReadiness.ready) {
2184
- var replyReason = businessProofReadiness.reason === 'support_business_proof_route_only_or_acceptance_blocked'
2185
- ? 'support_reply_rejects_route_only_business_proof'
2186
- : 'support_reply_requires_business_assertion_pass';
2187
- var proofRequiredEvidence = Array.from(new Set(__spreadArray(__spreadArray([], __read(requiredEvidence), false), __read(businessProofReadiness.requiredEvidence), false)));
2188
- return withReadiness({
2189
- action: 'hold_internal',
2190
- canDraftCustomerReply: false,
2191
- canSendCustomerReply: false,
2192
- confidenceLevel: confidenceLevel,
2193
- safety: 'internal_hold',
2194
- reason: replyReason,
2195
- requiredEvidence: proofRequiredEvidence,
2196
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2197
- reviewType: 'business_proof_qa',
2198
- title: 'Run Business Proof QA',
2199
- summary: 'Customer reply is blocked until the issue-specific before/action/after assertion passes.',
2200
- primaryAction: 'run_support_v5_business_proof_qa_row',
2201
- safety: 'internal_hold',
2202
- reason: replyReason,
2203
- blockers: businessProofReadiness.blockers,
2204
- requiredEvidence: proofRequiredEvidence,
2205
- evidenceRefs: businessProofReadiness.artifactPaths,
2206
- nextCommands: ['execute_issue_class_probe', 'record_before_action_after_artifacts', 'write_aiqa_business_assertion'],
2207
- forbiddenActions: ['Route probe pass remains route evidence only.'],
2208
- costRisk: 'small_model_or_qa'
2209
- })
2210
- }, issueClassProbePlanValidation);
2211
- }
2212
- if (!(gate === null || gate === void 0 ? void 0 : gate.proof_plan.business_proof_contract) || artifactCount < 1) {
2213
- return withReadiness({
2214
- action: 'hold_internal',
2215
- canDraftCustomerReply: false,
2216
- canSendCustomerReply: false,
2217
- confidenceLevel: confidenceLevel,
2218
- safety: 'internal_hold',
2219
- reason: 'support_reply_requires_business_proof_contract_artifact',
2220
- requiredEvidence: requiredEvidence,
2221
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2222
- reviewType: 'business_proof_qa',
2223
- title: 'Attach Business Proof Artifact',
2224
- summary: 'Customer reply is blocked until the business proof contract and artifact are attached.',
2225
- primaryAction: 'record_business_proof_artifact',
2226
- safety: 'internal_hold',
2227
- reason: 'support_reply_requires_business_proof_contract_artifact',
2228
- requiredEvidence: requiredEvidence,
2229
- evidenceRefs: businessProofReadiness.artifactPaths,
2230
- nextCommands: ['attach_business_proof_contract', 'attach_artifact_path', 'rerun_reply_policy'],
2231
- forbiddenActions: ['Do not draft a resolution reply without a proof artifact.'],
2232
- costRisk: 'free_or_deterministic'
2233
- })
2234
- }, issueClassProbePlanValidation);
2235
- }
2236
- return withReadiness({
2237
- action: 'draft_resolution_reply',
2238
- canDraftCustomerReply: true,
2239
- canSendCustomerReply: false,
2240
- confidenceLevel: confidenceLevel,
2241
- safety: 'safe_to_draft',
2242
- reason: 'support_reply_resolution_draft_allowed_after_business_proof',
2243
- requiredEvidence: requiredEvidence,
2244
- humanReviewPacket: buildResolveIOSupportHumanReviewPacket({
2245
- reviewType: 'customer_resolution_reply',
2246
- title: 'Review Customer Resolution Reply',
2247
- summary: "Business proof is ready for ".concat(gate.issue_class, "; draft a customer-facing resolution for human review."),
2248
- primaryAction: 'review_customer_reply',
2249
- customerFacingDraftAllowed: true,
2250
- safety: 'safe_to_draft',
2251
- reason: 'support_reply_resolution_draft_allowed_after_business_proof',
2252
- requiredEvidence: requiredEvidence,
2253
- evidenceRefs: businessProofReadiness.artifactPaths,
2254
- nextCommands: ['summarize_business_proof', 'draft_customer_reply_for_human_review'],
2255
- forbiddenActions: ['Draft only; do not send automatically.'],
2256
- costRisk: 'release_or_customer_send'
2257
- }),
2258
- draftBasis: {
2259
- issueClass: gate.issue_class,
2260
- issueClassProbePlanId: issueClassProbePlan === null || issueClassProbePlan === void 0 ? void 0 : issueClassProbePlan.planId,
2261
- issueClassProbePlanStatus: issueClassProbePlanValidation.status,
2262
- businessProof: gate.proof_plan.business_proof_contract.expected_business_state_change,
2263
- artifactCount: artifactCount
2264
- }
2265
- }, issueClassProbePlanValidation);
2266
- }
2267
- function buildResolveIOSupportIssueClassProbes(value) {
2268
- var validation = validateResolveIOSupportDiagnosisGate(value);
2269
- var gate = validation.normalized || normalizeResolveIOSupportDiagnosisGate(value);
2270
- if (!gate) {
2271
- return [];
2272
- }
2273
- var route = gate.proof_plan.route || gate.issue_case.route_module;
2274
- var proofContract = gate.proof_plan.business_proof_contract;
2275
- var proof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || gate.proof_plan.business_assertion;
2276
- var assertion = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion) || gate.proof_plan.data_assertion || gate.proof_plan.after;
2277
- var contractArtifacts = cleanList(proofContract === null || proofContract === void 0 ? void 0 : proofContract.proof_artifacts, 8, 160);
2278
- var common = {
2279
- issue_class: gate.issue_class,
2280
- probe_type: 'issue_class_probe',
2281
- route: route,
2282
- state_transition: {
2283
- before: gate.proof_plan.before || gate.proof_plan.before_state_unavailable_reason || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.setup_state) || '',
2284
- action: gate.proof_plan.action || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test) || '',
2285
- after: gate.proof_plan.after || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || '',
2286
- assertion: assertion || gate.proof_plan.business_assertion || ''
2287
- },
2288
- acceptance_gate: 'aiqa_business_assertion',
2289
- blocks_acceptance_without_business_assertion: true
2290
- };
2291
- var map = {
2292
- no_op_submit: {
2293
- action: "Submit the customer action on ".concat(route || 'the affected screen', " and assert a persisted state change or explicit validation message."),
2294
- expected: proof || 'Before/action/after proof shows the submit is no longer a no-op.',
2295
- failureClass: 'business',
2296
- requiredArtifacts: ['before form state', 'submit action trace', 'post-submit DOM/data proof', 'method/network result']
2297
- },
2298
- missing_wrong_data: {
2299
- action: "Load the named record/list on ".concat(route || 'the affected route', " and compare visible data to the expected persisted source."),
2300
- expected: proof || 'Visible data and persisted data match the customer expectation.',
2301
- failureClass: 'business',
2302
- requiredArtifacts: ['expected source record', 'visible DOM/data snapshot', 'persisted data comparison']
2303
- },
2304
- filter_query_mismatch: {
2305
- action: 'Apply the reported filter/query inputs and assert the returned rows/counts match the expected dataset.',
2306
- expected: proof || 'Filter/query output contains the correct included rows and excludes the wrong rows.',
2307
- failureClass: 'business',
2308
- requiredArtifacts: ['filter input trace', 'included/excluded row proof', 'query or publication result proof']
2309
- },
2310
- invoice_pdf_export: {
2311
- action: 'Generate the invoice/PDF/export from the affected route and inspect the downloaded/generated artifact.',
2312
- expected: proof || 'Generated artifact contains the expected customer-visible rows, totals, or fields.',
2313
- failureClass: 'business',
2314
- requiredArtifacts: ['export trigger trace', 'generated file artifact path', 'parsed artifact content proof']
2315
- },
2316
- upload_import: {
2317
- action: 'Run the upload/import workflow with a representative file and assert parsed plus persisted results.',
2318
- expected: proof || 'Import shows a success result and persisted rows/counts changed as expected.',
2319
- failureClass: 'business',
2320
- requiredArtifacts: ['input file fixture', 'import result message', 'persisted row/count delta']
2321
- },
2322
- route_auth_hydration: {
2323
- action: 'Open the route as the affected user and assert authenticated hydration reaches the functional screen, not a shell.',
2324
- expected: proof || 'Route hydrates with the required controls/data for the affected account.',
2325
- failureClass: 'route',
2326
- requiredArtifacts: ['auth context', 'hydrated DOM proof', 'console/network error log']
2327
- },
2328
- slow_query_performance: {
2329
- action: 'Run the reported query/workflow with timing/log evidence before and after the fix.',
2330
- expected: proof || 'Performance evidence shows the slow path improved without changing results.',
2331
- failureClass: 'business',
2332
- requiredArtifacts: ['before timing', 'after timing', 'result equivalence proof', 'query/log trace']
2333
- }
2334
- };
2335
- var selected = map[gate.issue_class];
2336
- var catalog = SUPPORT_ISSUE_CLASS_PROBE_CATALOG.find(function (entry) { return entry.issue_class === gate.issue_class; });
2337
- var requiredArtifacts = Array.from(new Set(__spreadArray(__spreadArray([], __read(contractArtifacts), false), __read(selected.requiredArtifacts), false)));
2338
- return [__assign(__assign({}, common), { failure_class: selected.failureClass, objective: "Issue-class probe for ".concat(gate.issue_class, ": ").concat(gate.issue_case.customer_complaint), action: proofContract
2339
- ? "".concat(proofContract.action_under_test, " ").concat(selected.action)
2340
- : selected.action, expected_evidence: "".concat(selected.expected).concat(assertion ? " Assertion: ".concat(assertion, ".") : '').concat(requiredArtifacts.length ? " Required artifacts: ".concat(requiredArtifacts.join(', '), ".") : '').trim(), expected_business_proof: proof || gate.proof_plan.business_assertion, required_artifacts: requiredArtifacts, false_pass_blockers: (catalog === null || catalog === void 0 ? void 0 : catalog.false_pass_blockers) || [
2341
- 'route loaded only',
2342
- 'screenshot without business state proof',
2343
- 'model claim without DOM/data proof'
2344
- ] })];
2345
- }
2346
- function normalizeResolveIOSupportIssueClassProbe(value, diagnosisGate) {
2347
- var source = cleanObject(value);
2348
- if (!Object.keys(source).length) {
2349
- return undefined;
2350
- }
2351
- var issueClass = normalizeIssueClass(source.issue_class || source.issueClass || (diagnosisGate === null || diagnosisGate === void 0 ? void 0 : diagnosisGate.issue_class));
2352
- var stateTransition = cleanObject(source.state_transition || source.stateTransition);
2353
- var route = cleanText(source.route, 500);
2354
- var failureClass = cleanText(source.failure_class || source.failureClass || 'business', 80);
2355
- return {
2356
- issue_class: (issueClass || (diagnosisGate === null || diagnosisGate === void 0 ? void 0 : diagnosisGate.issue_class) || 'missing_wrong_data'),
2357
- probe_type: (cleanText(source.probe_type || source.probeType, 80) || 'issue_class_probe'),
2358
- failure_class: failureClass,
2359
- objective: cleanText(source.objective, 1000),
2360
- route: route,
2361
- action: cleanText(source.action, 1200),
2362
- expected_evidence: cleanText(source.expected_evidence || source.expectedEvidence, 1600),
2363
- expected_business_proof: cleanText(source.expected_business_proof || source.expectedBusinessProof, 1600),
2364
- required_artifacts: cleanList(source.required_artifacts || source.requiredArtifacts, 12, 220),
2365
- state_transition: {
2366
- before: cleanText(stateTransition.before, 800),
2367
- action: cleanText(stateTransition.action, 800),
2368
- after: cleanText(stateTransition.after, 800),
2369
- assertion: cleanText(stateTransition.assertion, 1000)
2370
- },
2371
- acceptance_gate: cleanText(source.acceptance_gate || source.acceptanceGate, 120) === 'aiqa_business_assertion'
2372
- ? 'aiqa_business_assertion'
2373
- : 'aiqa_business_assertion',
2374
- blocks_acceptance_without_business_assertion: source.blocks_acceptance_without_business_assertion !== false
2375
- && source.blocksAcceptanceWithoutBusinessAssertion !== false,
2376
- false_pass_blockers: cleanList(source.false_pass_blockers || source.falsePassBlockers, 8, 260)
2377
- };
2378
- }
2379
- function validateResolveIOSupportIssueClassProbePlan(value, diagnosisGate, now) {
2380
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(diagnosisGate);
2381
- var normalizedDiagnosis = diagnosisValidation.normalized;
2382
- var source = cleanObject(value);
2383
- var rawProbes = Array.isArray(value)
2384
- ? value
2385
- : Array.isArray(source.probes)
2386
- ? source.probes
2387
- : Array.isArray(source.issueClassProbes)
2388
- ? source.issueClassProbes
2389
- : Array.isArray(source.issue_class_probes)
2390
- ? source.issue_class_probes
2391
- : source.activeProbe || source.active_probe
2392
- ? [source.activeProbe || source.active_probe]
2393
- : [];
2394
- var probes = rawProbes
2395
- .map(function (probe) { return normalizeResolveIOSupportIssueClassProbe(probe, normalizedDiagnosis); })
2396
- .filter(function (probe) { return !!probe; });
2397
- var activeProbe = probes[0] || normalizeResolveIOSupportIssueClassProbe(source.activeProbe || source.active_probe, normalizedDiagnosis);
2398
- var issueClass = normalizeIssueClass(source.issue_class || source.issueClass || (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.issue_class) || (normalizedDiagnosis === null || normalizedDiagnosis === void 0 ? void 0 : normalizedDiagnosis.issue_class));
2399
- var catalog = SUPPORT_ISSUE_CLASS_PROBE_CATALOG.find(function (entry) { return entry.issue_class === issueClass; });
2400
- var planRequiredArtifacts = cleanList(source.requiredArtifacts || source.required_artifacts, 16, 220);
2401
- var activeRequiredArtifacts = cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.required_artifacts, 16, 220);
2402
- var requiredArtifacts = planRequiredArtifacts.length ? planRequiredArtifacts : activeRequiredArtifacts;
2403
- var falsePassBlockers = cleanList(source.falsePassBlockers || source.false_pass_blockers, 12, 260).length
2404
- ? cleanList(source.falsePassBlockers || source.false_pass_blockers, 12, 260)
2405
- : cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.false_pass_blockers, 12, 260).length
2406
- ? cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.false_pass_blockers, 12, 260)
2407
- : ((catalog === null || catalog === void 0 ? void 0 : catalog.false_pass_blockers) || []);
2408
- var blockers = [];
2409
- if (!diagnosisValidation.valid || !normalizedDiagnosis) {
2410
- blockers.push('Valid SupportDiagnosisGate is required before issue-class probe QA.');
2411
- }
2412
- if (!probes.length || !activeProbe) {
2413
- blockers.push('Issue-class probe plan must include at least one active probe.');
2414
- }
2415
- if (!issueClass) {
2416
- blockers.push('Issue-class probe plan must record a valid issue_class.');
2417
- }
2418
- if (normalizedDiagnosis && issueClass && issueClass !== normalizedDiagnosis.issue_class) {
2419
- blockers.push("Issue-class probe plan issue_class ".concat(issueClass, " does not match diagnosis issue_class ").concat(normalizedDiagnosis.issue_class, "."));
2420
- }
2421
- if (activeProbe) {
2422
- if (!cleanText(activeProbe.route, 500)) {
2423
- blockers.push('Issue-class probe must include the exact route or module under test.');
2424
- }
2425
- if (!cleanText(activeProbe.action, 1200)) {
2426
- blockers.push('Issue-class probe must include the exact action to perform.');
2427
- }
2428
- if (!cleanText(activeProbe.expected_evidence, 1600)) {
2429
- blockers.push('Issue-class probe must include expected evidence.');
2430
- }
2431
- if (!cleanText(activeProbe.expected_business_proof, 1600)) {
2432
- blockers.push('Issue-class probe must include expected business proof.');
2433
- }
2434
- if (!cleanText(activeProbe.state_transition.before, 800)) {
2435
- blockers.push('Issue-class probe state_transition.before is required.');
2436
- }
2437
- if (!cleanText(activeProbe.state_transition.action, 800)) {
2438
- blockers.push('Issue-class probe state_transition.action is required.');
2439
- }
2440
- if (!cleanText(activeProbe.state_transition.after, 800)) {
2441
- blockers.push('Issue-class probe state_transition.after is required.');
2442
- }
2443
- if (!cleanText(activeProbe.state_transition.assertion, 1000)) {
2444
- blockers.push('Issue-class probe state_transition.assertion is required.');
2445
- }
2446
- if (activeProbe.acceptance_gate !== 'aiqa_business_assertion') {
2447
- blockers.push('Issue-class probe acceptance_gate must be aiqa_business_assertion.');
2448
- }
2449
- if (activeProbe.blocks_acceptance_without_business_assertion !== true) {
2450
- blockers.push('Issue-class probe must block acceptance without AIQaBusinessAssertion.');
2451
- }
2452
- if (activeRequiredArtifacts.length < 2) {
2453
- blockers.push('Active issue-class probe must require at least two proof artifacts.');
2454
- }
2455
- }
2456
- if (requiredArtifacts.length < 2) {
2457
- blockers.push('Issue-class probe plan must require at least two proof artifacts.');
2458
- }
2459
- if (!falsePassBlockers.length) {
2460
- blockers.push('Issue-class probe plan must record false-pass blockers.');
2461
- }
2462
- var status = blockers.length
2463
- ? (probes.length ? 'incomplete' : 'missing')
2464
- : 'ready';
2465
- var generatedAt = cleanText(source.generatedAt || source.generated_at, 120) || isoNow(now);
2466
- var normalized = {
2467
- planId: cleanText(source.planId || source.plan_id, 160) || "support-probe-plan-".concat(hashResolveIOSupportV5Evidence({
2468
- issueClass: issueClass,
2469
- route: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.route,
2470
- action: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.action,
2471
- expectedBusinessProof: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_business_proof
2472
- }).slice(0, 16)),
2473
- status: status,
2474
- issue_class: issueClass || undefined,
2475
- diagnosisValid: diagnosisValidation.valid === true,
2476
- probes: probes,
2477
- activeProbe: activeProbe,
2478
- requiredArtifacts: requiredArtifacts,
2479
- acceptanceGate: 'aiqa_business_assertion',
2480
- falsePassBlockers: falsePassBlockers,
2481
- blockers: blockers,
2482
- generatedAt: generatedAt
2483
- };
2484
- return {
2485
- valid: blockers.length === 0,
2486
- status: status,
2487
- blockers: blockers,
2488
- normalized: normalized,
2489
- activeProbe: activeProbe
2490
- };
2491
- }
2492
- function buildResolveIOSupportIssueClassProbePlan(diagnosisGate, now) {
2493
- var _a, _b;
2494
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(diagnosisGate);
2495
- var probes = diagnosisValidation.valid && diagnosisValidation.normalized
2496
- ? buildResolveIOSupportIssueClassProbes(diagnosisValidation.normalized)
2497
- : [];
2498
- var activeProbe = probes[0];
2499
- var issueClass = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.issue_class) || (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.issue_class);
2500
- var catalog = SUPPORT_ISSUE_CLASS_PROBE_CATALOG.find(function (entry) { return entry.issue_class === issueClass; });
2501
- var provisional = {
2502
- planId: "support-probe-plan-".concat(hashResolveIOSupportV5Evidence({
2503
- issueClass: issueClass,
2504
- route: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.route,
2505
- action: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.action,
2506
- expectedBusinessProof: activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_business_proof
2507
- }).slice(0, 16)),
2508
- status: 'incomplete',
2509
- issue_class: issueClass,
2510
- diagnosisValid: diagnosisValidation.valid === true,
2511
- probes: probes,
2512
- activeProbe: activeProbe,
2513
- requiredArtifacts: cleanList(activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.required_artifacts, 16, 220),
2514
- acceptanceGate: 'aiqa_business_assertion',
2515
- falsePassBlockers: ((_b = activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.false_pass_blockers) === null || _b === void 0 ? void 0 : _b.length)
2516
- ? activeProbe.false_pass_blockers
2517
- : ((catalog === null || catalog === void 0 ? void 0 : catalog.false_pass_blockers) || []),
2518
- blockers: [],
2519
- generatedAt: isoNow(now)
2520
- };
2521
- var validation = validateResolveIOSupportIssueClassProbePlan(provisional, diagnosisValidation.normalized || diagnosisGate, now);
2522
- return validation.normalized || __assign(__assign({}, provisional), { status: validation.status, blockers: validation.blockers });
2523
- }
2524
- function hashResolveIOSupportV5Evidence(value) {
2525
- var raw = typeof value === 'string' ? value : JSON.stringify(value || {});
2526
- var normalized = cleanText(raw, 8000)
2527
- .toLowerCase()
2528
- .replace(/[a-f0-9]{16,}/g, '<id>')
2529
- .replace(/\b\d{2,}\b/g, '<n>');
2530
- var hash = 0;
2531
- for (var index = 0; index < normalized.length; index += 1) {
2532
- hash = ((hash << 5) - hash + normalized.charCodeAt(index)) | 0;
2533
- }
2534
- return "ev-".concat(Math.abs(hash).toString(36) || '0');
2535
- }
2536
- function decideResolveIOSupportV5RepeatedFailureStop(input) {
2537
- var failureClass = cleanText(input.failureClass || 'unknown', 80).toLowerCase();
2538
- var blockerFingerprint = fingerprintResolveIOSupportV5Blocker(input.blocker || '');
2539
- var evidenceHash = cleanText(input.evidenceHash, 80) || hashResolveIOSupportV5Evidence(input.evidence || input.blocker || '');
2540
- var limit = Math.max(1, Number(input.limit || 2) || 2);
2541
- if (input.ignoreInfra !== false && /^(infra|compile)$/.test(failureClass)) {
2542
- return {
2543
- shouldStop: false,
2544
- repeatedCount: 0,
2545
- failureClass: failureClass,
2546
- blockerFingerprint: blockerFingerprint,
2547
- evidenceHash: evidenceHash,
2548
- reason: 'support_v5_infra_failures_do_not_count_as_product_repair_loops'
2549
- };
2550
- }
2551
- var latestRecord = (input.history || [])[(input.history || []).length - 1];
2552
- var managerDecision = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerPolicy)({
2553
- history: (input.history || []).map(function (entry) { return ({
2554
- outcome: entry.outcome,
2555
- lane: entry.lane,
2556
- stepType: entry.stepType,
2557
- failureClass: entry.failureClass,
2558
- blocker: entry.blocker || entry.summary,
2559
- evidenceHash: entry.evidenceHash,
2560
- changedFiles: entry.changedFiles,
2561
- artifactPaths: entry.artifactPaths,
2562
- summary: entry.summary,
2563
- recordedAt: entry.recordedAt
2564
- }); }),
2565
- current: {
2566
- outcome: 'needs_repair',
2567
- lane: latestRecord === null || latestRecord === void 0 ? void 0 : latestRecord.lane,
2568
- stepType: latestRecord === null || latestRecord === void 0 ? void 0 : latestRecord.stepType,
2569
- failureClass: failureClass,
2570
- blocker: input.blocker,
2571
- evidenceHash: evidenceHash,
2572
- changedFiles: cleanList(input.changedFiles, 40, 500),
2573
- artifactPaths: cleanList(input.artifactPaths, 40, 500),
2574
- summary: input.blocker
2575
- },
2576
- maxSameFailureRepeats: limit,
2577
- maxPingPongTransitions: 3,
2578
- infraFailureClasses: input.ignoreInfra !== false ? ['infra', 'compile'] : []
2579
- });
2580
- if (managerDecision.action === 'retry_infra') {
2581
- return {
2582
- shouldStop: false,
2583
- repeatedCount: 0,
2584
- failureClass: failureClass,
2585
- blockerFingerprint: blockerFingerprint,
2586
- evidenceHash: evidenceHash,
2587
- reason: 'support_v5_infra_failures_do_not_count_as_product_repair_loops'
2588
- };
2589
- }
2590
- if (managerDecision.action === 'park_ping_pong') {
2591
- return {
2592
- shouldStop: true,
2593
- repeatedCount: managerDecision.pingPongCount,
2594
- failureClass: failureClass,
2595
- blockerFingerprint: blockerFingerprint,
2596
- evidenceHash: evidenceHash,
2597
- newEvidence: managerDecision.newEvidence,
2598
- materialEvidence: managerDecision.materialEvidence,
2599
- evidenceStrength: managerDecision.evidenceStrength,
2600
- evidenceSignals: managerDecision.evidenceSignals,
2601
- reason: 'support_v5_ping_pong_failure_loop'
2602
- };
2603
- }
2604
- if (managerDecision.action === 'park_repeated_failure' && managerDecision.newEvidence && !managerDecision.materialEvidence) {
2605
- return {
2606
- shouldStop: true,
2607
- repeatedCount: managerDecision.sameFailureCount,
2608
- failureClass: failureClass,
2609
- blockerFingerprint: blockerFingerprint,
2610
- evidenceHash: evidenceHash,
2611
- newEvidence: managerDecision.newEvidence,
2612
- materialEvidence: managerDecision.materialEvidence,
2613
- evidenceStrength: managerDecision.evidenceStrength,
2614
- evidenceSignals: managerDecision.evidenceSignals,
2615
- reason: 'support_v5_same_failure_with_weak_evidence'
2616
- };
2617
- }
2618
- if (managerDecision.newEvidence && managerDecision.materialEvidence) {
2619
- return {
2620
- shouldStop: false,
2621
- repeatedCount: managerDecision.sameFailureCount,
2622
- failureClass: failureClass,
2623
- blockerFingerprint: blockerFingerprint,
2624
- evidenceHash: evidenceHash,
2625
- newEvidence: managerDecision.newEvidence,
2626
- materialEvidence: managerDecision.materialEvidence,
2627
- evidenceStrength: managerDecision.evidenceStrength,
2628
- evidenceSignals: managerDecision.evidenceSignals,
2629
- reason: 'support_v5_retry_allowed_material_evidence'
2630
- };
2631
- }
2632
- if (managerDecision.action === 'park_repeated_failure') {
2633
- return {
2634
- shouldStop: true,
2635
- repeatedCount: managerDecision.sameFailureCount,
2636
- failureClass: failureClass,
2637
- blockerFingerprint: blockerFingerprint,
2638
- evidenceHash: evidenceHash,
2639
- newEvidence: managerDecision.newEvidence,
2640
- materialEvidence: managerDecision.materialEvidence,
2641
- evidenceStrength: managerDecision.evidenceStrength,
2642
- evidenceSignals: managerDecision.evidenceSignals,
2643
- reason: 'support_v5_same_failure_class_without_new_evidence'
2644
- };
2645
- }
2646
- var repeatedCount = 0;
2647
- for (var index = (input.history || []).length - 1; index >= 0; index -= 1) {
2648
- var item = input.history[index];
2649
- if (item.outcome === 'pass' || item.outcome === 'ready_for_merge') {
2650
- break;
2651
- }
2652
- var itemFailureClass = cleanText(item.failureClass || 'unknown', 80).toLowerCase();
2653
- var itemBlockerFingerprint = cleanText(item.blockerFingerprint, 80)
2654
- || fingerprintResolveIOSupportV5Blocker(item.blocker || item.summary || '');
2655
- var itemEvidenceHash = cleanText(item.evidenceHash, 80)
2656
- || hashResolveIOSupportV5Evidence(item.artifactPaths || item.blocker || item.summary || '');
2657
- if (itemFailureClass !== failureClass || itemBlockerFingerprint !== blockerFingerprint || itemEvidenceHash !== evidenceHash) {
2658
- break;
2659
- }
2660
- repeatedCount += 1;
2661
- }
2662
- return {
2663
- shouldStop: repeatedCount >= limit,
2664
- repeatedCount: repeatedCount,
2665
- failureClass: failureClass,
2666
- blockerFingerprint: blockerFingerprint,
2667
- evidenceHash: evidenceHash,
2668
- newEvidence: managerDecision.newEvidence,
2669
- materialEvidence: managerDecision.materialEvidence,
2670
- evidenceStrength: managerDecision.evidenceStrength,
2671
- evidenceSignals: managerDecision.evidenceSignals,
2672
- reason: repeatedCount >= limit
2673
- ? 'support_v5_same_failure_class_without_new_evidence'
2674
- : 'support_v5_retry_allowed_new_or_below_repeat_limit'
2675
- };
2676
- }
2677
- function evaluateResolveIOSupportEvidenceFreshness(input) {
2678
- var _a;
2679
- var history = Array.isArray(input.history) ? input.history : [];
2680
- var latest = history.length ? history[history.length - 1] : undefined;
2681
- var rawFailureClass = cleanText(input.failureClass || (latest === null || latest === void 0 ? void 0 : latest.failureClass), 80).toLowerCase();
2682
- var failureClass = rawFailureClass || 'unknown';
2683
- var blocker = cleanText(input.blocker || (latest === null || latest === void 0 ? void 0 : latest.blocker) || (latest === null || latest === void 0 ? void 0 : latest.summary), 1200);
2684
- var changedFiles = cleanList(input.changedFiles || (latest === null || latest === void 0 ? void 0 : latest.changedFiles), 40, 500);
2685
- var artifactPaths = cleanList(input.artifactPaths || (latest === null || latest === void 0 ? void 0 : latest.artifactPaths), 40, 500);
2686
- var explicitEvidenceHash = cleanText(input.evidenceHash || (latest === null || latest === void 0 ? void 0 : latest.evidenceHash), 120);
2687
- var evidenceHash = explicitEvidenceHash || hashResolveIOSupportV5Evidence(input.evidence || artifactPaths || blocker || (latest === null || latest === void 0 ? void 0 : latest.summary) || '');
2688
- var blockerFingerprint = fingerprintResolveIOSupportV5Blocker(blocker || (latest === null || latest === void 0 ? void 0 : latest.summary) || '');
2689
- var missing = !history.length && !rawFailureClass && !blocker && !explicitEvidenceHash && !artifactPaths.length && !changedFiles.length;
2690
- if (missing) {
2691
- return {
2692
- status: 'missing',
2693
- failureClass: '',
2694
- blockerFingerprint: '',
2695
- evidenceHash: '',
2696
- sameFailureCount: 0,
2697
- pingPongCount: 0,
2698
- newEvidence: false,
2699
- materialEvidence: false,
2700
- evidenceStrength: 'none',
2701
- evidenceSignals: [],
2702
- loopBudgetShouldReset: false,
2703
- canRetry: true,
2704
- mustCollectNewEvidence: false,
2705
- productRepairFailure: false,
2706
- reason: 'support_evidence_freshness_waiting_for_first_failure_or_proof',
2707
- requiredResetEvidence: [
2708
- 'current blocker fingerprint',
2709
- 'evidence hash',
2710
- 'artifact path when available'
2711
- ],
2712
- changedFiles: changedFiles,
2713
- artifactPaths: artifactPaths
2714
- };
2715
- }
2716
- var current = {
2717
- outcome: 'needs_repair',
2718
- lane: cleanText(input.lane || (latest === null || latest === void 0 ? void 0 : latest.lane), 80) || (latest === null || latest === void 0 ? void 0 : latest.lane),
2719
- stepType: cleanText(input.stepType || (latest === null || latest === void 0 ? void 0 : latest.stepType), 80) || (latest === null || latest === void 0 ? void 0 : latest.stepType),
2720
- failureClass: failureClass,
2721
- blocker: blocker,
2722
- evidenceHash: evidenceHash,
2723
- changedFiles: changedFiles,
2724
- artifactPaths: artifactPaths,
2725
- summary: blocker
2726
- };
2727
- var policy = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerPolicy)({
2728
- history: history.map(function (entry) { return ({
2729
- outcome: entry.outcome,
2730
- lane: entry.lane,
2731
- stepType: entry.stepType,
2732
- failureClass: entry.failureClass,
2733
- blocker: entry.blocker || entry.summary,
2734
- evidenceHash: entry.evidenceHash,
2735
- changedFiles: entry.changedFiles,
2736
- artifactPaths: entry.artifactPaths,
2737
- summary: entry.summary,
2738
- recordedAt: entry.recordedAt
2739
- }); }),
2740
- current: current,
2741
- maxSameFailureRepeats: Math.max(1, Number(input.limit || 2) || 2),
2742
- maxPingPongTransitions: 3,
2743
- infraFailureClasses: input.ignoreInfra !== false ? ['infra', 'compile'] : []
2744
- });
2745
- var status = 'retry_below_limit';
2746
- if (policy.action === 'retry_infra') {
2747
- status = 'infra_ignored';
2748
- }
2749
- else if (policy.action === 'park_ping_pong') {
2750
- status = 'ping_pong';
2751
- }
2752
- else if (policy.action === 'park_repeated_failure') {
2753
- status = policy.newEvidence ? 'weak_evidence' : 'stale_repeated';
2754
- }
2755
- else if (policy.newEvidence && policy.materialEvidence) {
2756
- status = 'material_evidence';
2757
- }
2758
- else if (policy.newEvidence && !policy.materialEvidence) {
2759
- status = 'weak_evidence';
2760
- }
2761
- else if (policy.loopBudgetShouldReset || policy.reason === 'manager_policy_new_failure_or_lane') {
2762
- status = 'fresh';
2763
- }
2764
- var mustCollectNewEvidence = policy.action === 'park_repeated_failure'
2765
- || policy.action === 'park_ping_pong';
2766
- return {
2767
- status: status,
2768
- failureClass: policy.failureClass,
2769
- blockerFingerprint: blockerFingerprint || policy.blockerFingerprint,
2770
- evidenceHash: policy.evidenceHash,
2771
- sameFailureCount: policy.sameFailureCount,
2772
- pingPongCount: policy.pingPongCount,
2773
- newEvidence: policy.newEvidence,
2774
- materialEvidence: policy.materialEvidence,
2775
- evidenceStrength: policy.evidenceStrength,
2776
- evidenceSignals: policy.evidenceSignals,
2777
- loopBudgetShouldReset: policy.loopBudgetShouldReset,
2778
- canRetry: !mustCollectNewEvidence,
2779
- mustCollectNewEvidence: mustCollectNewEvidence,
2780
- productRepairFailure: policy.productRepairFailure,
2781
- reason: policy.reason,
2782
- requiredResetEvidence: Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(policy.recoveryPlan.loopResetEvidence, 12, 500)), false), __read(cleanList((_a = policy.recoveryAction) === null || _a === void 0 ? void 0 : _a.successCriteria, 12, 500)), false))).slice(0, 18),
2783
- changedFiles: changedFiles,
2784
- artifactPaths: artifactPaths
2785
- };
2786
- }
2787
- function buildResolveIOSupportContinuationProofCheckpoint(input) {
2788
- var evidenceFreshness = input.evidenceFreshness;
2789
- var action = input.action;
2790
- var requiredEvidence = cleanList(input.requiredEvidence, 20, 500);
2791
- var requiredResetEvidence = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(input.requiredResetEvidence, 20, 500)), false), __read(cleanList(evidenceFreshness === null || evidenceFreshness === void 0 ? void 0 : evidenceFreshness.requiredResetEvidence, 20, 500)), false), __read((action === 'run_diagnosis_gate'
2792
- ? [
2793
- 'accepted SupportDiagnosisGate with reproduced/blocked issue case',
2794
- 'bounded owner_files and before/action/after proof_plan'
2795
- ]
2796
- : [])), false), __read((action === 'collect_new_evidence'
2797
- ? [
2798
- 'fresh issue-class probe artifact',
2799
- 'changed blockerFingerprint or evidenceHash',
2800
- 'AIQaBusinessAssertion or before/action/after blocker artifact'
2801
- ]
2802
- : [])), false), __read((action === 'repair_infra_only'
2803
- ? [
2804
- 'infra or compile gate passes, or failureClass changes',
2805
- 'new evidenceHash from fresh preflight/build artifact'
2806
- ]
2807
- : [])), false), __read((action === 'repair_release_hotfix_first'
2808
- ? [
2809
- 'GitHub commit proof recorded before live backend hotfix',
2810
- 'release gate or hotfix durability evidence refreshed'
2811
- ]
2812
- : [])), false))).slice(0, 20);
2813
- var blocksProductRepair = input.blocksProductRepair === true
2814
- || action === 'collect_new_evidence'
2815
- || action === 'run_diagnosis_gate'
2816
- || action === 'ask_customer_clarification'
2817
- || action === 'repair_infra_only'
2818
- || action === 'revise_diagnosis_scope';
2819
- var waitingForNewEvidence = (evidenceFreshness === null || evidenceFreshness === void 0 ? void 0 : evidenceFreshness.mustCollectNewEvidence) === true
2820
- || action === 'collect_new_evidence';
2821
- var proofRequired = requiredEvidence.length > 0 || requiredResetEvidence.length > 0;
2822
- var status = waitingForNewEvidence
2823
- ? 'waiting_for_new_evidence'
2824
- : proofRequired
2825
- ? 'waiting_for_proof'
2826
- : 'waiting_for_state_transition';
2827
- return {
2828
- required: true,
2829
- status: status,
2830
- action: action,
2831
- reason: cleanText(input.reason || (evidenceFreshness === null || evidenceFreshness === void 0 ? void 0 : evidenceFreshness.reason) || '', 1000),
2832
- startingFailureClass: cleanText(evidenceFreshness === null || evidenceFreshness === void 0 ? void 0 : evidenceFreshness.failureClass, 120),
2833
- startingBlockerFingerprint: cleanText(evidenceFreshness === null || evidenceFreshness === void 0 ? void 0 : evidenceFreshness.blockerFingerprint, 160),
2834
- startingEvidenceHash: cleanText(evidenceFreshness === null || evidenceFreshness === void 0 ? void 0 : evidenceFreshness.evidenceHash, 160),
2835
- requiredEvidence: requiredEvidence,
2836
- requiredResetEvidence: requiredResetEvidence,
2837
- successRequiresNewEvidence: waitingForNewEvidence || blocksProductRepair,
2838
- blocksProductRepairUntilChangedEvidence: blocksProductRepair,
2839
- nextAction: waitingForNewEvidence
2840
- ? 'collect_required_reset_evidence'
2841
- : action
2842
- };
2843
- }
2844
- function changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(diagnosisGate, changedFiles, options) {
2845
- if (options === void 0) { options = {}; }
2846
- var validation = validateResolveIOSupportDiagnosisGate(diagnosisGate);
2847
- if (!validation.valid || !validation.normalized) {
2848
- return cleanList(changedFiles, 80, 500);
2849
- }
2850
- var owners = new Set(validation.normalized.owner_files.map(normalizeOwnerFilePath));
2851
- return cleanList(changedFiles, 120, 500)
2852
- .map(normalizeOwnerFilePath)
2853
- .filter(function (filePath) {
2854
- if (!filePath) {
2855
- return false;
2856
- }
2857
- if (owners.has(filePath)) {
2858
- return false;
2859
- }
2860
- if (options.allowTests && /(^|\/)(tests?|spec|__tests__)(\/|$)|\.(?:spec|test)\.[jt]sx?$/i.test(filePath)) {
2861
- return false;
2862
- }
2863
- return true;
2864
- });
2865
- }
2866
- function decideResolveIOSupportV5RepairGate(input) {
2867
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
2868
- var activeStepType = cleanText(input.activeStepType, 80);
2869
- var failureClass = cleanText(input.failureClass, 80).toLowerCase();
2870
- var preflightGate = evaluateResolveIOSupportPreflightGate(input.preflightGate);
2871
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.diagnosisGate, {
2872
- maxOwnerFiles: input.maxOwnerFiles
2873
- });
2874
- var ownerFiles = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || [];
2875
- var outsideOwnerFiles = changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(diagnosisValidation.normalized || input.diagnosisGate, input.changedFiles, { allowTests: input.allowTestsOutsideOwnerFiles === true });
2876
- var repeatedFailure = ((_b = input.history) === null || _b === void 0 ? void 0 : _b.length) ? decideResolveIOSupportV5RepeatedFailureStop({
2877
- history: input.history,
2878
- failureClass: failureClass,
2879
- blocker: input.blocker,
2880
- evidence: input.evidence,
2881
- evidenceHash: input.evidenceHash,
2882
- changedFiles: input.changedFiles,
2883
- artifactPaths: input.artifactPaths,
2884
- limit: Math.max(1, Number(input.maxRepeatedNoProgress || 2) || 2),
2885
- ignoreInfra: true
2886
- }) : undefined;
2887
- var recoveryPlanFor = function (action, reason, recoveryFailureClass, productRepairFailure) {
2888
- if (recoveryFailureClass === void 0) { recoveryFailureClass = failureClass || 'unknown'; }
2889
- if (productRepairFailure === void 0) { productRepairFailure = false; }
2890
- return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryPlan)({
2891
- action: action,
2892
- reason: reason,
2893
- failureClass: recoveryFailureClass,
2894
- lane: 'build',
2895
- stepType: activeStepType || 'build_repair',
2896
- blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
2897
- changedFiles: cleanList(input.changedFiles, 40, 500),
2898
- maxSameFailureRepeats: Math.max(1, Number(input.maxRepeatedNoProgress || 2) || 2),
2899
- productRepairFailure: productRepairFailure
2900
- });
2901
- };
2902
- var recoveryCheckpointFor = function (recoveryPlan) { return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryCheckpoint)({
2903
- plan: recoveryPlan,
2904
- current: {
2905
- lane: 'build',
2906
- stepType: activeStepType || 'build_repair',
2907
- failureClass: failureClass || 'unknown',
2908
- blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
2909
- evidenceHash: input.evidenceHash,
2910
- changedFiles: cleanList(input.changedFiles, 40, 500),
2911
- summary: input.blocker
2912
- }
2913
- }); };
2914
- var recoveryFieldsFor = function (recoveryPlan) {
2915
- var recoveryCheckpoint = recoveryCheckpointFor(recoveryPlan);
2916
- var recoveryEvidenceProbe = (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryEvidenceProbe)({
2917
- checkpoint: recoveryCheckpoint,
2918
- current: {
2919
- lane: 'build',
2920
- stepType: activeStepType || 'build_repair',
2921
- failureClass: failureClass || 'unknown',
2922
- blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
2923
- evidenceHash: input.evidenceHash,
2924
- changedFiles: cleanList(input.changedFiles, 40, 500),
2925
- summary: input.blocker
2926
- }
2927
- });
2928
- var current = {
2929
- lane: 'build',
2930
- stepType: activeStepType || 'build_repair',
2931
- failureClass: failureClass || 'unknown',
2932
- blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
2933
- evidenceHash: input.evidenceHash,
2934
- changedFiles: cleanList(input.changedFiles, 40, 500),
2935
- summary: input.blocker
2936
- };
2937
- return {
2938
- recoveryPlan: recoveryPlan,
2939
- recoveryCheckpoint: recoveryCheckpoint,
2940
- recoveryEvidenceProbe: recoveryEvidenceProbe,
2941
- recoveryAction: (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryActionPacket)({
2942
- plan: recoveryPlan,
2943
- checkpoint: recoveryCheckpoint,
2944
- probe: recoveryEvidenceProbe,
2945
- current: current
2946
- })
2947
- };
2948
- };
2949
- if (repeatedFailure === null || repeatedFailure === void 0 ? void 0 : repeatedFailure.shouldStop) {
2950
- var recoveryPlan_1 = recoveryPlanFor('park_repeated_failure', repeatedFailure.reason, repeatedFailure.failureClass, true);
2951
- return __assign({ action: 'park_repeated_failure', canEditProductCode: false, blockers: [repeatedFailure.reason], ownerFiles: ownerFiles, issueClass: (_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.issue_class, proofPlan: (_d = diagnosisValidation.normalized) === null || _d === void 0 ? void 0 : _d.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_1));
2952
- }
2953
- if (preflightGate.blocksProductRepair) {
2954
- var recoveryFailureClass = preflightGate.failureClass === 'compile' ? 'compile' : 'infra';
2955
- var recoveryPlan_2 = recoveryPlanFor('retry_infra', 'support_v5_preflight_gate_blocks_product_repair', recoveryFailureClass, false);
2956
- return __assign({ action: 'infra_repair_only', canEditProductCode: false, blockers: preflightGate.blockers.length
2957
- ? preflightGate.blockers
2958
- : ['Deterministic support preflight must pass before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_e = diagnosisValidation.normalized) === null || _e === void 0 ? void 0 : _e.issue_class, proofPlan: (_f = diagnosisValidation.normalized) === null || _f === void 0 ? void 0 : _f.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_2));
2959
- }
2960
- if (failureClass === 'infra' || failureClass === 'compile') {
2961
- var recoveryPlan_3 = recoveryPlanFor('retry_infra', 'support_v5_infra_or_compile_repair_required', failureClass, false);
2962
- return __assign({ action: 'infra_repair_only', canEditProductCode: false, blockers: ['Infra/compile/Puppeteer/startup failures must be repaired in the harness lane before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_g = diagnosisValidation.normalized) === null || _g === void 0 ? void 0 : _g.issue_class, proofPlan: (_h = diagnosisValidation.normalized) === null || _h === void 0 ? void 0 : _h.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_3));
2963
- }
2964
- if (activeStepType === 'diagnosis_gate' || !diagnosisValidation.valid) {
2965
- var recoveryPlan_4 = recoveryPlanFor('continue', 'support_v5_diagnosis_gate_required', 'diagnosis', false);
2966
- return __assign({ action: 'diagnose_only', canEditProductCode: false, blockers: diagnosisValidation.blockers.length
2967
- ? diagnosisValidation.blockers
2968
- : ['SupportDiagnosisGate is required before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_j = diagnosisValidation.normalized) === null || _j === void 0 ? void 0 : _j.issue_class, proofPlan: (_k = diagnosisValidation.normalized) === null || _k === void 0 ? void 0 : _k.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_4));
2969
- }
2970
- if (outsideOwnerFiles.length) {
2971
- var recoveryPlan_5 = recoveryPlanFor('continue', 'support_v5_out_of_scope_requires_diagnosis_revision', 'owner_scope', false);
2972
- return __assign({ action: 'reject_out_of_scope', canEditProductCode: false, blockers: ["Changed files outside diagnosis owner_files; revise diagnosis with new evidence before broadening edits: ".concat(outsideOwnerFiles.join(', '))], ownerFiles: ownerFiles, issueClass: (_l = diagnosisValidation.normalized) === null || _l === void 0 ? void 0 : _l.issue_class, proofPlan: (_m = diagnosisValidation.normalized) === null || _m === void 0 ? void 0 : _m.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_5));
2973
- }
2974
- var recoveryPlan = recoveryPlanFor('continue', 'support_v5_product_repair_allowed_after_diagnosis', failureClass || 'product_code', true);
2975
- return __assign({ action: 'allow_product_repair', canEditProductCode: true, blockers: [], ownerFiles: ownerFiles, issueClass: (_o = diagnosisValidation.normalized) === null || _o === void 0 ? void 0 : _o.issue_class, proofPlan: (_p = diagnosisValidation.normalized) === null || _p === void 0 ? void 0 : _p.proof_plan, outsideOwnerFiles: outsideOwnerFiles, preflightGate: preflightGate, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan));
2976
- }
2977
- function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
2978
- var _a;
2979
- var validation = validateResolveIOSupportDiagnosisGate(diagnosisGate);
2980
- var gate = validation.normalized;
2981
- if (!gate) {
2982
- return bundle;
2983
- }
2984
- var now = isoNow();
2985
- var ownerFiles = gate.owner_files;
2986
- var probes = buildResolveIOSupportIssueClassProbes(gate);
2987
- var probePlan = buildResolveIOSupportIssueClassProbePlan(gate, now);
2988
- var probePlanValidation = validateResolveIOSupportIssueClassProbePlan(probePlan, gate, now);
2989
- var proofContract = gate.proof_plan.business_proof_contract;
2990
- var activeProbe = probePlanValidation.activeProbe || probePlan.activeProbe || probes[0];
2991
- var businessProof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || gate.proof_plan.business_assertion;
2992
- var businessAssertion = (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.state_transition.assertion)
2993
- || (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion)
2994
- || gate.proof_plan.data_assertion
2995
- || gate.proof_plan.after;
2996
- var diagnosisMicrotaskId = ((_a = (bundle.supportV5MicrotaskLedger || [])
2997
- .find(function (task) { return task.type === 'diagnosis_gate'; })) === null || _a === void 0 ? void 0 : _a.microtaskId)
2998
- || stableIdFromText('diagnosis', "Root-cause-first diagnosis gate for: ".concat(cleanText(bundle.supportV5ScopeDigest || gate.issue_case.customer_complaint, 360) || 'support ticket'));
2999
- var ledger = (bundle.supportV5MicrotaskLedger || []).map(function (task) {
3000
- if (task.type === 'diagnosis_gate') {
3001
- return __assign(__assign({}, task), { status: validation.valid ? 'pass' : 'needs_repair', blocker: validation.valid ? '' : validation.blockers.join(' | '), updatedAt: now });
3002
- }
3003
- if (task.lane === 'build' && /repair|product_repair|build_repair/i.test(String(task.type || ''))) {
3004
- return __assign(__assign({}, task), { targetFiles: ownerFiles, contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'owner_files'], false))), selfGate: "Repair only the diagnosed owner files unless you revise the diagnosis with new evidence. Owner files: ".concat(ownerFiles.join(', '), "."), acceptanceProof: businessProof, dependsOn: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.dependsOn || [])), false), [diagnosisMicrotaskId], false))), updatedAt: now });
3005
- }
3006
- if (task.lane === 'qa' && task.type === 'qa_row') {
3007
- return __assign(__assign({}, task), { contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'supportV5IssueClassProbePlan', 'proof_plan'], false))), selfGate: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.action) || task.selfGate, acceptanceProof: (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.expected_business_proof) || businessProof || task.acceptanceProof, targetFiles: ownerFiles, updatedAt: now });
3008
- }
3009
- return task;
3010
- });
3011
- var nextActive = selectResolveIOSupportV5ActiveMicrotask(ledger, bundle.supportV5ActiveMicrotaskId);
3012
- return __assign(__assign({}, bundle), { supportV5DiagnosisGate: gate, supportV5IssueClassProbePlan: probePlanValidation.normalized || probePlan, supportV5MicrotaskLedger: ledger, supportV5ActiveMicrotaskId: nextActive === null || nextActive === void 0 ? void 0 : nextActive.microtaskId, supportV5LaneMemory: __assign(__assign({}, bundle.supportV5LaneMemory), { build: __assign(__assign({}, bundle.supportV5LaneMemory.build), { changedFiles: ownerFiles, scopeSummary: [
3013
- bundle.supportV5LaneMemory.build.scopeSummary,
3014
- "Diagnosis issue class: ".concat(gate.issue_class),
3015
- "Accepted hypothesis: ".concat(gate.accepted_hypothesis.statement),
3016
- "Owner files: ".concat(ownerFiles.join(', '))
3017
- ].filter(Boolean).join(' | '), updatedAt: now }), qa: __assign(__assign({}, bundle.supportV5LaneMemory.qa), { activeQaRow: {
3018
- workflow: (proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test) || (activeProbe === null || activeProbe === void 0 ? void 0 : activeProbe.state_transition.action) || gate.proof_plan.action,
3019
- route: gate.proof_plan.route || gate.issue_case.route_module,
3020
- assertion: businessAssertion,
3021
- status: 'pending'
3022
- }, updatedAt: now }) }) });
3023
- }
3024
- function stableIdFromText(prefix, value) {
3025
- var text = cleanText(value, 2000).toLowerCase();
3026
- var hash = 0;
3027
- for (var index = 0; index < text.length; index += 1) {
3028
- hash = ((hash << 5) - hash + text.charCodeAt(index)) | 0;
3029
- }
3030
- return "".concat(prefix, "-").concat(Math.abs(hash).toString(36) || '0');
3031
- }
3032
- function estimateTextTokens(value) {
3033
- var text = String(value || '');
3034
- if (!text) {
3035
- return 0;
3036
- }
3037
- return Math.max(1, Math.ceil(text.length / 4));
3038
- }
3039
- function fingerprintResolveIOSupportV5Blocker(value) {
3040
- var text = cleanText(value, 4000)
3041
- .toLowerCase()
3042
- .replace(/[a-f0-9]{16,}/g, '<id>')
3043
- .replace(/\b\d{2,}\b/g, '<n>')
3044
- .replace(/\bline\s+<n>\b/g, 'line <n>');
3045
- var hash = 0;
3046
- for (var index = 0; index < text.length; index += 1) {
3047
- hash = ((hash << 5) - hash + text.charCodeAt(index)) | 0;
3048
- }
3049
- return "v5-".concat(Math.abs(hash).toString(36));
3050
- }
3051
- function buildResolveIOSupportV5Budget(existing) {
3052
- return {
3053
- maxPromptTokensPerNonInitialStep: Number((existing === null || existing === void 0 ? void 0 : existing.maxPromptTokensPerNonInitialStep) || 1800),
3054
- maxLoopsPerTicket: Number((existing === null || existing === void 0 ? void 0 : existing.maxLoopsPerTicket) || 24),
3055
- maxRepeatedNoProgress: Number((existing === null || existing === void 0 ? void 0 : existing.maxRepeatedNoProgress) || 2),
3056
- maxRuntimeMinutesPerLoop: Number((existing === null || existing === void 0 ? void 0 : existing.maxRuntimeMinutesPerLoop) || 15),
3057
- totalPromptTokenEstimate: Number((existing === null || existing === void 0 ? void 0 : existing.totalPromptTokenEstimate) || 0),
3058
- totalRuntimeMs: Number((existing === null || existing === void 0 ? void 0 : existing.totalRuntimeMs) || 0),
3059
- loopCount: Number((existing === null || existing === void 0 ? void 0 : existing.loopCount) || 0)
3060
- };
3061
- }
3062
- function buildResolveIOSupportV5PromptBudget(existing) {
3063
- return {
3064
- initialPlannerCap: Number((existing === null || existing === void 0 ? void 0 : existing.initialPlannerCap) || 6000),
3065
- buildMicrotaskCap: Number((existing === null || existing === void 0 ? void 0 : existing.buildMicrotaskCap) || 1800),
3066
- buildMicrotaskHardCap: Number((existing === null || existing === void 0 ? void 0 : existing.buildMicrotaskHardCap) || 2500),
3067
- qaMicrotaskCap: Number((existing === null || existing === void 0 ? void 0 : existing.qaMicrotaskCap) || 1500),
3068
- qaMicrotaskHardCap: Number((existing === null || existing === void 0 ? void 0 : existing.qaMicrotaskHardCap) || 2200),
3069
- repairMicrotaskCap: Number((existing === null || existing === void 0 ? void 0 : existing.repairMicrotaskCap) || 1200),
3070
- repairMicrotaskHardCap: Number((existing === null || existing === void 0 ? void 0 : existing.repairMicrotaskHardCap) || 1800)
3071
- };
3072
- }
3073
- function buildResolveIOSupportV5ScopeDigest(input) {
3074
- var scope = Array.isArray(input.approvedScope)
3075
- ? cleanList(input.approvedScope, 30, 220).join(' | ')
3076
- : cleanText(input.approvedScope, 4000);
3077
- var raw = [
3078
- input.goal ? "Goal: ".concat(cleanText(input.goal, 300)) : '',
3079
- scope ? "Approved scope: ".concat(scope) : '',
3080
- input.prBranch ? "PR branch: ".concat(cleanText(input.prBranch, 160)) : ''
3081
- ].filter(Boolean).join('\n');
3082
- var maxChars = Math.max(400, Math.floor(Number(input.maxTokens || 1000) * 4));
3083
- return raw.slice(0, maxChars);
3084
- }
3085
- function buildResolveIOSupportV5MicrotaskLedger(input) {
3086
- var e_9, _a;
3087
- var existing = Array.isArray(input.existing) ? input.existing : [];
3088
- var completedByObjective = new Map();
3089
- try {
3090
- for (var existing_1 = __values(existing), existing_1_1 = existing_1.next(); !existing_1_1.done; existing_1_1 = existing_1.next()) {
3091
- var task = existing_1_1.value;
3092
- if (task && (task.status === 'pass' || task.status === 'parked')) {
3093
- completedByObjective.set(cleanText(task.objective, 500).toLowerCase(), task);
3094
- }
3095
- }
3096
- }
3097
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
3098
- finally {
3099
- try {
3100
- if (existing_1_1 && !existing_1_1.done && (_a = existing_1.return)) _a.call(existing_1);
3101
- }
3102
- finally { if (e_9) throw e_9.error; }
3103
- }
3104
- var now = isoNow(input.now);
3105
- var requirements = cleanList(input.requirements, 30, 240);
3106
- var sourceRequirements = requirements.length
3107
- ? requirements
3108
- : cleanText(input.scopeDigest, 1000).split(/\s+\|\s+|\r?\n/g).map(function (line) { return line.trim(); }).filter(Boolean).slice(0, 12);
3109
- var ledger = [];
3110
- var diagnosisObjective = "Root-cause-first diagnosis gate for: ".concat(cleanText(input.scopeDigest, 360) || 'support ticket');
3111
- var diagnosisId = stableIdFromText('diagnosis', diagnosisObjective);
3112
- var existingDiagnosis = existing.find(function (task) { return (task === null || task === void 0 ? void 0 : task.type) === 'diagnosis_gate' || (task === null || task === void 0 ? void 0 : task.microtaskId) === diagnosisId; });
3113
- ledger.push(existingDiagnosis && (existingDiagnosis.status === 'pass' || existingDiagnosis.status === 'parked') ? existingDiagnosis : {
3114
- microtaskId: diagnosisId,
3115
- lane: 'build',
3116
- type: 'diagnosis_gate',
3117
- status: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.status) || 'pending',
3118
- objective: diagnosisObjective,
3119
- targetFiles: [],
3120
- contextRefs: ['scope_digest', 'support_context', 'similar_tickets', 'similar_commits'],
3121
- selfGate: 'Read-only diagnosis only: reproduce or explicitly classify the issue, accept one falsifiable root-cause hypothesis, reject alternatives, identify the failing path, cap owner_files, and define before/action/after business proof.',
3122
- acceptanceProof: 'Valid ResolveIOSupportDiagnosisGate JSON with issue_case, issue_class, accepted_hypothesis, rejected_alternatives, failing_path, owner_files, proof_plan, evidence, and status=passed.',
3123
- threadKey: input.buildThreadKey,
3124
- promptTokenEstimate: existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.promptTokenEstimate,
3125
- attempts: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.attempts) || 0,
3126
- dependsOn: [],
3127
- parentScopeId: stableIdFromText('scope', diagnosisObjective),
3128
- blocker: existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.blocker,
3129
- createdAt: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.createdAt) || now,
3130
- updatedAt: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.updatedAt) || now
3131
- });
3132
- sourceRequirements.forEach(function (requirement, index) {
3133
- var objective = cleanText(requirement, 240);
3134
- if (!objective) {
3135
- return;
3136
- }
3137
- var existingCompleted = completedByObjective.get(objective.toLowerCase());
3138
- var buildId = stableIdFromText("build-".concat(index + 1), objective);
3139
- var qaId = stableIdFromText("qa-".concat(index + 1), objective);
3140
- ledger.push(existingCompleted && existingCompleted.lane === 'build' ? existingCompleted : {
3141
- microtaskId: buildId,
3142
- lane: 'build',
3143
- type: 'build_repair',
3144
- status: 'pending',
3145
- objective: objective,
3146
- targetFiles: [],
3147
- contextRefs: ['scope_digest'],
3148
- selfGate: 'Run the smallest compile/type/unit check that proves this one behavior.',
3149
- acceptanceProof: 'Concrete code/data proof for this behavior, with changed files listed.',
3150
- threadKey: input.buildThreadKey,
3151
- attempts: 0,
3152
- dependsOn: [diagnosisId],
3153
- parentScopeId: stableIdFromText('scope', objective),
3154
- createdAt: now,
3155
- updatedAt: now
3156
- });
3157
- ledger.push({
3158
- microtaskId: qaId,
3159
- lane: 'qa',
3160
- type: 'qa_row',
3161
- status: 'pending',
3162
- objective: "QA proof for: ".concat(objective),
3163
- targetFiles: [],
3164
- contextRefs: ['scope_digest', buildId],
3165
- selfGate: 'Drive this one customer-facing workflow row in browser/localhost and capture one captioned proof artifact.',
3166
- acceptanceProof: 'QA matrix row pass with route/data assertion, screenshot/caption artifact, and persisted before/after row/count/value proof for data-changing workflows.',
3167
- threadKey: input.qaThreadKey,
3168
- attempts: 0,
3169
- dependsOn: [diagnosisId, buildId],
3170
- parentScopeId: stableIdFromText('scope', objective),
3171
- createdAt: now,
3172
- updatedAt: now
3173
- });
3174
- });
3175
- return ledger.length ? ledger : existing.slice(-80);
3176
- }
3177
- function selectResolveIOSupportV5ActiveMicrotask(ledger, preferredId) {
3178
- if (ledger === void 0) { ledger = []; }
3179
- var byPreferred = preferredId ? ledger.find(function (task) { return task.microtaskId === preferredId && !['pass', 'parked'].includes(task.status); }) : undefined;
3180
- if (byPreferred) {
3181
- return byPreferred;
3182
- }
3183
- return ledger.find(function (task) { return task.status === 'needs_repair'; })
3184
- || ledger.find(function (task) { return task.status === 'in_progress'; })
3185
- || ledger.find(function (task) { return task.type === 'diagnosis_gate' && task.status === 'pending'; })
3186
- || ledger.find(function (task) { return task.lane === 'build' && /repair/i.test(String(task.type || '')) && task.status === 'pending'; })
3187
- || ledger.find(function (task) { return task.status === 'pending'; })
3188
- || ledger.find(function (task) { return task.status === 'blocked'; });
3189
- }
3190
- function initializeResolveIOSupportV5State(input) {
3191
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
3192
- var now = isoNow(input.now);
3193
- var existing = input.existing || {};
3194
- var existingSupervisor = existing.supportV5SupervisorState;
3195
- var existingLaneMemory = existing.supportV5LaneMemory || {};
3196
- var scope = cleanList(input.approvedScopeRequirements, 24, 240).join(' | ')
3197
- || cleanText(input.description, 1000)
3198
- || cleanText(input.title, 300);
3199
- var ticketLabel = cleanText(input.ticketNumber || input.ticketId || input.jobId, 120);
3200
- var buildThreadKey = cleanText(input.buildThreadKey || ((_a = existingLaneMemory.build) === null || _a === void 0 ? void 0 : _a.threadKey) || "support:".concat(input.ticketId || input.jobId, ":job:").concat(input.jobId, ":build"), 240);
3201
- var qaThreadKey = cleanText(input.qaThreadKey || ((_b = existingLaneMemory.qa) === null || _b === void 0 ? void 0 : _b.threadKey) || "support:".concat(input.ticketId || input.jobId, ":job:").concat(input.jobId, ":qa"), 240);
3202
- var budget = buildResolveIOSupportV5Budget(existing.supportV5Budget);
3203
- var existingDiagnosisGate = normalizeResolveIOSupportDiagnosisGate(existing.supportV5DiagnosisGate);
3204
- var existingPreflightGate = evaluateResolveIOSupportPreflightGate(existing.supportV5PreflightGate || existing.support_v5_preflight_gate, now);
3205
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(existingDiagnosisGate);
3206
- var existingProbePlanValidation = validateResolveIOSupportIssueClassProbePlan(existing.supportV5IssueClassProbePlan || existing.support_v5_issue_class_probe_plan, diagnosisValidation.normalized || existingDiagnosisGate, now);
3207
- var scopeDigest = cleanText(existing.supportV5ScopeDigest, 4000) || buildResolveIOSupportV5ScopeDigest({
3208
- goal: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.currentGoal) || "Resolve support ticket ".concat(ticketLabel),
3209
- approvedScope: scope,
3210
- prBranch: input.prBranch || (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.prBranch) || ''
3211
- });
3212
- var ledger = buildResolveIOSupportV5MicrotaskLedger({
3213
- scopeDigest: scopeDigest,
3214
- requirements: cleanList(input.approvedScopeRequirements, 30, 240),
3215
- buildThreadKey: buildThreadKey,
3216
- qaThreadKey: qaThreadKey,
3217
- now: now,
3218
- existing: existing.supportV5MicrotaskLedger
3219
- });
3220
- var activeMicrotask = selectResolveIOSupportV5ActiveMicrotask(ledger, existing.supportV5ActiveMicrotaskId);
3221
- var initialized = {
3222
- supportWorkflowVersion: 'v5',
3223
- supportV5SupervisorState: {
3224
- version: 'v5',
3225
- status: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.status) || 'active',
3226
- currentGoal: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.currentGoal) || "Resolve support ticket ".concat(ticketLabel),
3227
- approvedScope: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.approvedScope) || scope,
3228
- prBranch: cleanText(input.prBranch || (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.prBranch) || '', 240),
3229
- activeStep: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.activeStep) || (diagnosisValidation.valid ? 'compile_check' : 'diagnosis_gate'),
3230
- activeBlocker: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.activeBlocker) || (diagnosisValidation.valid ? '' : 'SupportDiagnosisGate required before product-code repair.'),
3231
- lastGoodCheckpoint: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.lastGoodCheckpoint) || 'v5_initialized',
3232
- currentQaRow: existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.currentQaRow,
3233
- processLease: input.processLease || (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.processLease),
3234
- artifactLinks: cleanList(existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.artifactLinks, 40, 500),
3235
- noEmailUnlessApproved: true,
3236
- updatedAt: now
3237
- },
3238
- supportV5DiagnosisGate: diagnosisValidation.valid ? diagnosisValidation.normalized : existingDiagnosisGate,
3239
- supportV5DiagnosisEvidencePack: existing.supportV5DiagnosisEvidencePack || existing.support_v5_diagnosis_evidence_pack,
3240
- supportV5IssueClassProbePlan: existingProbePlanValidation.normalized,
3241
- supportV5PreflightGate: existingPreflightGate.status === 'unknown' && existingPreflightGate.checks.length === 0
3242
- ? undefined
3243
- : existingPreflightGate,
3244
- supportV5LaneMemory: {
3245
- build: {
3246
- lane: 'build',
3247
- model: ((_c = existingLaneMemory.build) === null || _c === void 0 ? void 0 : _c.model) || 'gpt-5.3-codex',
3248
- threadKey: buildThreadKey,
3249
- scopeSummary: ((_d = existingLaneMemory.build) === null || _d === void 0 ? void 0 : _d.scopeSummary) || scope,
3250
- activeBlocker: ((_e = existingLaneMemory.build) === null || _e === void 0 ? void 0 : _e.activeBlocker) || '',
3251
- activeQaRow: (_f = existingLaneMemory.build) === null || _f === void 0 ? void 0 : _f.activeQaRow,
3252
- changedFiles: cleanList((_g = existingLaneMemory.build) === null || _g === void 0 ? void 0 : _g.changedFiles, 80, 500),
3253
- artifactPaths: cleanList((_h = existingLaneMemory.build) === null || _h === void 0 ? void 0 : _h.artifactPaths, 80, 500),
3254
- latestPromptTokenEstimate: Number(((_j = existingLaneMemory.build) === null || _j === void 0 ? void 0 : _j.latestPromptTokenEstimate) || 0) || undefined,
3255
- updatedAt: ((_k = existingLaneMemory.build) === null || _k === void 0 ? void 0 : _k.updatedAt) || now
3256
- },
3257
- qa: {
3258
- lane: 'qa',
3259
- model: ((_l = existingLaneMemory.qa) === null || _l === void 0 ? void 0 : _l.model) || 'gpt-5.4-mini',
3260
- threadKey: qaThreadKey,
3261
- scopeSummary: ((_m = existingLaneMemory.qa) === null || _m === void 0 ? void 0 : _m.scopeSummary) || scope,
3262
- activeBlocker: ((_o = existingLaneMemory.qa) === null || _o === void 0 ? void 0 : _o.activeBlocker) || '',
3263
- activeQaRow: (_p = existingLaneMemory.qa) === null || _p === void 0 ? void 0 : _p.activeQaRow,
3264
- changedFiles: cleanList((_q = existingLaneMemory.qa) === null || _q === void 0 ? void 0 : _q.changedFiles, 80, 500),
3265
- artifactPaths: cleanList((_r = existingLaneMemory.qa) === null || _r === void 0 ? void 0 : _r.artifactPaths, 80, 500),
3266
- latestPromptTokenEstimate: Number(((_s = existingLaneMemory.qa) === null || _s === void 0 ? void 0 : _s.latestPromptTokenEstimate) || 0) || undefined,
3267
- updatedAt: ((_t = existingLaneMemory.qa) === null || _t === void 0 ? void 0 : _t.updatedAt) || now
3268
- }
3269
- },
3270
- supportV5StepHistory: Array.isArray(existing.supportV5StepHistory)
3271
- ? existing.supportV5StepHistory.slice(-80)
3272
- : [],
3273
- supportV5Budget: budget,
3274
- supportV5RunnerIncidents: Array.isArray(existing.supportV5RunnerIncidents)
3275
- ? existing.supportV5RunnerIncidents.slice(-80)
3276
- : [],
3277
- supportV5MicrotaskLedger: ledger,
3278
- supportV5ActiveMicrotaskId: diagnosisValidation.valid
3279
- ? activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId
3280
- : ((_u = ledger.find(function (task) { return task.type === 'diagnosis_gate' && !['pass', 'parked'].includes(task.status); })) === null || _u === void 0 ? void 0 : _u.microtaskId) || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId),
3281
- supportV5ScopeDigest: scopeDigest,
3282
- supportV5MicrotaskUsageHistory: Array.isArray(existing.supportV5MicrotaskUsageHistory)
3283
- ? existing.supportV5MicrotaskUsageHistory.slice(-200)
3284
- : [],
3285
- supportV5FailureFingerprints: Array.isArray(existing.supportV5FailureFingerprints)
3286
- ? existing.supportV5FailureFingerprints.slice(-200)
3287
- : [],
3288
- supportV5RecoveryPlan: existing.supportV5RecoveryPlan,
3289
- supportV5RecoveryCheckpoint: existing.supportV5RecoveryCheckpoint,
3290
- supportV5RecoveryEvidenceProbe: existing.supportV5RecoveryEvidenceProbe,
3291
- supportV5RecoveryAction: existing.supportV5RecoveryAction,
3292
- supportV5RecoveryDispatchHistory: Array.isArray(existing.supportV5RecoveryDispatchHistory)
3293
- ? existing.supportV5RecoveryDispatchHistory.slice(-50)
3294
- : [],
3295
- supportV5RecoveryDirective: existing.supportV5RecoveryDirective
3296
- };
3297
- return diagnosisValidation.valid && diagnosisValidation.normalized
3298
- ? applyResolveIOSupportDiagnosisGateToMicrotasks(initialized, diagnosisValidation.normalized)
3299
- : initialized;
3300
- }
3301
- function recordResolveIOSupportV5Step(bundle, step) {
3302
- var _a, _b, _c, _d;
3303
- var now = isoNow(step.now);
3304
- var promptTokens = Math.max(0, Number(step.promptTokenEstimate || 0) || 0);
3305
- var runtimeMs = Math.max(0, Number(step.runtimeMs || 0) || 0);
3306
- var microtaskId = cleanText(step.microtaskId || bundle.supportV5ActiveMicrotaskId, 160);
3307
- var normalizedDiagnosisGate = step.diagnosisGate
3308
- ? normalizeResolveIOSupportDiagnosisGate(step.diagnosisGate, now)
3309
- : undefined;
3310
- var normalizedPreflightGate = step.preflightGate
3311
- ? evaluateResolveIOSupportPreflightGate(step.preflightGate, now)
3312
- : undefined;
3313
- var blockerFingerprint = step.blocker || step.summary
3314
- ? fingerprintResolveIOSupportV5Blocker(step.blocker || step.summary || '')
3315
- : undefined;
3316
- var evidenceHash = cleanText(step.evidenceHash, 80)
3317
- || (((_a = step.artifactPaths) === null || _a === void 0 ? void 0 : _a.length) || step.blocker || step.summary
3318
- ? hashResolveIOSupportV5Evidence(((_b = step.artifactPaths) === null || _b === void 0 ? void 0 : _b.length) ? step.artifactPaths : "".concat(step.blocker || '', "\n").concat(step.summary || ''))
3319
- : (0, ai_runner_manager_policy_1.hashResolveIOAIManagerEvidence)({
3320
- failureClass: step.failureClass,
3321
- blocker: step.blocker,
3322
- summary: step.summary,
3323
- changedFiles: step.changedFiles,
3324
- artifactPaths: step.artifactPaths
3325
- }));
3326
- var record = __assign(__assign({}, (microtaskId ? { microtaskId: microtaskId } : {})), { stepType: step.stepType, outcome: step.outcome, lane: step.lane, model: cleanText(step.model, 80), threadKey: cleanText(step.threadKey, 240), promptTokenEstimate: promptTokens || undefined, runtimeMs: runtimeMs || undefined, summary: cleanText(step.summary || step.blocker || step.outcome, 1200), blocker: cleanText(step.blocker, 1200), changedFiles: cleanList(step.changedFiles, 80, 500), artifactPaths: cleanList(step.artifactPaths, 80, 500), diagnosisGate: normalizedDiagnosisGate, preflightGate: normalizedPreflightGate, failureClass: cleanText(step.failureClass, 80) || undefined, blockerFingerprint: blockerFingerprint, evidenceHash: evidenceHash, recordedAt: now });
3327
- var diagnosisGate = normalizedDiagnosisGate || bundle.supportV5DiagnosisGate;
3328
- var preflightGate = normalizedPreflightGate || bundle.supportV5PreflightGate;
3329
- var laneMemory = __assign({}, bundle.supportV5LaneMemory);
3330
- if (step.lane === 'build' || step.lane === 'qa') {
3331
- var previous = laneMemory[step.lane];
3332
- laneMemory[step.lane] = __assign(__assign({}, previous), { activeBlocker: record.blocker || previous.activeBlocker || '', activeQaRow: step.activeQaRow || previous.activeQaRow, changedFiles: ((_c = record.changedFiles) === null || _c === void 0 ? void 0 : _c.length) ? record.changedFiles : previous.changedFiles, artifactPaths: ((_d = record.artifactPaths) === null || _d === void 0 ? void 0 : _d.length) ? record.artifactPaths : previous.artifactPaths, latestPromptTokenEstimate: promptTokens || previous.latestPromptTokenEstimate, updatedAt: now });
3333
- }
3334
- var supervisor = __assign(__assign({}, bundle.supportV5SupervisorState), { status: step.outcome === 'ready_for_merge' ? 'complete' : (step.outcome === 'park_manual' || step.outcome === 'budget_stop' ? 'parked' : 'active'), activeStep: step.stepType, activeBlocker: record.blocker || '', currentQaRow: step.activeQaRow || bundle.supportV5SupervisorState.currentQaRow, lastGoodCheckpoint: step.outcome === 'pass' || step.outcome === 'ready_for_merge'
3335
- ? step.stepType
3336
- : bundle.supportV5SupervisorState.lastGoodCheckpoint, artifactLinks: Array.from(new Set(__spreadArray(__spreadArray([], __read(bundle.supportV5SupervisorState.artifactLinks), false), __read((record.artifactPaths || [])), false))).slice(-80), updatedAt: now });
3337
- var ledger = (bundle.supportV5MicrotaskLedger || []).map(function (task) {
3338
- if (task.microtaskId !== bundle.supportV5ActiveMicrotaskId) {
3339
- return task;
3340
- }
3341
- var status = step.outcome === 'pass' || step.outcome === 'ready_for_merge'
3342
- ? 'pass'
3343
- : step.outcome === 'park_manual' || step.outcome === 'budget_stop'
3344
- ? 'parked'
3345
- : step.outcome === 'needs_repair' || step.outcome === 'retry_same_step'
3346
- ? 'needs_repair'
3347
- : 'in_progress';
3348
- return __assign(__assign({}, task), { status: status, blocker: record.blocker || task.blocker, promptTokenEstimate: promptTokens || task.promptTokenEstimate, attempts: task.attempts + (step.outcome === 'pass' || step.outcome === 'ready_for_merge' ? 0 : 1), updatedAt: now });
3349
- });
3350
- var failureFingerprint = record.failureClass && record.blockerFingerprint && record.evidenceHash
3351
- ? {
3352
- stepType: record.stepType,
3353
- failureClass: cleanText(record.failureClass, 80),
3354
- blockerFingerprint: record.blockerFingerprint,
3355
- evidenceHash: record.evidenceHash,
3356
- recordedAt: now
3357
- }
3358
- : undefined;
3359
- var managerDecision = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerPolicy)({
3360
- history: __spreadArray(__spreadArray([], __read(bundle.supportV5StepHistory), false), [record], false),
3361
- current: record,
3362
- maxSameFailureRepeats: buildResolveIOSupportV5Budget(bundle.supportV5Budget).maxRepeatedNoProgress,
3363
- maxPingPongTransitions: 3,
3364
- infraFailureClasses: ['infra', 'compile']
3365
- });
3366
- var previousRecord = bundle.supportV5StepHistory[bundle.supportV5StepHistory.length - 1];
3367
- var nextLoopCount = managerDecision.loopBudgetShouldReset
3368
- || (previousRecord === null || previousRecord === void 0 ? void 0 : previousRecord.failureClass) !== record.failureClass
3369
- || (previousRecord === null || previousRecord === void 0 ? void 0 : previousRecord.blockerFingerprint) !== record.blockerFingerprint
3370
- || (previousRecord === null || previousRecord === void 0 ? void 0 : previousRecord.evidenceHash) !== record.evidenceHash
3371
- ? 1
3372
- : bundle.supportV5Budget.loopCount + 1;
3373
- var nextMicrotask = selectResolveIOSupportV5ActiveMicrotask(ledger, bundle.supportV5ActiveMicrotaskId);
3374
- var nextBundle = __assign(__assign({}, bundle), { supportV5SupervisorState: supervisor, supportV5DiagnosisGate: diagnosisGate, supportV5PreflightGate: preflightGate, supportV5LaneMemory: laneMemory, supportV5StepHistory: __spreadArray(__spreadArray([], __read(bundle.supportV5StepHistory), false), [record], false).slice(-100), supportV5Budget: __assign(__assign({}, bundle.supportV5Budget), { totalPromptTokenEstimate: bundle.supportV5Budget.totalPromptTokenEstimate + promptTokens, totalRuntimeMs: bundle.supportV5Budget.totalRuntimeMs + runtimeMs, loopCount: nextLoopCount }), supportV5MicrotaskLedger: ledger, supportV5ActiveMicrotaskId: nextMicrotask === null || nextMicrotask === void 0 ? void 0 : nextMicrotask.microtaskId, supportV5MicrotaskUsageHistory: bundle.supportV5MicrotaskUsageHistory || [], supportV5FailureFingerprints: failureFingerprint
3375
- ? __spreadArray(__spreadArray([], __read((bundle.supportV5FailureFingerprints || [])), false), [failureFingerprint], false).slice(-200)
3376
- : (bundle.supportV5FailureFingerprints || []), supportV5RecoveryPlan: managerDecision.recoveryPlan, supportV5RecoveryCheckpoint: managerDecision.recoveryCheckpoint, supportV5RecoveryEvidenceProbe: managerDecision.recoveryEvidenceProbe, supportV5RecoveryAction: managerDecision.recoveryAction });
3377
- if (normalizedDiagnosisGate && validateResolveIOSupportDiagnosisGate(normalizedDiagnosisGate).valid) {
3378
- return applyResolveIOSupportDiagnosisGateToMicrotasks(nextBundle, normalizedDiagnosisGate);
3379
- }
3380
- return nextBundle;
3381
- }
3382
- function recordResolveIOSupportV5MicrotaskUsage(bundle, usage) {
3383
- var record = __assign(__assign({}, usage), { microtaskId: cleanText(usage.microtaskId, 160), threadKey: cleanText(usage.threadKey, 240), model: cleanText(usage.model, 80), promptTokenEstimate: Math.max(0, Number(usage.promptTokenEstimate || 0) || 0), promptSections: Array.isArray(usage.promptSections)
3384
- ? usage.promptSections.map(function (section) { return ({
3385
- name: cleanText(section.name, 120),
3386
- tokenEstimate: Math.max(0, Number(section.tokenEstimate || 0) || 0)
3387
- }); }).filter(function (section) { return section.name; })
3388
- : [], recordedAt: isoNow() });
3389
- var ledger = (bundle.supportV5MicrotaskLedger || []).map(function (task) { return task.microtaskId === record.microtaskId
3390
- ? __assign(__assign({}, task), { promptTokenEstimate: record.promptTokenEstimate, updatedAt: record.recordedAt }) : task; });
3391
- return __assign(__assign({}, bundle), { supportV5MicrotaskLedger: ledger, supportV5MicrotaskUsageHistory: __spreadArray(__spreadArray([], __read((bundle.supportV5MicrotaskUsageHistory || [])), false), [
3392
- record
3393
- ], false).slice(-200) });
3394
- }
3395
- function decideResolveIOSupportV5Continuation(bundle) {
3396
- var history = bundle.supportV5StepHistory || [];
3397
- var budget = buildResolveIOSupportV5Budget(bundle.supportV5Budget);
3398
- var last = history[history.length - 1];
3399
- var activeMicrotaskId = cleanText(bundle.supportV5ActiveMicrotaskId, 160);
3400
- var blockerFingerprint = fingerprintResolveIOSupportV5Blocker((last === null || last === void 0 ? void 0 : last.blocker) || (last === null || last === void 0 ? void 0 : last.summary) || '');
3401
- var repeatedNoProgressCount = 0;
3402
- for (var index = history.length - 1; index >= 0; index -= 1) {
3403
- var item = history[index];
3404
- if (activeMicrotaskId && cleanText(item.microtaskId, 160) !== activeMicrotaskId) {
3405
- continue;
3406
- }
3407
- if (item.outcome === 'pass' || item.outcome === 'ready_for_merge') {
3408
- break;
3409
- }
3410
- if (item.stepType !== (last === null || last === void 0 ? void 0 : last.stepType)) {
3411
- break;
3412
- }
3413
- if (fingerprintResolveIOSupportV5Blocker(item.blocker || item.summary || '') === blockerFingerprint) {
3414
- repeatedNoProgressCount += 1;
3415
- }
3416
- }
3417
- var budgetExceeded = budget.loopCount >= budget.maxLoopsPerTicket
3418
- || ((last === null || last === void 0 ? void 0 : last.promptTokenEstimate) || 0) > budget.maxPromptTokensPerNonInitialStep;
3419
- var repeatedFailure = last ? decideResolveIOSupportV5RepeatedFailureStop({
3420
- history: history,
3421
- failureClass: last.failureClass,
3422
- blocker: last.blocker || last.summary,
3423
- evidenceHash: last.evidenceHash,
3424
- changedFiles: last.changedFiles,
3425
- artifactPaths: last.artifactPaths,
3426
- limit: budget.maxRepeatedNoProgress,
3427
- ignoreInfra: true
3428
- }) : null;
3429
- var recoveryPlanFor = function (action, reason, extra) {
3430
- if (extra === void 0) { extra = {}; }
3431
- return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryPlan)(__assign({ action: action, reason: reason, failureClass: last === null || last === void 0 ? void 0 : last.failureClass, lane: (last === null || last === void 0 ? void 0 : last.lane) || 'supervisor', stepType: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.supportV5SupervisorState.activeStep, blocker: (last === null || last === void 0 ? void 0 : last.blocker) || (last === null || last === void 0 ? void 0 : last.summary), changedFiles: last === null || last === void 0 ? void 0 : last.changedFiles, artifactPaths: last === null || last === void 0 ? void 0 : last.artifactPaths, maxSameFailureRepeats: budget.maxRepeatedNoProgress }, extra));
3432
- };
3433
- var recoveryCheckpointFor = function (recoveryPlan) { return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryCheckpoint)({
3434
- plan: recoveryPlan,
3435
- current: last
3436
- }); };
3437
- var recoveryFieldsFor = function (recoveryPlan) {
3438
- var recoveryCheckpoint = recoveryCheckpointFor(recoveryPlan);
3439
- var recoveryEvidenceProbe = (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryEvidenceProbe)({
3440
- checkpoint: recoveryCheckpoint,
3441
- current: last
3442
- });
3443
- return {
3444
- recoveryPlan: recoveryPlan,
3445
- recoveryCheckpoint: recoveryCheckpoint,
3446
- recoveryEvidenceProbe: recoveryEvidenceProbe,
3447
- recoveryAction: (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryActionPacket)({
3448
- plan: recoveryPlan,
3449
- checkpoint: recoveryCheckpoint,
3450
- probe: recoveryEvidenceProbe,
3451
- current: last
3452
- })
3453
- };
3454
- };
3455
- if (budgetExceeded) {
3456
- var recoveryPlan_6 = recoveryPlanFor('manual_handoff', 'support_v5_budget_guard', {
3457
- productRepairFailure: false
3458
- });
3459
- return __assign({ action: 'park', reason: 'support_v5_budget_guard', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'cleanup', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_6));
3460
- }
3461
- var lastFailureClass = cleanText(last === null || last === void 0 ? void 0 : last.failureClass, 80).toLowerCase();
3462
- var materialEvidenceRetryAllowed = (repeatedFailure === null || repeatedFailure === void 0 ? void 0 : repeatedFailure.shouldStop) === false
3463
- && repeatedFailure.newEvidence === true
3464
- && repeatedFailure.materialEvidence === true;
3465
- if (repeatedNoProgressCount > budget.maxRepeatedNoProgress && /^(infra|compile)$/.test(lastFailureClass)) {
3466
- var recoveryPlan_7 = recoveryPlanFor('retry_infra', 'support_v5_infra_or_compile_repair_required', {
3467
- failureClass: lastFailureClass,
3468
- productRepairFailure: false
3469
- });
3470
- return __assign({ action: 'continue', reason: 'support_v5_infra_or_compile_repair_required', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'compile_check', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_7));
3471
- }
3472
- if (repeatedFailure === null || repeatedFailure === void 0 ? void 0 : repeatedFailure.shouldStop) {
3473
- var recoveryPlan_8 = recoveryPlanFor(repeatedFailure.reason === 'support_v5_ping_pong_failure_loop' ? 'park_ping_pong' : 'park_repeated_failure', repeatedFailure.reason, {
3474
- failureClass: repeatedFailure.failureClass,
3475
- productRepairFailure: true
3476
- });
3477
- return __assign({ action: 'park', reason: repeatedFailure.reason, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'cleanup', repeatedNoProgressCount: repeatedFailure.repeatedCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_8));
3478
- }
3479
- if (repeatedNoProgressCount > budget.maxRepeatedNoProgress && !materialEvidenceRetryAllowed) {
3480
- var recoveryPlan_9 = recoveryPlanFor('park_repeated_failure', 'support_v5_repeated_no_progress', {
3481
- productRepairFailure: true
3482
- });
3483
- return __assign({ action: 'park', reason: 'support_v5_repeated_no_progress', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'cleanup', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_9));
3484
- }
3485
- var recoveryPlan = recoveryPlanFor('continue', 'support_v5_continue');
3486
- return __assign({ action: 'continue', reason: 'support_v5_continue', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.supportV5SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan));
3487
- }
3488
- function decideResolveIOSupportV5AutonomousNextAction(input) {
3489
- var _a, _b, _c, _d, _e, _f, _g, _h;
3490
- var bundle = input.bundle;
3491
- var preflightGate = evaluateResolveIOSupportPreflightGate(input.preflightGate || bundle.supportV5PreflightGate, input.now);
3492
- var activeMicrotask = selectResolveIOSupportV5ActiveMicrotask(bundle.supportV5MicrotaskLedger || [], bundle.supportV5ActiveMicrotaskId);
3493
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(bundle.supportV5DiagnosisGate, {
3494
- maxOwnerFiles: input.maxOwnerFiles
3495
- });
3496
- var activeStepType = cleanText((activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) || (!diagnosisValidation.valid ? bundle.supportV5SupervisorState.activeStep : 'cleanup') || 'diagnosis_gate', 80);
3497
- var repairGate = decideResolveIOSupportV5RepairGate({
3498
- diagnosisGate: bundle.supportV5DiagnosisGate,
3499
- preflightGate: preflightGate,
3500
- activeStepType: activeStepType,
3501
- changedFiles: input.changedFiles,
3502
- failureClass: input.failureClass,
3503
- blocker: input.blocker,
3504
- evidence: input.evidence,
3505
- evidenceHash: input.evidenceHash,
3506
- history: bundle.supportV5StepHistory,
3507
- artifactPaths: input.artifactPaths,
3508
- maxOwnerFiles: input.maxOwnerFiles,
3509
- allowTestsOutsideOwnerFiles: true
3510
- });
3511
- var continuation = decideResolveIOSupportV5Continuation(bundle);
3512
- var customerReplyPolicy = decideResolveIOSupportCustomerReplyPolicy({
3513
- diagnosisGate: bundle.supportV5DiagnosisGate,
3514
- issueClassProbePlan: bundle.supportV5IssueClassProbePlan,
3515
- outcomeLabel: input.outcomeLabel,
3516
- confidence: input.confidence,
3517
- businessAssertionStatus: input.businessAssertionStatus,
3518
- businessAssertions: input.businessAssertions,
3519
- businessProofArtifacts: input.businessProofArtifacts,
3520
- previousProofFingerprint: input.previousProofFingerprint,
3521
- previousArtifactFingerprint: input.previousArtifactFingerprint,
3522
- unresolvedBlockers: input.unresolvedBlockers,
3523
- releaseStatus: input.releaseStatus,
3524
- hotfixEvidence: input.hotfixEvidence,
3525
- releasePolicy: input.releasePolicy,
3526
- releaseGatePassed: input.releaseGatePassed
3527
- });
3528
- var businessProofReadiness = evaluateResolveIOSupportBusinessProofReadiness({
3529
- diagnosisGate: bundle.supportV5DiagnosisGate,
3530
- outcomeLabel: input.outcomeLabel,
3531
- businessAssertionStatus: input.businessAssertionStatus,
3532
- businessAssertions: input.businessAssertions,
3533
- businessProofArtifacts: input.businessProofArtifacts,
3534
- previousProofFingerprint: input.previousProofFingerprint,
3535
- previousArtifactFingerprint: input.previousArtifactFingerprint
3536
- });
3537
- var evidenceFreshness = evaluateResolveIOSupportEvidenceFreshness({
3538
- history: bundle.supportV5StepHistory,
3539
- failureClass: input.failureClass,
3540
- blocker: input.blocker,
3541
- evidence: input.evidence,
3542
- evidenceHash: input.evidenceHash,
3543
- changedFiles: input.changedFiles,
3544
- artifactPaths: input.artifactPaths || input.businessProofArtifacts,
3545
- lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'supervisor',
3546
- stepType: activeStepType,
3547
- limit: buildResolveIOSupportV5Budget(bundle.supportV5Budget).maxRepeatedNoProgress,
3548
- ignoreInfra: true
3549
- });
3550
- var ownerFiles = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || repairGate.ownerFiles || [];
3551
- var proofContract = (_b = diagnosisValidation.normalized) === null || _b === void 0 ? void 0 : _b.proof_plan.business_proof_contract;
3552
- var expectedProof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion)
3553
- || ((_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.proof_plan.business_assertion)
3554
- || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.acceptanceProof)
3555
- || '';
3556
- var issueClassProbes = diagnosisValidation.valid && diagnosisValidation.normalized
3557
- ? buildResolveIOSupportIssueClassProbes(diagnosisValidation.normalized)
3558
- : [];
3559
- var generatedProbePlan = diagnosisValidation.valid && diagnosisValidation.normalized
3560
- ? buildResolveIOSupportIssueClassProbePlan(diagnosisValidation.normalized, input.now)
3561
- : undefined;
3562
- var storedProbePlanValidation = validateResolveIOSupportIssueClassProbePlan(bundle.supportV5IssueClassProbePlan, diagnosisValidation.normalized, input.now);
3563
- var issueClassProbePlanValidation = storedProbePlanValidation.valid
3564
- ? storedProbePlanValidation
3565
- : validateResolveIOSupportIssueClassProbePlan(generatedProbePlan, diagnosisValidation.normalized, input.now);
3566
- var issueClassProbePlan = issueClassProbePlanValidation.normalized || generatedProbePlan;
3567
- var activeIssueClassProbe = issueClassProbePlanValidation.activeProbe || (issueClassProbePlan === null || issueClassProbePlan === void 0 ? void 0 : issueClassProbePlan.activeProbe) || issueClassProbes[0];
3568
- var issueClassProbeEvidence = activeIssueClassProbe
3569
- ? Array.from(new Set(__spreadArray([
3570
- "IssueClassProbePlan ".concat((issueClassProbePlan === null || issueClassProbePlan === void 0 ? void 0 : issueClassProbePlan.planId) || 'generated', " status=").concat(issueClassProbePlanValidation.status),
3571
- "AIQaBusinessAssertion mapped to ".concat(activeIssueClassProbe.issue_class),
3572
- "state transition: ".concat(activeIssueClassProbe.state_transition.before || 'before', " -> ").concat(activeIssueClassProbe.state_transition.action || activeIssueClassProbe.action, " -> ").concat(activeIssueClassProbe.state_transition.after || 'after')
3573
- ], __read(activeIssueClassProbe.required_artifacts.map(function (artifact) { return "artifact: ".concat(artifact); })), false)))
3574
- : [];
3575
- var buildRootCauseReadiness = function (action, reason, fields, primaryCommand, nextCommands, blockers) {
3576
- var _a;
3577
- var statusByAction = {
3578
- run_diagnosis_gate: 'diagnosis_required',
3579
- ask_customer_clarification: 'customer_clarification_required',
3580
- repair_infra_only: 'infra_repair_only',
3581
- revise_diagnosis_scope: 'scope_revision_required',
3582
- run_owner_scoped_repair: 'owner_scoped_repair_ready',
3583
- run_business_proof_qa: 'business_proof_required',
3584
- repair_release_hotfix_first: 'release_hotfix_required',
3585
- collect_new_evidence: 'collect_new_evidence',
3586
- draft_customer_reply: 'customer_reply_draft_ready',
3587
- ready_for_release_gate: 'release_gate_ready',
3588
- park_manual: 'parked'
3589
- };
3590
- var nextGateByStatus = {
3591
- diagnosis_required: 'diagnosis',
3592
- customer_clarification_required: 'customer_reply',
3593
- infra_repair_only: 'infra',
3594
- scope_revision_required: 'scope',
3595
- owner_scoped_repair_ready: 'repair',
3596
- business_proof_required: 'business_proof',
3597
- release_hotfix_required: 'release',
3598
- release_gate_ready: 'release',
3599
- customer_reply_draft_ready: 'customer_reply',
3600
- collect_new_evidence: 'evidence',
3601
- parked: 'manual'
3602
- };
3603
- var status = statusByAction[action] || 'parked';
3604
- var diagnosisValid = diagnosisValidation.valid === true;
3605
- var ownerFilesReady = diagnosisValid && ownerFiles.length > 0;
3606
- var proofPlanReady = diagnosisValid && !!proofContract;
3607
- var issueClassProbePlanReady = issueClassProbePlanValidation.valid === true;
3608
- var preflightReady = preflightGate.blocksProductRepair !== true;
3609
- var rootCauseFirstSatisfied = diagnosisValid && ownerFilesReady && proofPlanReady && issueClassProbePlanReady && preflightReady;
3610
- var sameFailureParked = evidenceFreshness.mustCollectNewEvidence === true
3611
- || (action === 'collect_new_evidence' && /repeated|no_progress|ping_pong|same failure|same evidence/i.test(reason));
3612
- return {
3613
- status: status,
3614
- nextGate: nextGateByStatus[status],
3615
- nextCommand: primaryCommand || nextCommands[0] || action,
3616
- rootCauseFirstSatisfied: rootCauseFirstSatisfied,
3617
- diagnosisValid: diagnosisValid,
3618
- ownerFilesReady: ownerFilesReady,
3619
- proofPlanReady: proofPlanReady,
3620
- businessProofReady: businessProofReadiness.ready === true,
3621
- infraOnly: action === 'repair_infra_only',
3622
- sameFailureParked: sameFailureParked,
3623
- canEditProductCode: fields.canEditProductCode === true && rootCauseFirstSatisfied,
3624
- canRunIssueClassProbe: rootCauseFirstSatisfied && (action === 'run_business_proof_qa' || status === 'business_proof_required'),
3625
- canRunBusinessProofQa: rootCauseFirstSatisfied && (action === 'run_business_proof_qa' || !businessProofReadiness.ready),
3626
- canRelease: action === 'ready_for_release_gate' && businessProofReadiness.ready === true,
3627
- canDraftCustomerReply: (action === 'draft_customer_reply' && businessProofReadiness.ready === true)
3628
- || action === 'ask_customer_clarification',
3629
- requiresHumanDecision: action === 'park_manual' || fields.canRunAutonomously !== true,
3630
- issueClassProbePlanReady: issueClassProbePlanReady,
3631
- preflightReady: preflightReady,
3632
- preflightStatus: preflightGate.status,
3633
- preflightFailureClass: preflightGate.failureClass,
3634
- reason: reason,
3635
- blockers: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(blockers), false), __read(issueClassProbePlanValidation.blockers), false), __read(preflightGate.blockers), false))),
3636
- ownerFiles: ownerFiles,
3637
- issueClass: ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.issue_class) || repairGate.issueClass,
3638
- expectedProof: expectedProof,
3639
- issueClassProbes: issueClassProbes,
3640
- issueClassProbePlan: issueClassProbePlan,
3641
- businessProofStatus: businessProofReadiness.status,
3642
- proofFingerprint: businessProofReadiness.proofFingerprint,
3643
- artifactFingerprint: businessProofReadiness.artifactFingerprint,
3644
- proofFreshness: businessProofReadiness.proofFreshness,
3645
- preflightGate: preflightGate
3646
- };
3647
- };
3648
- var nextActionExpectedTransition = function (action, primaryCommand) {
3649
- if (action === 'run_diagnosis_gate') {
3650
- return 'SupportDiagnosisGate changes from missing/incomplete to passed, blocked with one clarification question, or rejected with explicit blockers; no source files are edited.';
3651
- }
3652
- if (action === 'ask_customer_clarification') {
3653
- return 'One customer clarification question is prepared for human review and the ticket parks until the missing reproduction/account context is supplied.';
3654
- }
3655
- if (action === 'repair_infra_only') {
3656
- return 'Infra/preflight evidence changes or passes without charging the failure as product-code repair.';
3657
- }
3658
- if (action === 'revise_diagnosis_scope') {
3659
- return 'SupportDiagnosisGate owner_files, failing_path, and proof_plan are revised together with new evidence before any broader edit.';
3660
- }
3661
- if (action === 'run_owner_scoped_repair') {
3662
- return 'Only diagnosis owner_files change, a compile/unit gate is recorded, and the next state is business proof QA rather than acceptance.';
3663
- }
3664
- if (action === 'run_business_proof_qa') {
3665
- return 'A fresh AIQaBusinessAssertion maps to the validated IssueClassProbePlan and records before/action/after DOM, data, or Mongo proof.';
3666
- }
3667
- if (action === 'repair_release_hotfix_first') {
3668
- return primaryCommand === 'record_hotfix_evidence'
3669
- ? 'Hotfix evidence is recorded with sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus before any live backend apply or continuation.'
3670
- : 'The smallest release/hotfix gate changes state, with duplicate full deploy blocked unless force evidence is explicit.';
3671
- }
3672
- if (action === 'ready_for_release_gate') {
3673
- return 'Release gate records compile, business proof, and deployment readiness without treating route-only evidence as acceptance.';
3674
- }
3675
- if (action === 'draft_customer_reply') {
3676
- return 'A customer resolution draft is prepared from accepted business proof and remains unsent until human approval.';
3677
- }
3678
- if (action === 'collect_new_evidence') {
3679
- return 'The next run records a changed blocker fingerprint, changed evidence hash, fresh artifact path, or explicit business/infra/compile/release proof.';
3680
- }
3681
- return 'The runner stays parked until a human changes scope, budget, evidence, or autonomy policy.';
3682
- };
3683
- var buildNextActionContract = function (action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers) {
3684
- var lane = (fields.lane || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'supervisor');
3685
- var stepType = (fields.stepType || activeStepType);
3686
- var liveHotfixBlockedUntilCommit = fields.liveHotfixBlockedUntilCommit === true;
3687
- var hotfixCommitRequired = action === 'repair_release_hotfix_first'
3688
- || liveHotfixBlockedUntilCommit
3689
- || fields.canHotfixBackend === true;
3690
- var requiresHumanApproval = action === 'park_manual'
3691
- || action === 'ask_customer_clarification'
3692
- || rootCauseReadiness.requiresHumanDecision === true;
3693
- var safeToAutoRun = fields.canRunAutonomously === true
3694
- && !requiresHumanApproval
3695
- && (action !== 'run_owner_scoped_repair' || (rootCauseReadiness.rootCauseFirstSatisfied === true && evidenceFreshness.mustCollectNewEvidence !== true))
3696
- && (action !== 'run_business_proof_qa' || rootCauseReadiness.issueClassProbePlanReady === true)
3697
- && (action !== 'repair_release_hotfix_first' || primaryCommand !== 'apply_backend_hotfix_only_after_commit_proof' || liveHotfixBlockedUntilCommit !== true);
3698
- var costRisk = requiresHumanApproval
3699
- ? 'manual_blocked'
3700
- : (fields.canHotfixBackend === true || action === 'draft_customer_reply')
3701
- ? 'release_or_customer_send'
3702
- : fields.canRunModel === true
3703
- ? 'expensive_model'
3704
- : fields.canRunQa === true
3705
- ? 'small_model_or_qa'
3706
- : 'free_or_deterministic';
3707
- var canRunWithoutCodexMonitor = safeToAutoRun
3708
- && continuationProofCheckpoint.required === true
3709
- && forbiddenActions.length > 0
3710
- && (requiredEvidence.length > 0 || action === 'repair_infra_only' || action === 'run_diagnosis_gate');
3711
- var codexFallbackRequired = !canRunWithoutCodexMonitor && !requiresHumanApproval;
3712
- var codexFallbackReason = codexFallbackRequired
3713
- ? (blockers[0] || continuationProofCheckpoint.reason || 'next_action_contract_missing_required_evidence')
3714
- : requiresHumanApproval
3715
- ? 'human_decision_required_not_codex_fallback'
3716
- : !canRunWithoutCodexMonitor
3717
- ? 'structured_contract_blocks_auto_run_without_requesting_codex_monitor'
3718
- : 'structured_next_action_contract_allows_manager_execution_without_external_codex_monitor';
3719
- var preconditions = Array.from(new Set(__spreadArray([
3720
- action !== 'run_diagnosis_gate' ? 'SupportDiagnosisGate validation checked before action.' : 'Diagnosis is read-only and cannot edit source files.',
3721
- action === 'run_owner_scoped_repair' ? 'Root-cause-first gate is satisfied and owner_files are the only editable product files.' : '',
3722
- action === 'run_business_proof_qa' ? 'Business proof QA must use the diagnosis proof_plan and validated IssueClassProbePlan.' : '',
3723
- action === 'repair_release_hotfix_first' ? 'Live backend hotfix is blocked until GitHub commit proof is recorded and passed.' : '',
3724
- evidenceFreshness.mustCollectNewEvidence === true ? 'Current failure is stale or repeated; only evidence collection is allowed until proof changes.' : ''
3725
- ], __read(requiredEvidence), false).filter(Boolean))).slice(0, 24);
3726
- var stopConditions = Array.from(new Set(__spreadArray([
3727
- 'Stop if the same failure class, blocker fingerprint, and evidence hash repeat without material evidence.',
3728
- 'Stop if the action would edit outside diagnosis owner_files without a revised diagnosis gate.',
3729
- 'Stop if route-load, screenshot-only, scorecard-only, or model-claim proof is the only acceptance evidence.',
3730
- liveHotfixBlockedUntilCommit ? 'Stop before live backend hotfix until sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus are recorded.' : ''
3731
- ], __read(continuationProofCheckpoint.requiredResetEvidence.map(function (entry) { return "Reset requires: ".concat(entry); })), false).filter(Boolean))).slice(0, 24);
3732
- var createdAt = isoNow(input.now);
3733
- return {
3734
- contractId: "support-next-action-".concat(hashResolveIOSupportV5Evidence({
3735
- action: action,
3736
- primaryCommand: primaryCommand,
3737
- reason: reason,
3738
- blockers: blockers,
3739
- requiredEvidence: requiredEvidence,
3740
- evidenceFreshness: evidenceFreshness.evidenceHash,
3741
- blockerFingerprint: evidenceFreshness.blockerFingerprint,
3742
- createdAt: createdAt.slice(0, 16)
3743
- }).slice(0, 16)),
3744
- action: action,
3745
- label: label,
3746
- primaryCommand: primaryCommand,
3747
- lane: lane,
3748
- stepType: stepType,
3749
- safeToAutoRun: safeToAutoRun,
3750
- requiresHumanApproval: requiresHumanApproval,
3751
- canRunWithoutCodexMonitor: canRunWithoutCodexMonitor,
3752
- codexFallbackRequired: codexFallbackRequired,
3753
- codexFallbackReason: codexFallbackReason,
3754
- costRisk: costRisk,
3755
- rootCauseFirstSatisfied: rootCauseReadiness.rootCauseFirstSatisfied === true,
3756
- decisionBasis: {
3757
- diagnosisValid: rootCauseReadiness.diagnosisValid === true,
3758
- ownerFilesReady: rootCauseReadiness.ownerFilesReady === true,
3759
- proofPlanReady: rootCauseReadiness.proofPlanReady === true,
3760
- businessProofReady: businessProofReadiness.ready === true,
3761
- evidenceFreshnessStatus: evidenceFreshness.status,
3762
- evidenceStrength: evidenceFreshness.evidenceStrength,
3763
- failureClass: evidenceFreshness.failureClass,
3764
- blockerFingerprint: evidenceFreshness.blockerFingerprint,
3765
- evidenceHash: evidenceFreshness.evidenceHash,
3766
- sameFailureCount: evidenceFreshness.sameFailureCount,
3767
- issueClassProbePlanReady: rootCauseReadiness.issueClassProbePlanReady === true,
3768
- preflightReady: rootCauseReadiness.preflightReady === true,
3769
- preflightStatus: preflightGate.status,
3770
- preflightFailureClass: preflightGate.failureClass,
3771
- preflightEvidenceHash: preflightGate.evidenceHash,
3772
- hotfixCommitRequired: hotfixCommitRequired,
3773
- liveHotfixBlockedUntilCommit: liveHotfixBlockedUntilCommit
3774
- },
3775
- preconditions: preconditions,
3776
- expectedStateTransition: nextActionExpectedTransition(action, primaryCommand),
3777
- successEvidence: Array.from(new Set(requiredEvidence.length ? requiredEvidence : continuationProofCheckpoint.requiredEvidence)).slice(0, 24),
3778
- stopConditions: stopConditions,
3779
- forbiddenActions: forbiddenActions.slice(0, 24),
3780
- ownerFiles: ownerFiles.slice(0, 24),
3781
- blockers: blockers.slice(0, 24),
3782
- nextCommands: nextCommands.slice(0, 24),
3783
- createdAt: createdAt
3784
- };
3785
- };
3786
- var buildHumanDecisionRequest = function (action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, nextActionContract, requiredEvidence, blockers) {
3787
- var repeatedEvidenceBlocked = evidenceFreshness.mustCollectNewEvidence === true
3788
- || rootCauseReadiness.sameFailureParked === true
3789
- || continuationProofCheckpoint.status === 'waiting_for_new_evidence';
3790
- var manualApprovalRequired = action === 'park_manual'
3791
- || action === 'ask_customer_clarification'
3792
- || nextActionContract.requiresHumanApproval === true
3793
- || fields.canRunAutonomously !== true;
3794
- if (!repeatedEvidenceBlocked && !manualApprovalRequired) {
3795
- return undefined;
3796
- }
3797
- var createdAt = isoNow(input.now);
3798
- var autoDispatchAllowed = repeatedEvidenceBlocked
3799
- && action === 'collect_new_evidence'
3800
- && nextActionContract.safeToAutoRun === true
3801
- && nextActionContract.canRunWithoutCodexMonitor === true;
3802
- var preferredChoiceId = autoDispatchAllowed
3803
- ? 'run_bounded_evidence_probe'
3804
- : action === 'ask_customer_clarification'
3805
- ? 'review_customer_clarification'
3806
- : action === 'run_diagnosis_gate' || action === 'revise_diagnosis_scope'
3807
- ? 'revise_diagnosis_gate'
3808
- : 'keep_parked';
3809
- var baseRequiredEvidence = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(requiredEvidence), false), __read(continuationProofCheckpoint.requiredResetEvidence), false), __read(evidenceFreshness.requiredResetEvidence), false).filter(Boolean))).slice(0, 20);
3810
- var choices = [];
3811
- if (repeatedEvidenceBlocked) {
3812
- choices.push({
3813
- choiceId: 'run_bounded_evidence_probe',
3814
- label: 'Run Evidence Probe',
3815
- action: 'collect_new_evidence',
3816
- description: 'Collect changed issue-specific evidence only; product-code repair remains blocked until blockerFingerprint, evidenceHash, or business proof changes.',
3817
- safety: 'low',
3818
- requiresConfirmation: false,
3819
- nextCommand: nextActionContract.primaryCommand || 'run_support_v5_recovery_evidence_probe',
3820
- expectedResult: nextActionExpectedTransition('collect_new_evidence', nextActionContract.primaryCommand || 'run_support_v5_recovery_evidence_probe'),
3821
- allowedWithoutCodexMonitor: autoDispatchAllowed
3822
- });
3823
- }
3824
- choices.push({
3825
- choiceId: 'revise_diagnosis_gate',
3826
- label: 'Revise Diagnosis',
3827
- action: 'run_diagnosis_gate',
3828
- description: 'Re-run read-only root-cause diagnosis with the new evidence and update owner files/proof plan before any repair loop.',
3829
- safety: 'low',
3830
- requiresConfirmation: repeatedEvidenceBlocked === false,
3831
- nextCommand: 'revise_support_diagnosis_gate_with_new_evidence',
3832
- expectedResult: nextActionExpectedTransition('run_diagnosis_gate', 'revise_support_diagnosis_gate_with_new_evidence'),
3833
- allowedWithoutCodexMonitor: false
3834
- });
3835
- if (action === 'ask_customer_clarification') {
3836
- choices.push({
3837
- choiceId: 'review_customer_clarification',
3838
- label: 'Review Clarification',
3839
- action: 'ask_customer_clarification',
3840
- description: 'Review the one customer question before any send action; no product-code repair is allowed from guessed context.',
3841
- safety: 'medium',
3842
- requiresConfirmation: true,
3843
- nextCommand: nextActionContract.primaryCommand || 'review_customer_clarification',
3844
- expectedResult: nextActionExpectedTransition('ask_customer_clarification', nextActionContract.primaryCommand || 'review_customer_clarification'),
3845
- allowedWithoutCodexMonitor: false
3846
- });
3847
- }
3848
- choices.push({
3849
- choiceId: 'keep_parked',
3850
- label: 'Keep Parked',
3851
- action: 'park_manual',
3852
- description: 'Do not spend more model, QA, release, or customer-send budget until new evidence, scope, budget, or approval changes.',
3853
- safety: 'low',
3854
- requiresConfirmation: false,
3855
- nextCommand: 'park_support_ticket_until_new_evidence',
3856
- expectedResult: 'The support runner stays parked and records the blocker as waiting for an operator decision or fresh evidence.',
3857
- allowedWithoutCodexMonitor: true
3858
- });
3859
- var blockedUntil = Array.from(new Set(__spreadArray(__spreadArray([], __read(baseRequiredEvidence), false), [
3860
- repeatedEvidenceBlocked ? 'blockerFingerprint changes from the starting repeated blocker' : '',
3861
- repeatedEvidenceBlocked ? 'evidenceHash changes from the starting repeated evidence hash' : '',
3862
- repeatedEvidenceBlocked ? 'fresh AIQaBusinessAssertion, infra/compile proof, release proof, or artifact path is attached' : '',
3863
- action === 'park_manual' ? 'operator changes scope, budget, autonomy policy, or approval' : ''
3864
- ], false).filter(Boolean))).slice(0, 16);
3865
- return {
3866
- requestId: "support-human-decision-".concat(hashResolveIOSupportV5Evidence({
3867
- action: action,
3868
- label: label,
3869
- reason: reason,
3870
- preferredChoiceId: preferredChoiceId,
3871
- failureClass: evidenceFreshness.failureClass,
3872
- blockerFingerprint: evidenceFreshness.blockerFingerprint,
3873
- evidenceHash: evidenceFreshness.evidenceHash,
3874
- createdAt: createdAt.slice(0, 16)
3875
- }).slice(0, 16)),
3876
- required: true,
3877
- status: autoDispatchAllowed ? 'auto_dispatch_allowed' : 'waiting_for_operator',
3878
- reason: repeatedEvidenceBlocked
3879
- ? "".concat(reason, " Same failure evidence repeated; repair is blocked until new evidence changes the proof state.")
3880
- : reason,
3881
- question: repeatedEvidenceBlocked
3882
- ? 'Same blocker/evidence repeated. Run one bounded evidence probe, revise diagnosis with new facts, or keep the ticket parked?'
3883
- : action === 'ask_customer_clarification'
3884
- ? 'Customer context is missing. Review the clarification question or keep the ticket parked?'
3885
- : "Human approval is required for ".concat(label, ". What should the runner do next?"),
3886
- preferredChoiceId: preferredChoiceId,
3887
- evidence: {
3888
- failureClass: evidenceFreshness.failureClass,
3889
- blocker: cleanText(blockers[0] || reason, 1000),
3890
- blockerFingerprint: evidenceFreshness.blockerFingerprint,
3891
- evidenceHash: evidenceFreshness.evidenceHash,
3892
- sameFailureCount: evidenceFreshness.sameFailureCount,
3893
- pingPongCount: evidenceFreshness.pingPongCount,
3894
- evidenceStrength: evidenceFreshness.evidenceStrength,
3895
- requiredResetEvidence: baseRequiredEvidence,
3896
- recentArtifactPaths: evidenceFreshness.artifactPaths.slice(0, 20),
3897
- changedFiles: evidenceFreshness.changedFiles.slice(0, 20),
3898
- nextActionContractId: nextActionContract.contractId
3899
- },
3900
- choices: choices
3901
- .filter(function (choice, index, source) { return source.findIndex(function (candidate) { return candidate.choiceId === choice.choiceId; }) === index; })
3902
- .slice(0, 6),
3903
- blockedUntil: blockedUntil,
3904
- autoDispatchAllowed: autoDispatchAllowed,
3905
- createdAt: createdAt
3906
- };
3907
- };
3908
- var makeDecision = function (action, label, reason, fields) {
3909
- var _a;
3910
- var primaryCommand = fields.primaryCommand || action;
3911
- var nextCommands = fields.nextCommands || [primaryCommand];
3912
- var requiredEvidence = fields.requiredEvidence || [];
3913
- var blockers = fields.blockers || [];
3914
- var rootCauseReadiness = buildRootCauseReadiness(action, reason, fields, primaryCommand, nextCommands, blockers);
3915
- var forbiddenActions = Array.from(new Set(__spreadArray([
3916
- 'Do not send customer email without explicit human approval.',
3917
- 'Do not broaden owner_files without revised diagnosis evidence.',
3918
- 'Do not accept route-load, screenshot-only, scorecard-only, or model-claim proof.'
3919
- ], __read((fields.forbiddenActions || [])), false)));
3920
- var continuationProofCheckpoint = buildResolveIOSupportContinuationProofCheckpoint({
3921
- action: action,
3922
- reason: reason,
3923
- evidenceFreshness: evidenceFreshness,
3924
- requiredEvidence: requiredEvidence,
3925
- requiredResetEvidence: fields.requiredEvidence,
3926
- blocksProductRepair: evidenceFreshness.mustCollectNewEvidence === true
3927
- });
3928
- var nextActionContract = buildNextActionContract(action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, primaryCommand, nextCommands, requiredEvidence, forbiddenActions, blockers);
3929
- var humanReviewPacket = fields.humanReviewPacket
3930
- || (action === 'draft_customer_reply' && customerReplyPolicy.humanReviewPacket ? customerReplyPolicy.humanReviewPacket : undefined)
3931
- || buildResolveIOSupportHumanReviewPacket({
3932
- reviewType: supportAutonomousReviewTypeForAction(action),
3933
- title: label,
3934
- summary: reason,
3935
- primaryAction: primaryCommand,
3936
- customerFacingDraftAllowed: fields.canDraftCustomerReply === true,
3937
- safety: action === 'draft_customer_reply' ? 'safe_to_draft' : 'internal_hold',
3938
- reason: reason,
3939
- blockers: blockers,
3940
- requiredEvidence: requiredEvidence,
3941
- evidenceRefs: businessProofReadiness.artifactPaths,
3942
- nextCommands: nextCommands,
3943
- forbiddenActions: forbiddenActions,
3944
- costRisk: fields.canHotfixBackend === true || action === 'draft_customer_reply'
3945
- ? 'release_or_customer_send'
3946
- : fields.canRunModel === true
3947
- ? 'expensive_model'
3948
- : fields.canRunQa === true
3949
- ? 'small_model_or_qa'
3950
- : 'free_or_deterministic',
3951
- now: input.now
3952
- });
3953
- var humanDecisionRequest = buildHumanDecisionRequest(action, label, reason, fields, rootCauseReadiness, continuationProofCheckpoint, nextActionContract, requiredEvidence, blockers);
3954
- var customerReplyReadiness = customerReplyPolicy.readinessContract || buildResolveIOSupportCustomerReplyReadinessContract({
3955
- policy: customerReplyPolicy,
3956
- diagnosisValidation: diagnosisValidation,
3957
- issueClassProbePlanValidation: issueClassProbePlanValidation,
3958
- businessProofReadiness: businessProofReadiness
3959
- });
3960
- return {
3961
- action: action,
3962
- label: label,
3963
- reason: reason,
3964
- canRunAutonomously: fields.canRunAutonomously === true,
3965
- canEditProductCode: fields.canEditProductCode === true,
3966
- canRunModel: fields.canRunModel === true,
3967
- canRunQa: fields.canRunQa === true,
3968
- canPrepareHotfixPatch: fields.canPrepareHotfixPatch === true,
3969
- canHotfixBackend: fields.canHotfixBackend === true,
3970
- liveHotfixBlockedUntilCommit: fields.liveHotfixBlockedUntilCommit === true,
3971
- canDraftCustomerReply: fields.canDraftCustomerReply === true,
3972
- canSendCustomerReply: false,
3973
- lane: fields.lane || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'supervisor',
3974
- stepType: fields.stepType || activeStepType,
3975
- microtaskId: activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId,
3976
- primaryCommand: primaryCommand,
3977
- nextCommands: nextCommands,
3978
- requiredEvidence: requiredEvidence,
3979
- forbiddenActions: forbiddenActions,
3980
- blockers: blockers,
3981
- ownerFiles: ownerFiles,
3982
- issueClass: ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.issue_class) || repairGate.issueClass,
3983
- expectedProof: expectedProof,
3984
- issueClassProbes: issueClassProbes,
3985
- issueClassProbePlan: issueClassProbePlan,
3986
- issueClassProbePlanValidation: issueClassProbePlanValidation,
3987
- activeMicrotask: activeMicrotask,
3988
- diagnosisValidation: diagnosisValidation,
3989
- repairGate: repairGate,
3990
- continuation: continuation,
3991
- customerReplyPolicy: customerReplyPolicy,
3992
- customerReplyReadiness: customerReplyReadiness,
3993
- businessProofReadiness: businessProofReadiness,
3994
- evidenceFreshness: evidenceFreshness,
3995
- preflightGate: preflightGate,
3996
- rootCauseReadiness: rootCauseReadiness,
3997
- continuationProofCheckpoint: continuationProofCheckpoint,
3998
- nextActionContract: nextActionContract,
3999
- humanReviewPacket: humanReviewPacket,
4000
- humanDecisionRequest: humanDecisionRequest,
4001
- hotfixContinuation: fields.hotfixContinuation,
4002
- hotfixDurabilityContract: fields.hotfixDurabilityContract,
4003
- recordedAt: isoNow(input.now)
4004
- };
4005
- };
4006
- if (continuation.action === 'park' && continuation.reason === 'support_v5_budget_guard') {
4007
- return makeDecision('park_manual', 'Park Manual', continuation.reason, {
4008
- canRunAutonomously: false,
4009
- lane: 'supervisor',
4010
- stepType: 'cleanup',
4011
- primaryCommand: 'park_support_ticket_for_manual_budget_review',
4012
- requiredEvidence: ['budget summary', 'latest blocker', 'operator decision'],
4013
- blockers: ['Support V5 budget guard is active.']
4014
- });
4015
- }
4016
- if (continuation.action === 'park') {
4017
- return makeDecision('collect_new_evidence', 'Collect New Evidence', continuation.reason, {
4018
- canRunAutonomously: true,
4019
- canRunModel: false,
4020
- canRunQa: true,
4021
- lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'qa',
4022
- stepType: activeStepType,
4023
- primaryCommand: 'run_support_v5_recovery_evidence_probe',
4024
- nextCommands: continuation.recoveryAction.nextCommands,
4025
- requiredEvidence: continuation.recoveryAction.requiredArtifacts,
4026
- blockers: [continuation.reason],
4027
- forbiddenActions: ['Do not run another product-code repair until blockerFingerprint or evidenceHash changes.']
4028
- });
4029
- }
4030
- if (customerReplyPolicy.action === 'ask_clarification') {
4031
- return makeDecision('ask_customer_clarification', 'Ask Customer Clarification', customerReplyPolicy.reason, {
4032
- canRunAutonomously: false,
4033
- canRunModel: false,
4034
- canEditProductCode: false,
4035
- canDraftCustomerReply: true,
4036
- lane: 'customer',
4037
- stepType: 'customer_reply',
4038
- primaryCommand: ((_d = customerReplyPolicy.humanReviewPacket) === null || _d === void 0 ? void 0 : _d.primaryAction) || 'review_customer_clarification',
4039
- nextCommands: ((_e = customerReplyPolicy.humanReviewPacket) === null || _e === void 0 ? void 0 : _e.nextCommands) || ['edit_clarification_question', 'send_after_human_review', 'park_ticket_until_customer_reply'],
4040
- requiredEvidence: customerReplyPolicy.requiredEvidence,
4041
- blockers: diagnosisValidation.blockers,
4042
- forbiddenActions: [
4043
- 'Do not run repair from a guessed reproduction path.',
4044
- 'Do not send customer email without explicit human approval.'
4045
- ],
4046
- humanReviewPacket: customerReplyPolicy.humanReviewPacket
4047
- });
4048
- }
4049
- if (repairGate.action === 'diagnose_only' || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) === 'diagnosis_gate' || !diagnosisValidation.valid) {
4050
- return makeDecision('run_diagnosis_gate', 'Run Diagnosis Gate', 'support_v5_root_cause_first_required', {
4051
- canRunAutonomously: true,
4052
- canRunModel: true,
4053
- canEditProductCode: false,
4054
- lane: 'build',
4055
- stepType: 'diagnosis_gate',
4056
- primaryCommand: 'run_support_v5_read_only_diagnosis_gate',
4057
- nextCommands: ['retrieve_similar_tickets_and_commits', 'run_reproduction_or_classification_probe', 'write_support_diagnosis_gate_json'],
4058
- requiredEvidence: [
4059
- 'issue_case expected/observed/account context',
4060
- 'accepted falsifiable hypothesis',
4061
- 'rejected alternatives',
4062
- 'failing path',
4063
- 'small owner_files set',
4064
- 'before/action/after business proof plan'
4065
- ],
4066
- blockers: repairGate.blockers,
4067
- forbiddenActions: ['No source edits during diagnosis.']
4068
- });
4069
- }
4070
- if (repairGate.action === 'infra_repair_only') {
4071
- var compileOnly = repairGate.preflightGate.failureClass === 'compile' || input.failureClass === 'compile';
4072
- var preflightNextCommand = repairGate.preflightGate.nextCommand === 'continue_to_diagnosis'
4073
- ? undefined
4074
- : repairGate.preflightGate.nextCommand;
4075
- return makeDecision('repair_infra_only', compileOnly ? 'Repair Compile Only' : 'Repair Infra Only', 'support_v5_infra_failure_before_product_repair', {
4076
- canRunAutonomously: true,
4077
- canRunModel: false,
4078
- canEditProductCode: false,
4079
- canRunQa: true,
4080
- lane: 'qa',
4081
- stepType: activeStepType,
4082
- primaryCommand: preflightNextCommand || (compileOnly ? 'run_support_v5_compile_repair' : 'run_support_v5_infra_repair'),
4083
- nextCommands: Array.from(new Set([
4084
- preflightNextCommand || (compileOnly ? 'run_support_v5_compile_repair' : 'run_support_v5_infra_repair'),
4085
- 'rerun_puppeteer_compile_startup_preflight',
4086
- compileOnly ? 'repair_compile_or_cache_only' : 'repair_harness_or_cache_only',
4087
- 'record_infra_artifact'
4088
- ])),
4089
- requiredEvidence: repairGate.preflightGate.requiredEvidence.length
4090
- ? repairGate.preflightGate.requiredEvidence
4091
- : ['preflight log', 'compile/startup/browser status', 'new infra blocker hash or pass'],
4092
- blockers: repairGate.blockers,
4093
- forbiddenActions: ['Do not charge infra failures as product-code repair failures.']
4094
- });
4095
- }
4096
- if (repairGate.action === 'reject_out_of_scope') {
4097
- return makeDecision('revise_diagnosis_scope', 'Revise Diagnosis Scope', 'support_v5_owner_scope_block', {
4098
- canRunAutonomously: true,
4099
- canRunModel: true,
4100
- canEditProductCode: false,
4101
- lane: 'build',
4102
- stepType: 'diagnosis_gate',
4103
- primaryCommand: 'revise_support_diagnosis_gate_with_new_owner_file_evidence',
4104
- nextCommands: ['attach_out_of_scope_diff', 'prove_new_owner_file_is_required', 'update_support_diagnosis_gate'],
4105
- requiredEvidence: ['new root-cause evidence for each added owner file'],
4106
- blockers: repairGate.blockers,
4107
- forbiddenActions: ['Do not edit files outside owner_files before diagnosis is revised.']
4108
- });
4109
- }
4110
- if (repairGate.action === 'park_repeated_failure') {
4111
- return makeDecision('collect_new_evidence', 'Collect New Evidence', 'support_v5_repeated_failure_needs_new_evidence', {
4112
- canRunAutonomously: true,
4113
- canRunModel: false,
4114
- canRunQa: true,
4115
- lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'qa',
4116
- stepType: activeStepType,
4117
- primaryCommand: 'run_support_v5_recovery_evidence_probe',
4118
- nextCommands: repairGate.recoveryAction.nextCommands,
4119
- requiredEvidence: repairGate.recoveryAction.requiredArtifacts,
4120
- blockers: repairGate.blockers,
4121
- forbiddenActions: ['Do not run another repair loop until new material evidence exists.']
4122
- });
4123
- }
4124
- if (evidenceFreshness.mustCollectNewEvidence === true && repairGate.action === 'allow_product_repair') {
4125
- return makeDecision('collect_new_evidence', 'Collect New Evidence', 'support_v5_no_blind_loop_requires_changed_evidence', {
4126
- canRunAutonomously: true,
4127
- canRunModel: false,
4128
- canRunQa: true,
4129
- canEditProductCode: false,
4130
- lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'qa',
4131
- stepType: activeStepType,
4132
- primaryCommand: 'run_support_v5_recovery_evidence_probe',
4133
- nextCommands: ['execute_issue_class_probe', 'record_changed_blocker_or_business_proof', 'write_aiqa_business_assertion_or_blocker_artifact'],
4134
- requiredEvidence: evidenceFreshness.requiredResetEvidence.length
4135
- ? evidenceFreshness.requiredResetEvidence
4136
- : ['changed blockerFingerprint or evidenceHash', 'fresh issue-specific business proof artifact'],
4137
- blockers: [evidenceFreshness.reason || 'Repeated failure needs fresh evidence before owner-scoped repair.'],
4138
- forbiddenActions: ['Do not edit product code in this recovery; collect changed browser/data/business-proof evidence only.']
4139
- });
4140
- }
4141
- if (supportReleaseLooksBlocked(input.releaseStatus)) {
4142
- var releaseBlocker = cleanList(input.unresolvedBlockers, 20, 500).join('; ')
4143
- || cleanText(input.blocker || input.releaseStatus, 1000)
4144
- || 'Support release is blocked.';
4145
- var hotfixContinuation = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerHotfixContinuation)({
4146
- evidence: input.hotfixEvidence,
4147
- policy: input.releasePolicy,
4148
- releaseGatePassed: input.releaseGatePassed,
4149
- failureClass: 'release',
4150
- blocker: releaseBlocker,
4151
- now: input.now
4152
- });
4153
- var hotfixPrimaryCommandByAction = {
4154
- record_hotfix_evidence: 'record_hotfix_evidence',
4155
- request_force_deploy_reason: 'request_force_deploy_reason',
4156
- rerun_release_gate: 'rerun_support_release_gate_once',
4157
- continue_runner: 'continue_support_runner_after_committed_hotfix',
4158
- allow_one_full_deploy: 'execute_one_full_deploy_with_force_evidence',
4159
- park_manual: 'park_support_release_manual'
4160
- };
4161
- var hotfixNextCommands = Array.from(new Set(__spreadArray(__spreadArray([
4162
- 'classify_release_blocker',
4163
- 'prepare_hotfix_patch_without_live_apply',
4164
- 'commit_and_push_hotfix_to_github',
4165
- 'record_github_commit_for_hotfix'
4166
- ], __read(hotfixContinuation.nextCommands), false), [
4167
- 'apply_backend_hotfix_only_after_commit_proof',
4168
- 'rerun_release_gate_once'
4169
- ], false)));
4170
- var hotfixRequiredEvidence = Array.from(new Set(__spreadArray([
4171
- 'hotfix evidence',
4172
- 'full sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus for the exact pushed GitHub commit',
4173
- 'checksum before/after',
4174
- 'health/self-test pass',
4175
- 'release gate result'
4176
- ], __read(hotfixContinuation.requiredEvidence), false)));
4177
- var hotfixForbiddenActions = [
4178
- 'Do not apply a live hotfix before the exact diff is committed and pushed to GitHub.',
4179
- 'Do not mark a hotfix durable without sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus.',
4180
- 'Do not run a full deploy to clear a duplicate release loop unless force evidence explicitly allows one.'
4181
- ];
4182
- var hotfixGitGuard = hotfixContinuation.githubCommitGuard;
4183
- var liveHotfixBlockedUntilCommit = hotfixContinuation.action === 'record_hotfix_evidence'
4184
- || (hotfixGitGuard === null || hotfixGitGuard === void 0 ? void 0 : hotfixGitGuard.managerMustCommitBeforeHotfix) === true
4185
- || ((hotfixGitGuard === null || hotfixGitGuard === void 0 ? void 0 : hotfixGitGuard.required) === true && (hotfixGitGuard === null || hotfixGitGuard === void 0 ? void 0 : hotfixGitGuard.passed) !== true);
4186
- var hotfixDurabilityContract = (0, ai_runner_manager_policy_1.buildResolveIOAIManagerHotfixDurabilityContract)({
4187
- action: 'run_release_repair',
4188
- reason: releaseBlocker,
4189
- evidence: input.hotfixEvidence,
4190
- policy: input.releasePolicy,
4191
- continuation: hotfixContinuation,
4192
- releaseGatePassed: input.releaseGatePassed,
4193
- source: 'support_v5_autonomous_decision',
4194
- now: input.now
4195
- });
4196
- return makeDecision('repair_release_hotfix_first', 'Hotfix Release', 'support_v5_release_blocked_hotfix_first', {
4197
- canRunAutonomously: hotfixContinuation.action !== 'park_manual',
4198
- canRunModel: false,
4199
- canEditProductCode: false,
4200
- canPrepareHotfixPatch: hotfixDurabilityContract.canPrepareHotfixPatch,
4201
- canHotfixBackend: hotfixDurabilityContract.canHotfixBackend,
4202
- liveHotfixBlockedUntilCommit: hotfixDurabilityContract.liveHotfixBlockedUntilCommit || liveHotfixBlockedUntilCommit,
4203
- lane: 'release',
4204
- stepType: 'release_gate',
4205
- primaryCommand: hotfixDurabilityContract.liveHotfixBlockedUntilCommit
4206
- ? 'record_hotfix_evidence'
4207
- : hotfixPrimaryCommandByAction[hotfixContinuation.action] || hotfixDurabilityContract.nextSafeAction || 'record_hotfix_evidence',
4208
- nextCommands: hotfixNextCommands,
4209
- requiredEvidence: Array.from(new Set(__spreadArray(__spreadArray([], __read(hotfixRequiredEvidence), false), __read(hotfixDurabilityContract.requiredEvidence), false))).slice(0, 30),
4210
- blockers: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(input.unresolvedBlockers, 20, 500)), false), __read(hotfixContinuation.blockers), false), __read((hotfixDurabilityContract.liveHotfixBlockedUntilCommit
4211
- ? ["Hotfix durability contract ".concat(hotfixDurabilityContract.contractId, " requires GitHub commit and push proof before live backend apply.")]
4212
- : [])), false))),
4213
- forbiddenActions: Array.from(new Set(__spreadArray(__spreadArray([], __read(hotfixForbiddenActions), false), __read(hotfixDurabilityContract.forbiddenActions), false))).slice(0, 20),
4214
- hotfixContinuation: hotfixContinuation,
4215
- hotfixDurabilityContract: hotfixDurabilityContract
4216
- });
4217
- }
4218
- if (customerReplyPolicy.action === 'hold_internal' && customerReplyPolicy.reason === 'support_reply_blocked_until_release_or_hotfix_gate_finishes') {
4219
- return makeDecision('repair_release_hotfix_first', 'Hotfix Release', 'support_v5_reply_blocked_by_hotfix_evidence', {
4220
- canRunAutonomously: true,
4221
- canRunModel: false,
4222
- canEditProductCode: false,
4223
- canPrepareHotfixPatch: true,
4224
- canHotfixBackend: false,
4225
- liveHotfixBlockedUntilCommit: true,
4226
- lane: 'release',
4227
- stepType: 'release_gate',
4228
- primaryCommand: ((_f = customerReplyPolicy.humanReviewPacket) === null || _f === void 0 ? void 0 : _f.primaryAction) || 'repair_release_hotfix_first',
4229
- nextCommands: ((_g = customerReplyPolicy.humanReviewPacket) === null || _g === void 0 ? void 0 : _g.nextCommands) || ['record_hotfix_evidence', 'commit_and_push_hotfix_to_github', 'rerun_release_gate_once'],
4230
- requiredEvidence: customerReplyPolicy.requiredEvidence,
4231
- blockers: ((_h = customerReplyPolicy.humanReviewPacket) === null || _h === void 0 ? void 0 : _h.blockers) || ['Release or hotfix evidence is incomplete.'],
4232
- forbiddenActions: ['Do not draft a customer resolution until hotfix commit proof and release evidence are complete.'],
4233
- humanReviewPacket: customerReplyPolicy.humanReviewPacket
4234
- });
4235
- }
4236
- if ((activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) === 'qa' || /^(qa_row|qa_retest|business_proof|route_probe|issue_class_probe)$/.test(activeStepType)) {
4237
- return makeDecision('run_business_proof_qa', 'Run Business Proof QA', 'support_v5_business_assertion_required', {
4238
- canRunAutonomously: true,
4239
- canRunQa: true,
4240
- canRunModel: false,
4241
- canEditProductCode: false,
4242
- lane: 'qa',
4243
- stepType: /^(qa_row|qa_retest|business_proof|route_probe|issue_class_probe)$/.test(activeStepType) ? activeStepType : 'qa_row',
4244
- primaryCommand: 'run_support_v5_business_proof_qa_row',
4245
- nextCommands: ['start_local_stack_if_needed', 'execute_issue_class_probe', 'record_before_action_after_artifacts', 'write_aiqa_business_assertion'],
4246
- requiredEvidence: Array.from(new Set(__spreadArray(['AIQaBusinessAssertion pass', 'DOM/data proof', 'artifact path', 'Mongo delta when data-changing'], __read(issueClassProbeEvidence), false))),
4247
- forbiddenActions: ['Route probe pass alone remains route evidence only.']
4248
- });
4249
- }
4250
- if (!activeMicrotask && customerReplyPolicy.action === 'draft_resolution_reply') {
4251
- return makeDecision('draft_customer_reply', 'Draft Customer Reply', customerReplyPolicy.reason, {
4252
- canRunAutonomously: true,
4253
- canRunModel: true,
4254
- canDraftCustomerReply: true,
4255
- lane: 'customer',
4256
- stepType: 'customer_reply',
4257
- primaryCommand: 'draft_support_customer_resolution_reply',
4258
- nextCommands: ['summarize_business_proof', 'draft_customer_reply_for_human_review'],
4259
- requiredEvidence: customerReplyPolicy.requiredEvidence,
4260
- forbiddenActions: ['Draft only; do not send.']
4261
- });
4262
- }
4263
- if (!activeMicrotask && diagnosisValidation.valid && !businessProofReadiness.ready) {
4264
- return makeDecision('run_business_proof_qa', 'Run Business Proof QA', businessProofReadiness.reason, {
4265
- canRunAutonomously: true,
4266
- canRunQa: true,
4267
- canRunModel: false,
4268
- canEditProductCode: false,
4269
- lane: 'qa',
4270
- stepType: 'business_proof',
4271
- primaryCommand: 'run_support_v5_business_proof_qa_row',
4272
- nextCommands: ['execute_issue_class_probe', 'record_before_action_after_artifacts', 'write_aiqa_business_assertion'],
4273
- requiredEvidence: Array.from(new Set(__spreadArray(__spreadArray([], __read(businessProofReadiness.requiredEvidence), false), __read(issueClassProbeEvidence), false))),
4274
- blockers: businessProofReadiness.blockers,
4275
- forbiddenActions: ['Do not run release or customer reply until businessProofReadiness.ready=true.']
4276
- });
4277
- }
4278
- if (!activeMicrotask && businessProofReadiness.ready) {
4279
- return makeDecision('ready_for_release_gate', 'Run Release Gate', 'support_v5_business_proof_complete_release_gate_ready', {
4280
- canRunAutonomously: true,
4281
- canRunQa: true,
4282
- lane: 'release',
4283
- stepType: 'release_gate',
4284
- primaryCommand: 'run_support_release_gate_once',
4285
- nextCommands: ['verify_compile_and_business_proof_artifacts', 'run_release_gate_once', 'record_release_status'],
4286
- requiredEvidence: ['compile pass', 'business assertion artifact', 'release status']
4287
- });
4288
- }
4289
- return makeDecision('run_owner_scoped_repair', 'Run Owner-Scoped Repair', 'support_v5_product_repair_allowed_after_diagnosis', {
4290
- canRunAutonomously: true,
4291
- canRunModel: true,
4292
- canEditProductCode: true,
4293
- lane: (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) || 'build',
4294
- stepType: activeStepType || 'build_repair',
4295
- primaryCommand: 'run_support_v5_owner_scoped_repair',
4296
- nextCommands: ['load_owner_files_only', 'apply_smallest_fix', 'run_smallest_compile_or_unit_gate', 'handoff_to_business_proof_qa'],
4297
- requiredEvidence: ['changed files within owner_files', 'compile/unit proof', 'next QA row'],
4298
- forbiddenActions: ['Do not edit outside owner_files unless diagnosis is revised with new evidence.']
4299
- });
4300
- }
4301
- function buildResolveIOSupportV5DiagnoseFirstPrompt(lines) {
4302
- var _a, _b;
4303
- return [
4304
- 'Support Runner V5 contract: act like a guarded autonomous engineer, not a gate checklist.',
4305
- 'Start with Diagnose First: observed evidence, likely cause, smallest next action, and expected proof.',
4306
- 'Use compact lane memory and current artifacts before asking for broad ticket context.',
4307
- 'Do not send customer email. Do not write production data. Do not spawn duplicate build, QA, server, client, Mongo, browser, or Codex processes.',
4308
- 'If repairing, inspect logs/artifacts/source/diff first; make the smallest code or localhost-data change, then run the smallest finite self-gate.',
4309
- 'For build repairs, prefer `npm run build-prod -- --watch=false`, a targeted `tsc --noEmit`, or a focused unit test. `npm run build-dev` is forbidden for support microtasks because it is slow/watch-oriented and can leave heavy esbuild work. If no finite gate exists, return a blocked self-gate with the exact reason instead of running build-dev.',
4310
- 'If QA fails, retest the failed row before advancing; if the same blocker repeats without new proof, park with the exact blocker.',
4311
- lines.goal ? "Goal: ".concat(cleanText(lines.goal, 500)) : '',
4312
- cleanList(lines.approvedScope, 12, 240).length ? "Approved scope: ".concat(cleanList(lines.approvedScope, 12, 240).join(' | ')) : '',
4313
- lines.activeStep ? "Active step: ".concat(lines.activeStep) : '',
4314
- lines.lane ? "Lane: ".concat(lines.lane) : '',
4315
- lines.laneSummary ? "Lane memory: ".concat(cleanText(lines.laneSummary, 700)) : '',
4316
- lines.activeBlocker ? "Active blocker: ".concat(cleanText(lines.activeBlocker, 800)) : '',
4317
- ((_a = lines.currentQaRow) === null || _a === void 0 ? void 0 : _a.workflow) ? "Current QA row: ".concat(cleanText(lines.currentQaRow.workflow, 300)) : '',
4318
- ((_b = lines.currentQaRow) === null || _b === void 0 ? void 0 : _b.route) ? "Current QA route: ".concat(cleanText(lines.currentQaRow.route, 300)) : '',
4319
- cleanList(lines.changedFiles, 12, 200).length ? "Changed files: ".concat(cleanList(lines.changedFiles, 12, 200).join(', ')) : '',
4320
- cleanList(lines.artifactPaths, 12, 240).length ? "Artifacts: ".concat(cleanList(lines.artifactPaths, 12, 240).join(', ')) : ''
4321
- ].filter(Boolean);
4322
- }
4323
- function buildResolveIOSupportV5MicrotaskPrompt(input) {
4324
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4325
- var activeMicrotask = selectResolveIOSupportV5ActiveMicrotask(input.bundle.supportV5MicrotaskLedger || [], input.bundle.supportV5ActiveMicrotaskId);
4326
- var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.bundle.supportV5DiagnosisGate);
4327
- var diagnosisGate = diagnosisValidation.normalized || input.bundle.supportV5DiagnosisGate;
4328
- var diagnosisActive = (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) === 'diagnosis_gate';
4329
- var budget = buildResolveIOSupportV5PromptBudget();
4330
- var repairLike = Boolean(input.failureText || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.status) === 'needs_repair' || /repair/i.test(String(input.stage || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) || '')));
4331
- var cap = repairLike
4332
- ? budget.repairMicrotaskCap
4333
- : input.lane === 'qa'
4334
- ? budget.qaMicrotaskCap
4335
- : budget.buildMicrotaskCap;
4336
- var hardCap = repairLike
4337
- ? budget.repairMicrotaskHardCap
4338
- : input.lane === 'qa'
4339
- ? budget.qaMicrotaskHardCap
4340
- : budget.buildMicrotaskHardCap;
4341
- var laneMemory = input.bundle.supportV5LaneMemory[input.lane];
4342
- var taskThreadKey = (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.threadKey) || laneMemory.threadKey;
4343
- var changedFiles = cleanList(((_a = input.changedFiles) === null || _a === void 0 ? void 0 : _a.length) ? input.changedFiles : laneMemory.changedFiles, 8, 160);
4344
- var artifactPaths = cleanList(((_b = input.artifactPaths) === null || _b === void 0 ? void 0 : _b.length) ? input.artifactPaths : laneMemory.artifactPaths, 8, 200);
4345
- var targetFiles = cleanList(((_c = input.targetFiles) === null || _c === void 0 ? void 0 : _c.length) ? input.targetFiles : activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.targetFiles, 5, 160);
4346
- var contextSnippets = cleanList(input.contextSnippets, 5, 360);
4347
- var diagnosisEvidencePack = buildResolveIOSupportDiagnosisEvidencePack({
4348
- bundle: input.bundle,
4349
- similarCaseHints: input.similarCaseHints,
4350
- issueClass: diagnosisGate === null || diagnosisGate === void 0 ? void 0 : diagnosisGate.issue_class,
4351
- ownerFiles: (diagnosisGate === null || diagnosisGate === void 0 ? void 0 : diagnosisGate.owner_files) || targetFiles,
4352
- text: input.bundle.supportV5ScopeDigest || input.bundle.supportV5SupervisorState.currentGoal
4353
- });
4354
- var promptProbePlanValidation = validateResolveIOSupportIssueClassProbePlan(input.bundle.supportV5IssueClassProbePlan, diagnosisValidation.normalized || diagnosisGate, input.now);
4355
- var promptProbePlan = promptProbePlanValidation.valid
4356
- ? promptProbePlanValidation.normalized
4357
- : diagnosisValidation.valid
4358
- ? buildResolveIOSupportIssueClassProbePlan(diagnosisValidation.normalized || diagnosisGate, input.now)
4359
- : undefined;
4360
- var similarCaseSelection = diagnosisEvidencePack.similarCaseSelection;
4361
- var similarCaseHintsText = ((_d = similarCaseSelection === null || similarCaseSelection === void 0 ? void 0 : similarCaseSelection.ranked) === null || _d === void 0 ? void 0 : _d.length)
4362
- ? __spreadArray([
4363
- 'Similar accepted fix hints. Advisory only: use these to prioritize inspection paths, not as proof.'
4364
- ], __read(similarCaseSelection.ranked.slice(0, 5).map(function (hint, index) {
4365
- var _a;
4366
- return [
4367
- "".concat(index + 1, ". source=").concat(hint.source || 'unknown', " score=").concat(Number(hint.score || 0)),
4368
- hint.ticketNumber ? "ticket=".concat(hint.ticketNumber) : '',
4369
- hint.commitSha ? "commit=".concat(hint.commitSha) : '',
4370
- hint.issueClass ? "issue_class=".concat(hint.issueClass) : '',
4371
- ((_a = hint.ownerFiles) === null || _a === void 0 ? void 0 : _a.length) ? "owner_files=".concat(hint.ownerFiles.slice(0, 4).join(', ')) : '',
4372
- hint.reason ? "signals=".concat(hint.reason) : '',
4373
- hint.title ? "title=".concat(cleanText(hint.title, 180)) : ''
4374
- ].filter(Boolean).join(' | ');
4375
- })), false).join('\n')
4376
- : '';
4377
- var qaRow = input.activeQaRow || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) === 'qa'
4378
- ? input.activeQaRow || laneMemory.activeQaRow || input.bundle.supportV5SupervisorState.currentQaRow
4379
- : undefined;
4380
- var sections = [
4381
- {
4382
- name: 'microtask_contract',
4383
- text: [
4384
- 'Support Runner V5 Microtask Contract.',
4385
- 'Use the existing persistent lane thread. Do not start a fresh thread.',
4386
- 'Do exactly one microtask and one proof gate. Do not replay ticket triage, prior plans, attachments, broad QA checklist, or unrelated scope.',
4387
- 'If context is insufficient, request the smallest missing file/log/artifact by path and park this microtask; do not broaden the prompt.',
4388
- 'Do not send customer email. Do not deploy. Do not spawn duplicate server/client/Mongo/browser/Codex processes.',
4389
- diagnosisActive
4390
- ? 'Diagnosis gate hard boundary: read-only investigation only. Do not edit source, generated files, package files, tests, fixtures, QA artifacts, or local data. Return the diagnosis JSON contract only.'
4391
- : input.lane === 'qa'
4392
- ? 'QA lane hard boundary: the platform preflight owns compile, dependency install, Mongo/server/client startup, and Angular startup. This lane owns only browser/data proof and QA artifacts unless the prompt explicitly says preflight was skipped.'
4393
- : 'Build lane hard boundary: do not run `npm run build-dev`, `ng build`, `npm run server`, `npm run client`, `ng serve`, `run-local-qa.sh`, browser automation, or any watch/long-lived command. If a broad compile gate is needed, run only `npm run build-prod -- --watch=false`; otherwise use a targeted finite check or return the precise blocker.'
4394
- ].join('\n')
4395
- },
4396
- diagnosisActive ? {
4397
- name: 'root_cause_first_diagnosis_contract',
4398
- text: [
4399
- 'Before any product-code repair, produce strict JSON only:',
4400
- '{"support_diagnosis_gate":{"issue_case":{"customer_complaint":"","expected_result":"","observed_result":"","route_module":"","account_customer_context":"","reproduction_status":"reproduced|blocked|classified","reproduction_blocker":""},"issue_class":"no_op_submit|missing_wrong_data|filter_query_mismatch|invoice_pdf_export|upload_import|route_auth_hydration|slow_query_performance","accepted_hypothesis":{"statement":"","falsifiable_test":"","evidence":[""]},"rejected_alternatives":[""],"failing_path":{"frontend":"","backend":"","shared_library":"","data_query":"","description":""},"owner_files":["small/exact/file.ts"],"proof_plan":{"before":"","before_state_unavailable_reason":"","action":"","after":"","business_assertion":"","route":"","data_assertion":"","artifact_expectation":"","business_proof_contract":{"issue_class":"same as diagnosis issue_class","setup_state":"","action_under_test":"","expected_business_state_change":"","prohibited_false_pass":"Route load, screenshot, scorecard, or model claim alone is not acceptance.","proof_artifacts":["browser trace/screenshot/json/mongo delta"],"data_or_dom_assertion":""}},"similar_tickets":[],"similar_commits":[],"evidence":[{"type":"ticket|browser|mongo|log|code|commit|qa|other","summary":"","artifactPath":""}],"status":"passed"}}',
4401
- 'Owner files must be a small exact editable set, not directories, globs, generated wrappers, or broad repo areas.',
4402
- 'The accepted hypothesis must be falsifiable and backed by evidence; prior similar tickets or commits are hints only and cannot bypass fresh diagnosis.',
4403
- 'For reproduction_status="reproduced", evidence must include at least one browser, Mongo, log, or QA evidence object with artifactPath so the runner can replay the proof.',
4404
- 'For reproduction_status="classified", evidence must still include non-ticket root-cause proof such as code, commit, Mongo, log, browser, or QA evidence.',
4405
- 'Ticket text and similar-ticket hints are context, not root-cause proof by themselves.',
4406
- 'The proof plan must be before/action/after business proof plus business_proof_contract. If before-state proof is impossible, explain exactly why in before_state_unavailable_reason.',
4407
- 'The business_proof_contract must name the setup state, action under test, expected business state change, prohibited false pass, required artifacts, and DOM/data assertion.'
4408
- ].join('\n')
4409
- } : {
4410
- name: 'diagnosis_gate_context',
4411
- text: diagnosisValidation.valid && diagnosisGate ? [
4412
- "Diagnosis issue class: ".concat(diagnosisGate.issue_class),
4413
- "Accepted hypothesis: ".concat(diagnosisGate.accepted_hypothesis.statement),
4414
- "Failing path: ".concat(diagnosisGate.failing_path.description || diagnosisGate.failing_path.frontend || diagnosisGate.failing_path.backend || ''),
4415
- "Owner files: ".concat(diagnosisGate.owner_files.join(', ')),
4416
- "Business proof required: ".concat(diagnosisGate.proof_plan.business_assertion),
4417
- diagnosisGate.proof_plan.business_proof_contract
4418
- ? "Business proof contract: ".concat((_e = diagnosisGate.proof_plan.business_proof_contract) === null || _e === void 0 ? void 0 : _e.action_under_test, " -> ").concat((_f = diagnosisGate.proof_plan.business_proof_contract) === null || _f === void 0 ? void 0 : _f.expected_business_state_change, "; assertion ").concat((_g = diagnosisGate.proof_plan.business_proof_contract) === null || _g === void 0 ? void 0 : _g.data_or_dom_assertion)
4419
- : '',
4420
- "Before/action/after: ".concat(diagnosisGate.proof_plan.before || diagnosisGate.proof_plan.before_state_unavailable_reason, " -> ").concat(diagnosisGate.proof_plan.action, " -> ").concat(diagnosisGate.proof_plan.after)
4421
- ].filter(Boolean).join('\n') : 'SupportDiagnosisGate is not valid. Park instead of editing product code.'
4422
- },
4423
- diagnosisActive ? {
4424
- name: 'diagnosis_evidence_pack',
4425
- text: JSON.stringify({
4426
- packId: diagnosisEvidencePack.packId,
4427
- status: diagnosisEvidencePack.status,
4428
- readOnly: diagnosisEvidencePack.readOnly,
4429
- sourceEditsAllowed: diagnosisEvidencePack.sourceEditsAllowed,
4430
- requiredOutputKey: diagnosisEvidencePack.requiredOutputKey,
4431
- requiredFields: diagnosisEvidencePack.requiredFields,
4432
- requiredEvidence: diagnosisEvidencePack.requiredEvidence,
4433
- forbiddenActions: diagnosisEvidencePack.forbiddenActions,
4434
- validationBlockers: diagnosisEvidencePack.validationBlockers,
4435
- issueClassHint: diagnosisEvidencePack.issueClassHint,
4436
- ownerFileHints: diagnosisEvidencePack.ownerFileHints,
4437
- similarHintsAdvisoryOnly: true,
4438
- similarHintCount: diagnosisEvidencePack.similarCaseSelection.ranked.length,
4439
- issueClassProbeCatalog: diagnosisEvidencePack.issueClassProbeCatalog.map(function (entry) { return ({
4440
- issue_class: entry.issue_class,
4441
- action: entry.action,
4442
- proof_required: entry.proof_required,
4443
- acceptance_gate: entry.acceptance_gate,
4444
- false_pass_blockers: entry.false_pass_blockers
4445
- }); })
4446
- })
4447
- } : undefined,
4448
- diagnosisActive && similarCaseHintsText ? {
4449
- name: 'similar_accepted_fix_hints',
4450
- text: similarCaseHintsText
4451
- } : undefined,
4452
- !diagnosisActive && input.lane === 'qa' && promptProbePlan ? {
4453
- name: 'issue_class_probe_plan',
4454
- text: [
4455
- "IssueClassProbePlan ".concat(promptProbePlan.planId, " status=").concat(promptProbePlan.status, " issue_class=").concat(promptProbePlan.issue_class || '', " gate=").concat(promptProbePlan.acceptanceGate),
4456
- "route=".concat(cleanText((_h = promptProbePlan.activeProbe) === null || _h === void 0 ? void 0 : _h.route, 180)),
4457
- "action=".concat(cleanText(((_j = promptProbePlan.activeProbe) === null || _j === void 0 ? void 0 : _j.state_transition.action) || ((_k = promptProbePlan.activeProbe) === null || _k === void 0 ? void 0 : _k.action), 260)),
4458
- "assertion=".concat(cleanText((_l = promptProbePlan.activeProbe) === null || _l === void 0 ? void 0 : _l.state_transition.assertion, 260)),
4459
- "after=".concat(cleanText((_m = promptProbePlan.activeProbe) === null || _m === void 0 ? void 0 : _m.state_transition.after, 260)),
4460
- "artifacts=".concat(promptProbePlan.requiredArtifacts.slice(0, 6).join(', ')),
4461
- "false_pass_blockers=".concat(promptProbePlan.falsePassBlockers.slice(0, 4).join(', ')),
4462
- promptProbePlan.blockers.length ? "blockers=".concat(promptProbePlan.blockers.slice(0, 4).join('; ')) : ''
4463
- ].filter(Boolean).join('\n')
4464
- } : undefined,
4465
- {
4466
- name: 'scope_digest',
4467
- text: cleanText(input.bundle.supportV5ScopeDigest || input.bundle.supportV5SupervisorState.approvedScope, 900)
4468
- },
4469
- {
4470
- name: 'active_microtask',
4471
- text: activeMicrotask ? [
4472
- "Microtask id: ".concat(activeMicrotask.microtaskId),
4473
- "Lane: ".concat(input.lane),
4474
- "Type: ".concat(activeMicrotask.type),
4475
- "Status: ".concat(activeMicrotask.status),
4476
- "Objective: ".concat(cleanText(activeMicrotask.objective, 360)),
4477
- "Self-gate: ".concat(cleanText(activeMicrotask.selfGate, 260)),
4478
- "Acceptance proof: ".concat(cleanText(activeMicrotask.acceptanceProof, 260)),
4479
- "Attempts on this microtask: ".concat(activeMicrotask.attempts),
4480
- "Thread key: ".concat(taskThreadKey)
4481
- ].join('\n') : 'No active microtask found. Park and report support_v5_microtask_missing.'
4482
- },
4483
- {
4484
- name: 'failure_delta',
4485
- text: input.failureText ? "Latest blocker/failure delta: ".concat(cleanText(input.failureText, 700)) : ''
4486
- },
4487
- {
4488
- name: 'target_context',
4489
- text: [
4490
- targetFiles.length ? "Target files: ".concat(targetFiles.join(', ')) : '',
4491
- changedFiles.length ? "Changed files: ".concat(changedFiles.join(', ')) : '',
4492
- artifactPaths.length ? "Artifacts: ".concat(artifactPaths.join(', ')) : '',
4493
- (qaRow === null || qaRow === void 0 ? void 0 : qaRow.workflow) ? "QA row workflow: ".concat(cleanText(qaRow.workflow, 220)) : '',
4494
- (qaRow === null || qaRow === void 0 ? void 0 : qaRow.route) ? "QA row route: ".concat(cleanText(qaRow.route, 220)) : '',
4495
- (qaRow === null || qaRow === void 0 ? void 0 : qaRow.assertion) ? "QA row assertion: ".concat(cleanText(qaRow.assertion, 260)) : '',
4496
- contextSnippets.length ? "Relevant snippets:\n".concat(contextSnippets.join('\n---\n')) : ''
4497
- ].filter(Boolean).join('\n')
4498
- },
4499
- input.lane === 'qa' ? {
4500
- name: 'qa_browser_evidence_contract',
4501
- text: [
4502
- 'QA lane first action after preflight: collect fresh browser evidence for the active row, not a proof review of existing route/auth artifacts.',
4503
- 'Use the already-running localhost harness and staged env. Before any shell command, run `source .resolveio-support-tools/env.sh 2>/dev/null || source ../.resolveio-support-tools/env.sh 2>/dev/null || true`; then use `$RESOLVEIO_SUPPORT_QA_CLIENT_URL`, `$RESOLVEIO_SUPPORT_QA_SERVER_URL`, `$PUPPETEER_EXECUTABLE_PATH`, and `$CHROME_BIN`.',
4504
- 'Required auth replay helper inside every Puppeteer row script: `const storage=JSON.parse(fs.readFileSync("qa-artifacts/auth-bootstrap-storage-state.json","utf8")); const entries=[...(Array.isArray(storage.localStorageEntries)?storage.localStorageEntries:[]), ...(Array.isArray(storage.localStorage)?storage.localStorage:Object.entries(storage.localStorage||{}).map(([key,value])=>({key,value}))), ...((storage.origins||[]).flatMap(o=>o.localStorage||[]))].map(e=>({key:e.key||e.name,value:e.value})).filter(e=>e.key); const clientUrl=process.env.RESOLVEIO_SUPPORT_QA_CLIENT_URL||process.env.RESOLVEIO_RUNNER_QA_CLIENT_URL; const rowRoute="<ACTIVE_QA_ROUTE>"; await page.goto(clientUrl,{waitUntil:"domcontentloaded"}); await page.evaluate(items=>{localStorage.clear(); for(const item of items)localStorage.setItem(item.key,item.value);}, entries); await page.goto(new URL(rowRoute, clientUrl).href,{waitUntil:"domcontentloaded"});` Replace `<ACTIVE_QA_ROUTE>` with the active row route.',
4505
- 'Allowed first command shape: one bounded `node`/Puppeteer row script that reads `qa-artifacts/auth-bootstrap-storage-state.json`, opens `$RESOLVEIO_SUPPORT_QA_CLIENT_URL`, seeds localStorage, navigates to the active QA route with `new URL(activeRoute, clientUrl).href`, drives the visible workflow, captures screenshot/caption, and updates the active matrix row. A `/home` proof is invalid for a locked non-home route.',
4506
- 'Forbidden in QA lane after preflight: build/install/startup/watch commands, `mongod`, `run-local-qa.sh`, and broad source discovery. If build/startup/dependency is suspected, return blocked/needs-fix with existing qa-artifacts log paths.',
4507
- 'Before passing, confirm `qa-artifacts/auth-bootstrap-result.json` used the ticket reporter or named affected user when available. If it used generic admin/dev while `qa-live-data-seed-result.json.selected.qa_user_context` names a reporter/affected user, rerun auth as that user or return needs-fix.',
4508
- 'Drive the visible customer workflow for this one row. Capture a new customer-facing screenshot/caption and update `qa-artifacts/qa-coverage-matrix.json` with workflow, route, data id/name, assertion, screenshot path, caption, and pass/failed/blocked status.',
4509
- 'Also write `qa-artifacts/aiqa-business-assertion.json` with one AIQaBusinessAssertion object: assertion, status, workflow, route, before, action, expected, after/observed, dataProof or mongoDelta, artifactPaths, and metadata.supportDiagnosisProof=true only when it maps to the active SupportDiagnosisGate proof_plan.',
4510
- 'After selecting any From/To, source/target, dropdown, combobox, rio-select, filter, item, customer, yard, chemical, or treatment-plan value, read the visible control text back from the DOM. If it still contains placeholder text such as Select Chemical, Select Yard, Select Customer, Select Treatment Plan Type, Loading..., empty, null, or undefined, do not click the action button and do not mark pass. Capture the selected-state blocker screenshot/DOM text and return needs-fix.',
4511
- 'If the row needs persisted data proof, create that proof yourself in the same bounded QA command by querying localhost QA Mongo through process.env.MONGO_URL after the visible UI action. Write the result under qa-artifacts/ as JSON and reference that path in the matrix. Do not ask for a missing post-action DB artifact while the local QA stack is running; either write it or return needs-fix with the exact query/script error. For update-interchangeables rows, the JSON must include concrete non-placeholder fromText and toText, before/after counts or sample documents for treatment plans and tank/interchangeable records, and must fail if either selected value is only an arrow/placeholder or if the persisted collections are empty.',
4512
- 'If the row names multiple concrete entities such as assets, units, BOLs, invoices, chemicals, customers, yards, or numbered records, prove every named entity. Do not pass by proving only one representative record.',
4513
- 'For customer-reported data bugs, use production-seeded localhost records from `qa-live-data-seed-result.json`. If the exact named record is missing from the seed, fail the row as a seed/query blocker instead of testing a substitute record.',
4514
- 'Route-ready, auth-bootstrap, shell, header-only, and empty-list screenshots do not satisfy this microtask. If the row cannot be proven, capture the blocker screenshot/DOM state and return needs-fix with that exact blocker.',
4515
- 'Do not run compile/startup/npm install, do not spawn another server/client/Mongo, and do not inspect broad source trees before the first browser evidence command.'
4516
- ].join('\n')
4517
- } : {
4518
- name: 'non_qa_noop',
4519
- text: ''
4520
- },
4521
- {
4522
- name: 'return_contract',
4523
- text: diagnosisActive
4524
- ? 'Return strict JSON only with support_diagnosis_gate. Do not include Markdown and do not edit files.'
4525
- : input.lane === 'qa'
4526
- ? 'Return strict JSON only: {"status":"pass"|"needs-fix"|"blocked","microtaskId":"","summary":"","evidence":[""],"artifacts":[""],"next_actions":[""]}.'
4527
- : 'Return concise Markdown with: Microtask Result, Root Cause, Changes, Self-Gate, Acceptance Proof, Residual Risk.'
4528
- }
4529
- ].filter(function (section) { return !!section && !!cleanText(section.text, 20); });
4530
- var promptSections = sections.map(function (section) { return ({
4531
- name: section.name,
4532
- tokenEstimate: estimateTextTokens(section.text)
4533
- }); });
4534
- var prompt = sections.map(function (section) { return section.text; }).join('\n\n');
4535
- var promptTokenEstimate = estimateTextTokens(prompt);
4536
- return {
4537
- prompt: prompt,
4538
- promptTokenEstimate: promptTokenEstimate,
4539
- promptSections: promptSections,
4540
- diagnosisEvidencePack: diagnosisEvidencePack,
4541
- activeMicrotask: activeMicrotask,
4542
- withinCap: promptTokenEstimate <= cap,
4543
- withinHardCap: promptTokenEstimate <= hardCap,
4544
- cap: cap,
4545
- hardCap: hardCap,
4546
- reason: promptTokenEstimate > hardCap
4547
- ? 'support_v5_microtask_prompt_hard_cap'
4548
- : promptTokenEstimate > cap
4549
- ? 'support_v5_microtask_prompt_soft_cap'
4550
- : undefined
4551
- };
4552
- }
4553
- function summarizeResolveIOSupportV5MicrotaskUsage(bundle) {
4554
- var e_10, _a, e_11, _b;
4555
- var byMicrotask = new Map();
4556
- var bySection = new Map();
4557
- var totalPromptTokenEstimate = 0;
4558
- var broadPromptViolations = [];
4559
- var promptBudget = buildResolveIOSupportV5PromptBudget();
4560
- try {
4561
- for (var _c = __values(bundle.supportV5MicrotaskUsageHistory || []), _d = _c.next(); !_d.done; _d = _c.next()) {
4562
- var usage = _d.value;
4563
- totalPromptTokenEstimate += usage.promptTokenEstimate || 0;
4564
- var existing = byMicrotask.get(usage.microtaskId) || { microtaskId: usage.microtaskId, promptTokenEstimate: 0, calls: 0 };
4565
- existing.promptTokenEstimate += usage.promptTokenEstimate || 0;
4566
- existing.calls += 1;
4567
- byMicrotask.set(usage.microtaskId, existing);
4568
- try {
4569
- for (var _e = (e_11 = void 0, __values(usage.promptSections || [])), _f = _e.next(); !_f.done; _f = _e.next()) {
4570
- var section = _f.value;
4571
- bySection.set(section.name, (bySection.get(section.name) || 0) + section.tokenEstimate);
4572
- }
4573
- }
4574
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
4575
- finally {
4576
- try {
4577
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
4578
- }
4579
- finally { if (e_11) throw e_11.error; }
4580
- }
4581
- var hardCap = usage.lane === 'qa' ? promptBudget.qaMicrotaskHardCap : promptBudget.buildMicrotaskHardCap;
4582
- if ((usage.promptTokenEstimate || 0) > hardCap) {
4583
- broadPromptViolations.push(usage);
4584
- }
4585
- }
4586
- }
4587
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
4588
- finally {
4589
- try {
4590
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
4591
- }
4592
- finally { if (e_10) throw e_10.error; }
4593
- }
4594
- return {
4595
- totalPromptTokenEstimate: totalPromptTokenEstimate,
4596
- byMicrotask: Array.from(byMicrotask.values()),
4597
- bySection: Array.from(bySection.entries()).map(function (_a) {
4598
- var _b = __read(_a, 2), name = _b[0], tokenEstimate = _b[1];
4599
- return ({ name: name, tokenEstimate: tokenEstimate });
4600
- }),
4601
- broadPromptViolations: broadPromptViolations
4602
- };
4603
- }
4604
- function buildResolveIOSupportV5Incident(input) {
4605
- return {
4606
- incidentClass: cleanText(input.incidentClass, 120) || 'support_v5_runner_incident',
4607
- summary: cleanText(input.summary, 1200),
4608
- stepType: input.stepType,
4609
- blockerFingerprint: input.blocker ? fingerprintResolveIOSupportV5Blocker(input.blocker) : undefined,
4610
- artifactPaths: cleanList(input.artifactPaths, 40, 500),
4611
- recordedAt: isoNow(input.now)
4612
- };
4613
- }
4614
-
4615
- //# sourceMappingURL=support-runner-v5.js.map