@resolveio/server-lib 22.3.195 → 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 -4124
  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 -767
  690. package/util/ai-runner-manager-policy.js +0 -3304
  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 -423
  699. package/util/aicoder-runner-v6.js +0 -2177
  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,4124 +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.evaluateAssistantAnswerQuality = evaluateAssistantAnswerQuality;
51
- exports.buildAssistantAnswerActionabilityContract = buildAssistantAnswerActionabilityContract;
52
- exports.buildSupportAIRunFromEvidence = buildSupportAIRunFromEvidence;
53
- exports.buildAICoderAIRunFromEvidence = buildAICoderAIRunFromEvidence;
54
- exports.buildAssistantAIRunFromEvidence = buildAssistantAIRunFromEvidence;
55
- var ai_run_evidence_1 = require("./ai-run-evidence");
56
- var aicoder_runner_v6_1 = require("./aicoder-runner-v6");
57
- var ai_runner_manager_policy_1 = require("./ai-runner-manager-policy");
58
- var support_runner_v5_1 = require("./support-runner-v5");
59
- function cleanText(value, max) {
60
- if (max === void 0) { max = 1000; }
61
- return String(value || '').replace(/\s+/g, ' ').trim().slice(0, max);
62
- }
63
- function idText(value, max) {
64
- if (max === void 0) { max = 160; }
65
- var normalized = cleanText(value, max);
66
- return normalized || undefined;
67
- }
68
- function asArray(value) {
69
- return Array.isArray(value) ? value : [];
70
- }
71
- function cleanStringList(value, limit, max) {
72
- if (limit === void 0) { limit = 40; }
73
- if (max === void 0) { max = 500; }
74
- return asArray(value)
75
- .map(function (entry) { return cleanText(entry, max); })
76
- .filter(Boolean)
77
- .slice(0, limit);
78
- }
79
- function plainObject(value) {
80
- return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
81
- }
82
- function firstText(source, fields, max) {
83
- var e_1, _a;
84
- if (max === void 0) { max = 1000; }
85
- try {
86
- for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
87
- var field = fields_1_1.value;
88
- var value = source === null || source === void 0 ? void 0 : source[field];
89
- var normalized = idText(value, max);
90
- if (normalized) {
91
- return normalized;
92
- }
93
- }
94
- }
95
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
96
- finally {
97
- try {
98
- if (fields_1_1 && !fields_1_1.done && (_a = fields_1.return)) _a.call(fields_1);
99
- }
100
- finally { if (e_1) throw e_1.error; }
101
- }
102
- return undefined;
103
- }
104
- function dateValue(source, fields) {
105
- var e_2, _a;
106
- try {
107
- for (var fields_2 = __values(fields), fields_2_1 = fields_2.next(); !fields_2_1.done; fields_2_1 = fields_2.next()) {
108
- var field = fields_2_1.value;
109
- var value = source === null || source === void 0 ? void 0 : source[field];
110
- if (value) {
111
- return value;
112
- }
113
- }
114
- }
115
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
116
- finally {
117
- try {
118
- if (fields_2_1 && !fields_2_1.done && (_a = fields_2.return)) _a.call(fields_2);
119
- }
120
- finally { if (e_2) throw e_2.error; }
121
- }
122
- return undefined;
123
- }
124
- function addSourceId(sourceIds, key, value) {
125
- var normalized = idText(value);
126
- if (normalized) {
127
- sourceIds[key] = normalized;
128
- }
129
- }
130
- function pushEvent(events, event) {
131
- var _a;
132
- var message = cleanText(event.message, 1800);
133
- var metadata = event.metadata || {};
134
- if (!message && !Object.keys(metadata).length && !((_a = event.artifactPaths) === null || _a === void 0 ? void 0 : _a.length)) {
135
- return;
136
- }
137
- events.push(__assign(__assign({}, event), { message: message, artifactPaths: asArray(event.artifactPaths).filter(Boolean).slice(0, 20) }));
138
- }
139
- function eventDate(record) {
140
- return dateValue(record, ['recordedAt', 'createdAt', 'updatedAt', 'timestamp', 'time', 'date']);
141
- }
142
- function normalizeManagerFailureRecord(value, fallback) {
143
- if (fallback === void 0) { fallback = {}; }
144
- var entry = plainObject(value);
145
- if (!Object.keys(entry).length && !Object.keys(fallback).length) {
146
- return undefined;
147
- }
148
- var blocker = cleanText(entry.blocker || entry.reason || entry.summary || entry.message || fallback.blocker || fallback.summary, 1200);
149
- var failureClass = cleanText(entry.failureClass || entry.failure_class || entry.class || fallback.failureClass, 120);
150
- var evidenceHash = cleanText(entry.evidenceHash || entry.evidence_hash || entry.hash || fallback.evidenceHash, 180);
151
- var blockerFingerprint = cleanText(entry.blockerFingerprint || entry.blocker_fingerprint || fallback.blockerFingerprint, 180);
152
- var lane = cleanText(entry.lane || fallback.lane || 'support', 80);
153
- var stepType = cleanText(entry.stepType || entry.step_type || entry.type || fallback.stepType || 'support_step', 80);
154
- var outcome = cleanText(entry.outcome || entry.status || entry.result || fallback.outcome || 'needs_repair', 80);
155
- if (!blocker && !failureClass && !evidenceHash && !blockerFingerprint) {
156
- return undefined;
157
- }
158
- return {
159
- lane: lane,
160
- stepType: stepType,
161
- outcome: outcome,
162
- failureClass: failureClass || undefined,
163
- blocker: blocker || undefined,
164
- summary: cleanText(entry.summary || entry.message || fallback.summary, 1200) || undefined,
165
- blockerFingerprint: blockerFingerprint || undefined,
166
- evidenceHash: evidenceHash || undefined,
167
- changedFiles: cleanStringList(entry.changedFiles || entry.changed_files || fallback.changedFiles, 80, 500),
168
- artifactPaths: cleanStringList(entry.artifactPaths || entry.artifact_paths || entry.artifacts || fallback.artifactPaths, 80, 500)
169
- };
170
- }
171
- function supportManagerFailureRecords(job, evidence) {
172
- var e_3, _a, e_4, _b;
173
- var records = [];
174
- var pushRecord = function (value, fallback) {
175
- if (fallback === void 0) { fallback = {}; }
176
- var record = normalizeManagerFailureRecord(value, fallback);
177
- if (record) {
178
- records.push(record);
179
- }
180
- };
181
- try {
182
- for (var _c = __values(asArray(job.supportV5StepHistory || job.support_v5_step_history || evidence.supportV5StepHistory || evidence.support_v5_step_history)), _d = _c.next(); !_d.done; _d = _c.next()) {
183
- var entry = _d.value;
184
- pushRecord(entry);
185
- }
186
- }
187
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
188
- finally {
189
- try {
190
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
191
- }
192
- finally { if (e_3) throw e_3.error; }
193
- }
194
- try {
195
- for (var _e = __values(asArray(job.supportV5FailureFingerprints || job.support_v5_failure_fingerprints || evidence.supportV5FailureFingerprints || evidence.support_v5_failure_fingerprints)), _f = _e.next(); !_f.done; _f = _e.next()) {
196
- var entry = _f.value;
197
- var fingerprint = plainObject(entry);
198
- var count = Math.max(1, Math.min(8, Number(fingerprint.count || fingerprint.repeatedCount || fingerprint.repeated_count || 1) || 1));
199
- var fallback = {
200
- lane: cleanText(fingerprint.lane || 'support', 80),
201
- stepType: cleanText(fingerprint.stepType || fingerprint.step_type || 'support_step', 80),
202
- outcome: cleanText(fingerprint.outcome || 'needs_repair', 80),
203
- failureClass: cleanText(fingerprint.failureClass || fingerprint.failure_class || fingerprint.class, 120),
204
- blocker: cleanText(fingerprint.blocker || fingerprint.reason || fingerprint.summary, 1200),
205
- blockerFingerprint: cleanText(fingerprint.blockerFingerprint || fingerprint.blocker_fingerprint, 180),
206
- evidenceHash: cleanText(fingerprint.evidenceHash || fingerprint.evidence_hash, 180)
207
- };
208
- for (var index = 0; index < count; index += 1) {
209
- pushRecord(fingerprint, fallback);
210
- }
211
- }
212
- }
213
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
214
- finally {
215
- try {
216
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
217
- }
218
- finally { if (e_4) throw e_4.error; }
219
- }
220
- var currentFailure = evidenceObject(job.supportV5CurrentFailure, job.support_v5_current_failure, job.supportV5RecoveryCurrent, job.support_v5_recovery_current, evidence.currentFailure, evidence.current_failure);
221
- pushRecord(currentFailure);
222
- return records.slice(-80);
223
- }
224
- function managerNoBlindLoopGateFromHistory(history, budgetSource, now) {
225
- var _a;
226
- if (!history.length) {
227
- return undefined;
228
- }
229
- var budget = plainObject(budgetSource);
230
- var maxSameFailureRepeats = Math.max(1, Number(budget.maxRepeatedNoProgress || budget.max_repeated_no_progress || budget.maxSameFailureRepeats || budget.max_same_failure_repeats || 3) || 3);
231
- var decision = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerPolicy)({
232
- history: history,
233
- maxSameFailureRepeats: maxSameFailureRepeats
234
- });
235
- var parksRun = /^(park_repeated_failure|park_ping_pong|manual_handoff)$/.test(decision.action);
236
- var status = parksRun
237
- ? 'blocked'
238
- : decision.action === 'retry_infra'
239
- ? 'warn'
240
- : 'pass';
241
- return {
242
- key: 'manager_no_blind_loop_policy',
243
- label: 'No-blind-loop manager policy',
244
- status: status,
245
- reason: decision.reason,
246
- evidenceRefs: cleanStringList(decision.recoveryAction.requiredArtifacts, 20, 500),
247
- recordedAt: isoNow(now),
248
- metadata: {
249
- action: decision.action,
250
- failureClass: decision.failureClass,
251
- blockerFingerprint: decision.blockerFingerprint,
252
- evidenceHash: decision.evidenceHash,
253
- sameFailureCount: decision.sameFailureCount,
254
- pingPongCount: decision.pingPongCount,
255
- newEvidence: decision.newEvidence,
256
- materialEvidence: decision.materialEvidence,
257
- evidenceStrength: decision.evidenceStrength,
258
- evidenceSignals: decision.evidenceSignals,
259
- loopBudgetShouldReset: decision.loopBudgetShouldReset,
260
- productRepairFailure: decision.productRepairFailure,
261
- recoveryClass: decision.recoveryPlan.recoveryClass,
262
- allowedAction: decision.recoveryPlan.allowedAction,
263
- dispatchAction: decision.recoveryAction.allowedDispatchAction,
264
- evidenceOnly: decision.recoveryAction.evidenceOnly,
265
- productRepairAllowed: decision.recoveryAction.productRepairAllowed,
266
- expensiveModelAllowed: decision.recoveryAction.expensiveModelAllowed,
267
- costCeilingUsd: decision.recoveryAction.costCeilingUsd,
268
- requiresNewEvidence: ((_a = decision.recoveryAction.retryPolicy) === null || _a === void 0 ? void 0 : _a.requireNewEvidence) === true,
269
- nextCommands: decision.recoveryAction.nextCommands,
270
- requiredEvidence: decision.recoveryAction.requiredArtifacts,
271
- forbiddenActions: decision.recoveryPlan.forbiddenActions
272
- }
273
- };
274
- }
275
- function managerRecoveryExecutionProofGate(proof, now) {
276
- if (!proof || !Object.keys(proof).length) {
277
- return undefined;
278
- }
279
- var validation = (0, ai_runner_manager_policy_1.validateResolveIOAIManagerRecoveryExecutionProofContract)(proof);
280
- var normalized = validation.normalized;
281
- var statusText = cleanText(normalized.status, 120);
282
- var gateStatus = validation.valid && normalized.canContinueRun === true && statusText === 'proof_ready'
283
- ? 'pass'
284
- : statusText === 'manual_handoff'
285
- ? 'warn'
286
- : 'blocked';
287
- return {
288
- key: 'manager_recovery_execution_proof',
289
- label: 'Manager recovery execution proof',
290
- status: gateStatus,
291
- reason: normalized.blockers[0] || validation.blockers[0] || statusText || 'Manager recovery execution proof recorded.',
292
- evidenceRefs: normalized.artifactPaths,
293
- recordedAt: isoNow(now || normalized.createdAt),
294
- metadata: {
295
- contractId: normalized.contractId,
296
- directiveId: normalized.directiveId,
297
- surface: normalized.surface,
298
- dispatchAction: normalized.dispatchAction,
299
- phase: normalized.phase,
300
- status: statusText,
301
- canContinueRun: normalized.canContinueRun,
302
- canRunProductRepair: normalized.canRunProductRepair,
303
- canRunExpensiveModel: normalized.canRunExpensiveModel,
304
- canResetLoopBudget: normalized.canResetLoopBudget,
305
- proofRequiredBeforeContinuation: normalized.proofRequiredBeforeContinuation,
306
- requiresNewEvidence: normalized.requiresNewEvidence,
307
- newEvidence: normalized.newEvidence,
308
- materialEvidence: normalized.materialEvidence,
309
- evidenceStrength: normalized.evidenceStrength,
310
- evidenceSignals: normalized.evidenceSignals,
311
- startingFailureClass: normalized.startingFailureClass,
312
- startingBlockerFingerprint: normalized.startingBlockerFingerprint,
313
- startingEvidenceHash: normalized.startingEvidenceHash,
314
- latestFailureClass: normalized.latestFailureClass,
315
- latestBlockerFingerprint: normalized.latestBlockerFingerprint,
316
- latestEvidenceHash: normalized.latestEvidenceHash,
317
- requiredEvidence: normalized.requiredEvidence,
318
- missingEvidence: normalized.missingEvidence,
319
- changedFiles: normalized.changedFiles,
320
- blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(normalized.blockers), false), __read(validation.blockers), false))),
321
- nextAllowedAction: normalized.nextAllowedAction,
322
- forbiddenActions: normalized.forbiddenActions
323
- }
324
- };
325
- }
326
- function supportManagerNoBlindLoopGate(job, evidence, now) {
327
- return managerNoBlindLoopGateFromHistory(supportManagerFailureRecords(job, evidence), job.supportV5Budget || job.support_v5_budget || evidence.supportV5Budget || evidence.support_v5_budget, now);
328
- }
329
- function aicoderManagerFailureRecords(app, job, evidence) {
330
- var e_5, _a, e_6, _b, e_7, _c, e_8, _d;
331
- var records = [];
332
- var pushRecord = function (value, fallback) {
333
- if (fallback === void 0) { fallback = {}; }
334
- var record = normalizeManagerFailureRecord(value, __assign({ lane: 'aicoder', stepType: 'workflow_step' }, fallback));
335
- if (record) {
336
- records.push(record);
337
- }
338
- };
339
- var historySources = [
340
- job.aicoderV6StepHistory,
341
- job.aiCoderV6StepHistory,
342
- job.aicoder_v6_step_history,
343
- job.ai_coder_v6_step_history,
344
- job.workflowStepHistory,
345
- job.workflow_step_history,
346
- job.stepHistory,
347
- job.step_history,
348
- job.managerFailureHistory,
349
- job.manager_failure_history,
350
- app.aicoderV6StepHistory,
351
- app.aiCoderV6StepHistory,
352
- app.aicoder_v6_step_history,
353
- app.ai_coder_v6_step_history,
354
- app.workflowStepHistory,
355
- app.workflow_step_history,
356
- evidence.aicoderV6StepHistory,
357
- evidence.aiCoderV6StepHistory,
358
- evidence.aicoder_v6_step_history,
359
- evidence.ai_coder_v6_step_history,
360
- evidence.workflowStepHistory,
361
- evidence.workflow_step_history,
362
- evidence.stepHistory,
363
- evidence.step_history,
364
- evidence.managerFailureHistory,
365
- evidence.manager_failure_history
366
- ];
367
- try {
368
- for (var historySources_1 = __values(historySources), historySources_1_1 = historySources_1.next(); !historySources_1_1.done; historySources_1_1 = historySources_1.next()) {
369
- var source = historySources_1_1.value;
370
- try {
371
- for (var _e = (e_6 = void 0, __values(asArray(source))), _f = _e.next(); !_f.done; _f = _e.next()) {
372
- var entry = _f.value;
373
- pushRecord(entry);
374
- }
375
- }
376
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
377
- finally {
378
- try {
379
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
380
- }
381
- finally { if (e_6) throw e_6.error; }
382
- }
383
- }
384
- }
385
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
386
- finally {
387
- try {
388
- if (historySources_1_1 && !historySources_1_1.done && (_a = historySources_1.return)) _a.call(historySources_1);
389
- }
390
- finally { if (e_5) throw e_5.error; }
391
- }
392
- var fingerprintSources = [
393
- job.aicoderV6FailureFingerprints,
394
- job.aiCoderV6FailureFingerprints,
395
- job.aicoder_v6_failure_fingerprints,
396
- job.ai_coder_v6_failure_fingerprints,
397
- job.workflowFailureFingerprints,
398
- job.workflow_failure_fingerprints,
399
- job.failureFingerprints,
400
- job.failure_fingerprints,
401
- app.aicoderV6FailureFingerprints,
402
- app.aiCoderV6FailureFingerprints,
403
- app.aicoder_v6_failure_fingerprints,
404
- app.ai_coder_v6_failure_fingerprints,
405
- evidence.aicoderV6FailureFingerprints,
406
- evidence.aiCoderV6FailureFingerprints,
407
- evidence.aicoder_v6_failure_fingerprints,
408
- evidence.ai_coder_v6_failure_fingerprints,
409
- evidence.workflowFailureFingerprints,
410
- evidence.workflow_failure_fingerprints,
411
- evidence.failureFingerprints,
412
- evidence.failure_fingerprints
413
- ];
414
- try {
415
- for (var fingerprintSources_1 = __values(fingerprintSources), fingerprintSources_1_1 = fingerprintSources_1.next(); !fingerprintSources_1_1.done; fingerprintSources_1_1 = fingerprintSources_1.next()) {
416
- var source = fingerprintSources_1_1.value;
417
- try {
418
- for (var _g = (e_8 = void 0, __values(asArray(source))), _h = _g.next(); !_h.done; _h = _g.next()) {
419
- var entry = _h.value;
420
- var fingerprint = plainObject(entry);
421
- var count = Math.max(1, Math.min(8, Number(fingerprint.count || fingerprint.repeatedCount || fingerprint.repeated_count || 1) || 1));
422
- var fallback = {
423
- lane: cleanText(fingerprint.lane || 'aicoder', 80),
424
- stepType: cleanText(fingerprint.stepType || fingerprint.step_type || 'workflow_step', 80),
425
- outcome: cleanText(fingerprint.outcome || 'needs_repair', 80),
426
- failureClass: cleanText(fingerprint.failureClass || fingerprint.failure_class || fingerprint.class, 120),
427
- blocker: cleanText(fingerprint.blocker || fingerprint.reason || fingerprint.summary, 1200),
428
- blockerFingerprint: cleanText(fingerprint.blockerFingerprint || fingerprint.blocker_fingerprint, 180),
429
- evidenceHash: cleanText(fingerprint.evidenceHash || fingerprint.evidence_hash, 180)
430
- };
431
- for (var index = 0; index < count; index += 1) {
432
- pushRecord(fingerprint, fallback);
433
- }
434
- }
435
- }
436
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
437
- finally {
438
- try {
439
- if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
440
- }
441
- finally { if (e_8) throw e_8.error; }
442
- }
443
- }
444
- }
445
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
446
- finally {
447
- try {
448
- if (fingerprintSources_1_1 && !fingerprintSources_1_1.done && (_c = fingerprintSources_1.return)) _c.call(fingerprintSources_1);
449
- }
450
- finally { if (e_7) throw e_7.error; }
451
- }
452
- var currentFailure = evidenceObject(job.aicoderV6CurrentFailure, job.aiCoderV6CurrentFailure, job.aicoder_v6_current_failure, job.ai_coder_v6_current_failure, job.workflowCurrentFailure, job.workflow_current_failure, job.currentFailure, job.current_failure, evidence.aicoderV6CurrentFailure, evidence.aiCoderV6CurrentFailure, evidence.aicoder_v6_current_failure, evidence.ai_coder_v6_current_failure, evidence.workflowCurrentFailure, evidence.workflow_current_failure, evidence.currentFailure, evidence.current_failure);
453
- pushRecord(currentFailure);
454
- return records.slice(-80);
455
- }
456
- function aicoderManagerNoBlindLoopGate(app, job, evidence, now) {
457
- return managerNoBlindLoopGateFromHistory(aicoderManagerFailureRecords(app, job, evidence), job.aicoderV6Budget
458
- || job.aiCoderV6Budget
459
- || job.aicoder_v6_budget
460
- || job.ai_coder_v6_budget
461
- || evidence.aicoderV6Budget
462
- || evidence.aiCoderV6Budget
463
- || evidence.aicoder_v6_budget
464
- || evidence.ai_coder_v6_budget
465
- || app.aicoderV6Budget
466
- || app.aiCoderV6Budget
467
- || app.aicoder_v6_budget
468
- || app.ai_coder_v6_budget
469
- || job.budget
470
- || evidence.budget, now);
471
- }
472
- function managerNoBlindLoopMetadata(gate) {
473
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
474
- if (!gate) {
475
- return undefined;
476
- }
477
- return {
478
- action: cleanText((_a = gate.metadata) === null || _a === void 0 ? void 0 : _a.action, 120),
479
- status: gate.status,
480
- failureClass: cleanText((_b = gate.metadata) === null || _b === void 0 ? void 0 : _b.failureClass, 120),
481
- sameFailureCount: Number(((_c = gate.metadata) === null || _c === void 0 ? void 0 : _c.sameFailureCount) || 0),
482
- pingPongCount: Number(((_d = gate.metadata) === null || _d === void 0 ? void 0 : _d.pingPongCount) || 0),
483
- newEvidence: ((_e = gate.metadata) === null || _e === void 0 ? void 0 : _e.newEvidence) === true,
484
- materialEvidence: ((_f = gate.metadata) === null || _f === void 0 ? void 0 : _f.materialEvidence) === true,
485
- evidenceStrength: cleanText((_g = gate.metadata) === null || _g === void 0 ? void 0 : _g.evidenceStrength, 120),
486
- loopBudgetShouldReset: ((_h = gate.metadata) === null || _h === void 0 ? void 0 : _h.loopBudgetShouldReset) === true,
487
- dispatchAction: cleanText((_j = gate.metadata) === null || _j === void 0 ? void 0 : _j.dispatchAction, 160),
488
- productRepairAllowed: ((_k = gate.metadata) === null || _k === void 0 ? void 0 : _k.productRepairAllowed) === true,
489
- expensiveModelAllowed: ((_l = gate.metadata) === null || _l === void 0 ? void 0 : _l.expensiveModelAllowed) === true,
490
- productRepairFailure: ((_m = gate.metadata) === null || _m === void 0 ? void 0 : _m.productRepairFailure) === true,
491
- requiresNewEvidence: ((_o = gate.metadata) === null || _o === void 0 ? void 0 : _o.requiresNewEvidence) === true
492
- };
493
- }
494
- function hotfixEvidenceCandidates() {
495
- var e_9, _a;
496
- var sources = [];
497
- for (var _i = 0; _i < arguments.length; _i++) {
498
- sources[_i] = arguments[_i];
499
- }
500
- var result = [];
501
- var seen = new Set();
502
- var pushCandidate = function (value) {
503
- var e_10, _a, e_11, _b;
504
- var _c, _d;
505
- if (Array.isArray(value)) {
506
- try {
507
- for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
508
- var entry = value_1_1.value;
509
- pushCandidate(entry);
510
- }
511
- }
512
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
513
- finally {
514
- try {
515
- if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
516
- }
517
- finally { if (e_10) throw e_10.error; }
518
- }
519
- return;
520
- }
521
- if (!value || typeof value !== 'object') {
522
- return;
523
- }
524
- var nestedValues = [
525
- value.hotfixEvidence,
526
- value.hotfix_evidence,
527
- value.releaseHotfixEvidence,
528
- value.release_hotfix_evidence,
529
- value.managerHotfixEvidence,
530
- value.manager_hotfix_evidence,
531
- value.backendHotfixEvidence,
532
- value.backend_hotfix_evidence
533
- ].filter(Boolean);
534
- if (nestedValues.length) {
535
- try {
536
- for (var nestedValues_1 = __values(nestedValues), nestedValues_1_1 = nestedValues_1.next(); !nestedValues_1_1.done; nestedValues_1_1 = nestedValues_1.next()) {
537
- var nestedValue = nestedValues_1_1.value;
538
- pushCandidate(nestedValue);
539
- }
540
- }
541
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
542
- finally {
543
- try {
544
- if (nestedValues_1_1 && !nestedValues_1_1.done && (_b = nestedValues_1.return)) _b.call(nestedValues_1);
545
- }
546
- finally { if (e_11) throw e_11.error; }
547
- }
548
- return;
549
- }
550
- if (!(value.channel || value.hotfixChannel || value.hotfix_channel)) {
551
- return;
552
- }
553
- var key = JSON.stringify({
554
- channel: value.channel || value.hotfixChannel || value.hotfix_channel,
555
- host: ((_c = value.target) === null || _c === void 0 ? void 0 : _c.host) || value.host,
556
- path: ((_d = value.target) === null || _d === void 0 ? void 0 : _d.path) || value.path || value.remotePath || value.remote_path,
557
- checksum: value.remoteChecksumAfter || value.remote_checksum_after || value.remoteChecksum || value.remote_checksum
558
- });
559
- if (seen.has(key)) {
560
- return;
561
- }
562
- seen.add(key);
563
- result.push(value);
564
- };
565
- try {
566
- for (var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()) {
567
- var source = sources_1_1.value;
568
- pushCandidate(source);
569
- }
570
- }
571
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
572
- finally {
573
- try {
574
- if (sources_1_1 && !sources_1_1.done && (_a = sources_1.return)) _a.call(sources_1);
575
- }
576
- finally { if (e_9) throw e_9.error; }
577
- }
578
- return result;
579
- }
580
- function hotfixEvidenceArtifactPaths(evidence, normalized) {
581
- var _a;
582
- return [
583
- normalized === null || normalized === void 0 ? void 0 : normalized.compiledArtifactPath,
584
- normalized === null || normalized === void 0 ? void 0 : normalized.builtDistPath,
585
- (_a = normalized === null || normalized === void 0 ? void 0 : normalized.target) === null || _a === void 0 ? void 0 : _a.artifactPath,
586
- evidence.compiledArtifactPath,
587
- evidence.compiled_artifact_path,
588
- evidence.builtDistPath,
589
- evidence.built_dist_path,
590
- evidence.artifactPath,
591
- evidence.artifact_path
592
- ].map(function (entry) { return cleanText(entry, 500); }).filter(Boolean).slice(0, 8);
593
- }
594
- function hotfixEvidenceGate(evidence, now) {
595
- var _a, _b;
596
- var validation = (0, ai_runner_manager_policy_1.validateResolveIOAIManagerHotfixEvidence)(evidence);
597
- if (!validation.normalized && validation.status === 'missing') {
598
- return undefined;
599
- }
600
- var status = validation.valid
601
- ? (validation.fullDeployAllowed ? 'warn' : 'pass')
602
- : validation.status === 'blocked'
603
- ? 'blocked'
604
- : 'fail';
605
- var reason = validation.valid
606
- ? validation.fullDeployAllowed
607
- ? 'Hotfix evidence allows exactly one full deploy after force/new-artifact proof.'
608
- : 'Hotfix evidence is sufficient; rerun the smallest release gate before continuing.'
609
- : validation.blockers.join('; ');
610
- return {
611
- key: 'hotfix_evidence',
612
- label: 'Hotfix evidence',
613
- status: status,
614
- reason: reason,
615
- evidenceRefs: hotfixEvidenceArtifactPaths(evidence, validation.normalized),
616
- recordedAt: isoNow(now || ((_a = validation.normalized) === null || _a === void 0 ? void 0 : _a.recordedAt)),
617
- metadata: {
618
- channel: validation.channel,
619
- nextAction: validation.nextAction,
620
- fullDeployAllowed: validation.fullDeployAllowed,
621
- fullDeployBlocked: validation.fullDeployBlocked,
622
- hotfixSatisfied: validation.hotfixSatisfied,
623
- blockers: validation.blockers,
624
- githubCommitGuard: validation.githubCommitGuard,
625
- target: (_b = validation.normalized) === null || _b === void 0 ? void 0 : _b.target
626
- }
627
- };
628
- }
629
- function hotfixCommitProofGate(evidence, now) {
630
- var _a;
631
- var validation = (0, ai_runner_manager_policy_1.validateResolveIOAIManagerHotfixEvidence)(evidence);
632
- var guard = validation.githubCommitGuard;
633
- if (!guard.required) {
634
- return undefined;
635
- }
636
- var status = guard.passed
637
- ? 'pass'
638
- : guard.status === 'invalid'
639
- ? 'fail'
640
- : 'blocked';
641
- return {
642
- key: 'hotfix_commit_proof',
643
- label: 'Hotfix GitHub commit proof',
644
- status: status,
645
- reason: guard.passed
646
- ? 'Hotfix has matching sourceCommitSha, GitHub commit URL, passed gitCommitStatus, and passed gitPushStatus.'
647
- : (guard.blockers.join('; ') || 'Manager hotfix is blocked until sourceCommitSha, githubCommitUrl, passed gitCommitStatus, and passed gitPushStatus prove the hotfix is committed and pushed to GitHub.'),
648
- evidenceRefs: cleanStringList([guard.githubCommitUrl], 1, 500),
649
- recordedAt: isoNow(now || ((_a = validation.normalized) === null || _a === void 0 ? void 0 : _a.recordedAt)),
650
- metadata: {
651
- channel: guard.channel || validation.channel,
652
- status: guard.status,
653
- passed: guard.passed,
654
- managerMustCommitBeforeHotfix: guard.managerMustCommitBeforeHotfix,
655
- sourceCommitSha: guard.sourceCommitSha,
656
- githubCommitUrl: guard.githubCommitUrl,
657
- githubCommitSha: guard.githubCommitSha,
658
- gitCommitStatus: guard.gitCommitStatus,
659
- gitPushStatus: guard.gitPushStatus,
660
- blockers: guard.blockers,
661
- nextCommands: guard.nextCommands,
662
- requiredEvidence: guard.requiredEvidence
663
- }
664
- };
665
- }
666
- function hotfixDurabilityContractCandidates() {
667
- var e_12, _a;
668
- var sources = [];
669
- for (var _i = 0; _i < arguments.length; _i++) {
670
- sources[_i] = arguments[_i];
671
- }
672
- var result = [];
673
- var seen = new Set();
674
- var pushCandidate = function (value) {
675
- var e_13, _a, e_14, _b;
676
- var _c, _d;
677
- if (Array.isArray(value)) {
678
- try {
679
- for (var value_2 = __values(value), value_2_1 = value_2.next(); !value_2_1.done; value_2_1 = value_2.next()) {
680
- var entry = value_2_1.value;
681
- pushCandidate(entry);
682
- }
683
- }
684
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
685
- finally {
686
- try {
687
- if (value_2_1 && !value_2_1.done && (_a = value_2.return)) _a.call(value_2);
688
- }
689
- finally { if (e_13) throw e_13.error; }
690
- }
691
- return;
692
- }
693
- if (!value || typeof value !== 'object') {
694
- return;
695
- }
696
- var nestedValues = [
697
- value.hotfixDurabilityContract,
698
- value.hotfix_durability_contract,
699
- value.supportManagerHotfixDurabilityContract,
700
- value.support_manager_hotfix_durability_contract,
701
- value.managerRecoveryHotfixDurability,
702
- value.manager_recovery_hotfix_durability,
703
- (_c = value.supportV5RecoveryDirective) === null || _c === void 0 ? void 0 : _c.hotfixDurabilityContract,
704
- (_d = value.supportV5RecoveryDirective) === null || _d === void 0 ? void 0 : _d.hotfix_durability_contract
705
- ].filter(Boolean);
706
- if (nestedValues.length) {
707
- try {
708
- for (var nestedValues_2 = __values(nestedValues), nestedValues_2_1 = nestedValues_2.next(); !nestedValues_2_1.done; nestedValues_2_1 = nestedValues_2.next()) {
709
- var nestedValue = nestedValues_2_1.value;
710
- pushCandidate(nestedValue);
711
- }
712
- }
713
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
714
- finally {
715
- try {
716
- if (nestedValues_2_1 && !nestedValues_2_1.done && (_b = nestedValues_2.return)) _b.call(nestedValues_2);
717
- }
718
- finally { if (e_14) throw e_14.error; }
719
- }
720
- }
721
- var required = value.required === true || value.liveHotfixBlockedUntilCommit === true || value.live_hotfix_blocked_until_commit === true || value.commitProofPassed === true || value.commit_proof_passed === true;
722
- if (!required) {
723
- return;
724
- }
725
- var key = cleanText(value.contractId || value.contract_id || JSON.stringify({
726
- status: value.status,
727
- sha: value.sourceCommitSha || value.source_commit_sha,
728
- url: value.githubCommitUrl || value.github_commit_url
729
- }), 500);
730
- if (seen.has(key)) {
731
- return;
732
- }
733
- seen.add(key);
734
- result.push(value);
735
- };
736
- try {
737
- for (var sources_2 = __values(sources), sources_2_1 = sources_2.next(); !sources_2_1.done; sources_2_1 = sources_2.next()) {
738
- var source = sources_2_1.value;
739
- pushCandidate(source);
740
- }
741
- }
742
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
743
- finally {
744
- try {
745
- if (sources_2_1 && !sources_2_1.done && (_a = sources_2.return)) _a.call(sources_2);
746
- }
747
- finally { if (e_12) throw e_12.error; }
748
- }
749
- return result;
750
- }
751
- function hotfixDurabilityContractGate(contractValue, now) {
752
- var contract = (0, ai_runner_manager_policy_1.buildResolveIOAIManagerHotfixDurabilityContract)({
753
- existing: contractValue,
754
- evidence: contractValue.evidence || contractValue.hotfixEvidence || contractValue.hotfix_evidence,
755
- action: contractValue.action,
756
- reason: contractValue.reason,
757
- now: now
758
- });
759
- if (!contract.required) {
760
- return undefined;
761
- }
762
- var status = contract.liveHotfixBlockedUntilCommit
763
- ? 'blocked'
764
- : contract.status === 'ready_for_continuation' || contract.status === 'ready_for_release_gate'
765
- ? 'pass'
766
- : 'warn';
767
- return {
768
- key: 'hotfix_durability_contract',
769
- label: 'Hotfix durability contract',
770
- status: status,
771
- reason: contract.liveHotfixBlockedUntilCommit
772
- ? "Manager hotfix is blocked until GitHub commit proof is recorded: ".concat(contract.missingCommitProofFields.join(', ') || 'sourceCommitSha, githubCommitUrl, gitCommitStatus=passed, gitPushStatus=passed')
773
- : "Manager hotfix durability contract is ".concat(contract.status, "."),
774
- evidenceRefs: cleanStringList([contract.githubCommitUrl], 1, 500),
775
- recordedAt: isoNow(now || contract.updatedAt),
776
- metadata: {
777
- contractId: contract.contractId,
778
- status: contract.status,
779
- nextSafeAction: contract.nextSafeAction,
780
- canPrepareHotfixPatch: contract.canPrepareHotfixPatch,
781
- canHotfixBackend: contract.canHotfixBackend,
782
- liveHotfixBlockedUntilCommit: contract.liveHotfixBlockedUntilCommit,
783
- commitProofPassed: contract.commitProofPassed,
784
- commitProofStatus: contract.commitProofStatus,
785
- missingCommitProofFields: contract.missingCommitProofFields,
786
- sourceCommitSha: contract.sourceCommitSha,
787
- githubCommitUrl: contract.githubCommitUrl,
788
- gitCommitStatus: contract.gitCommitStatus,
789
- gitPushStatus: contract.gitPushStatus,
790
- phaseOrder: contract.phaseOrder,
791
- requiredFields: contract.requiredFields,
792
- forbiddenActions: contract.forbiddenActions
793
- }
794
- };
795
- }
796
- function collectHotfixEvidenceEvents(sources, events, gates, now) {
797
- var e_15, _a, e_16, _b;
798
- var _c, _d;
799
- try {
800
- for (var _e = __values(hotfixDurabilityContractCandidates.apply(void 0, __spreadArray([], __read(sources), false))), _f = _e.next(); !_f.done; _f = _e.next()) {
801
- var contract = _f.value;
802
- var gate = hotfixDurabilityContractGate(contract, now);
803
- if (gate) {
804
- gates.push(gate);
805
- pushEvent(events, {
806
- type: 'log',
807
- category: 'hotfix_durability_contract',
808
- message: gate.reason,
809
- artifactPaths: gate.evidenceRefs,
810
- recordedAt: gate.recordedAt,
811
- metadata: gate.metadata
812
- });
813
- }
814
- }
815
- }
816
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
817
- finally {
818
- try {
819
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
820
- }
821
- finally { if (e_15) throw e_15.error; }
822
- }
823
- try {
824
- for (var _g = __values(hotfixEvidenceCandidates.apply(void 0, __spreadArray([], __read(sources), false))), _h = _g.next(); !_h.done; _h = _g.next()) {
825
- var evidence = _h.value;
826
- var validation = (0, ai_runner_manager_policy_1.validateResolveIOAIManagerHotfixEvidence)(evidence);
827
- if (!validation.normalized && validation.status === 'missing') {
828
- continue;
829
- }
830
- var artifactPaths = hotfixEvidenceArtifactPaths(evidence, validation.normalized);
831
- pushEvent(events, {
832
- type: 'hotfix',
833
- category: validation.channel || 'hotfix',
834
- message: validation.valid
835
- ? "Hotfix evidence recorded for ".concat(validation.channel, ".")
836
- : "Incomplete hotfix evidence for ".concat(validation.channel || 'unknown channel', "."),
837
- artifactPaths: artifactPaths,
838
- recordedAt: ((_c = validation.normalized) === null || _c === void 0 ? void 0 : _c.recordedAt) || eventDate(evidence),
839
- metadata: {
840
- status: validation.status,
841
- nextAction: validation.nextAction,
842
- fullDeployAllowed: validation.fullDeployAllowed,
843
- fullDeployBlocked: validation.fullDeployBlocked,
844
- hotfixSatisfied: validation.hotfixSatisfied,
845
- blockers: validation.blockers,
846
- githubCommitGuard: validation.githubCommitGuard,
847
- target: (_d = validation.normalized) === null || _d === void 0 ? void 0 : _d.target
848
- }
849
- });
850
- var gate = hotfixEvidenceGate(evidence, now);
851
- if (gate) {
852
- gates.push(gate);
853
- }
854
- var commitProofGate = hotfixCommitProofGate(evidence, now);
855
- if (commitProofGate) {
856
- gates.push(commitProofGate);
857
- pushEvent(events, {
858
- type: 'log',
859
- category: 'hotfix_commit_proof',
860
- message: commitProofGate.reason,
861
- artifactPaths: commitProofGate.evidenceRefs,
862
- recordedAt: commitProofGate.recordedAt,
863
- metadata: commitProofGate.metadata
864
- });
865
- }
866
- }
867
- }
868
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
869
- finally {
870
- try {
871
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
872
- }
873
- finally { if (e_16) throw e_16.error; }
874
- }
875
- }
876
- function hotfixDurabilityMetadata(gates) {
877
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
878
- var hotfixGate = gates.find(function (gate) { return gate.key === 'hotfix_evidence'; });
879
- var commitGate = gates.find(function (gate) { return gate.key === 'hotfix_commit_proof'; });
880
- var durabilityGate = gates.find(function (gate) { return gate.key === 'hotfix_durability_contract'; });
881
- if (!hotfixGate && !commitGate && !durabilityGate) {
882
- return undefined;
883
- }
884
- var commitBlocked = (!!commitGate && (commitGate.status === 'blocked' || commitGate.status === 'fail'))
885
- || ((_a = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _a === void 0 ? void 0 : _a.liveHotfixBlockedUntilCommit) === true;
886
- return {
887
- durabilityStatus: cleanText((_b = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _b === void 0 ? void 0 : _b.status, 80),
888
- durabilityGateStatus: cleanText(durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.status, 80),
889
- canPrepareHotfixPatch: ((_c = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _c === void 0 ? void 0 : _c.canPrepareHotfixPatch) === true,
890
- canHotfixBackend: ((_d = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _d === void 0 ? void 0 : _d.canHotfixBackend) === true,
891
- liveHotfixBlockedUntilCommit: ((_e = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _e === void 0 ? void 0 : _e.liveHotfixBlockedUntilCommit) === true,
892
- hotfixEvidenceStatus: cleanText(hotfixGate === null || hotfixGate === void 0 ? void 0 : hotfixGate.status, 80),
893
- hotfixSatisfied: ((_f = hotfixGate === null || hotfixGate === void 0 ? void 0 : hotfixGate.metadata) === null || _f === void 0 ? void 0 : _f.hotfixSatisfied) === true,
894
- fullDeployBlocked: ((_g = hotfixGate === null || hotfixGate === void 0 ? void 0 : hotfixGate.metadata) === null || _g === void 0 ? void 0 : _g.fullDeployBlocked) === true,
895
- fullDeployAllowed: ((_h = hotfixGate === null || hotfixGate === void 0 ? void 0 : hotfixGate.metadata) === null || _h === void 0 ? void 0 : _h.fullDeployAllowed) === true,
896
- commitProofRequired: !!commitGate || !!durabilityGate,
897
- commitProofStatus: cleanText((commitGate === null || commitGate === void 0 ? void 0 : commitGate.status) || ((_j = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _j === void 0 ? void 0 : _j.commitProofStatus), 80),
898
- commitProofPassed: ((_k = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _k === void 0 ? void 0 : _k.passed) === true || ((_l = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _l === void 0 ? void 0 : _l.commitProofPassed) === true,
899
- commitBlocked: commitBlocked,
900
- channel: cleanText(((_m = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _m === void 0 ? void 0 : _m.channel) || ((_o = hotfixGate === null || hotfixGate === void 0 ? void 0 : hotfixGate.metadata) === null || _o === void 0 ? void 0 : _o.channel), 120),
901
- sourceCommitSha: cleanText(((_p = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _p === void 0 ? void 0 : _p.sourceCommitSha) || ((_q = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _q === void 0 ? void 0 : _q.sourceCommitSha), 200),
902
- githubCommitUrl: cleanText(((_r = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _r === void 0 ? void 0 : _r.githubCommitUrl) || ((_s = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _s === void 0 ? void 0 : _s.githubCommitUrl), 500),
903
- gitCommitStatus: cleanText(((_t = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _t === void 0 ? void 0 : _t.gitCommitStatus) || ((_u = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _u === void 0 ? void 0 : _u.gitCommitStatus), 120),
904
- gitPushStatus: cleanText(((_v = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _v === void 0 ? void 0 : _v.gitPushStatus) || ((_w = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _w === void 0 ? void 0 : _w.gitPushStatus), 120),
905
- blockers: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray((_x = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _x === void 0 ? void 0 : _x.missingCommitProofFields)), false), __read(asArray((_y = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _y === void 0 ? void 0 : _y.blockers)), false), __read(asArray((_z = hotfixGate === null || hotfixGate === void 0 ? void 0 : hotfixGate.metadata) === null || _z === void 0 ? void 0 : _z.blockers)), false), 20, 500),
906
- requiredEvidence: cleanStringList(((_0 = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _0 === void 0 ? void 0 : _0.requiredEvidence) || ((_1 = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _1 === void 0 ? void 0 : _1.requiredFields), 20, 500),
907
- nextCommands: cleanStringList((_2 = commitGate === null || commitGate === void 0 ? void 0 : commitGate.metadata) === null || _2 === void 0 ? void 0 : _2.nextCommands, 20, 240),
908
- nextAction: commitBlocked
909
- ? cleanText((_3 = durabilityGate === null || durabilityGate === void 0 ? void 0 : durabilityGate.metadata) === null || _3 === void 0 ? void 0 : _3.nextSafeAction, 200) || 'Commit and push the hotfix to GitHub, record sourceCommitSha/githubCommitUrl/gitCommitStatus/gitPushStatus, then rerun the smallest verification gate.'
910
- : cleanText((_4 = hotfixGate === null || hotfixGate === void 0 ? void 0 : hotfixGate.metadata) === null || _4 === void 0 ? void 0 : _4.nextAction, 1000)
911
- };
912
- }
913
- function collectUsageEvents(entries, events) {
914
- var e_17, _a;
915
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
916
- if (!entries.length) {
917
- return undefined;
918
- }
919
- var normalizedEntries = (0, ai_run_evidence_1.normalizeOpenAIUsageRowsForCosting)(entries);
920
- try {
921
- for (var normalizedEntries_1 = __values(normalizedEntries), normalizedEntries_1_1 = normalizedEntries_1.next(); !normalizedEntries_1_1.done; normalizedEntries_1_1 = normalizedEntries_1.next()) {
922
- var entry = normalizedEntries_1_1.value;
923
- pushEvent(events, {
924
- type: 'usage',
925
- category: cleanText(entry.category || entry.kind || entry.phase, 160) || 'usage',
926
- message: cleanText(entry.summary || entry.description || entry.model || 'Model usage recorded.', 800),
927
- recordedAt: eventDate(entry),
928
- metadata: {
929
- model: entry.model,
930
- inputTokens: (_b = entry.inputTokens) !== null && _b !== void 0 ? _b : entry.input_tokens,
931
- outputTokens: (_c = entry.outputTokens) !== null && _c !== void 0 ? _c : entry.output_tokens,
932
- totalTokens: (_d = entry.totalTokens) !== null && _d !== void 0 ? _d : entry.total_tokens,
933
- estimatedUsd: (_e = entry.estimatedUsd) !== null && _e !== void 0 ? _e : entry.cost_estimate,
934
- usageSource: (_f = entry.usage_source) !== null && _f !== void 0 ? _f : entry.usageSource,
935
- usageSurface: (_g = entry.usage_surface) !== null && _g !== void 0 ? _g : entry.usageSurface,
936
- usagePhase: (_h = entry.usage_phase) !== null && _h !== void 0 ? _h : entry.usagePhase,
937
- costBasis: (_j = entry.cost_basis) !== null && _j !== void 0 ? _j : entry.costBasis,
938
- isManual: (_k = entry.is_manual) !== null && _k !== void 0 ? _k : entry.isManual,
939
- isUntracked: (_l = entry.is_untracked) !== null && _l !== void 0 ? _l : entry.isUntracked,
940
- untrackedReason: (_m = entry.untracked_reason) !== null && _m !== void 0 ? _m : entry.untrackedReason
941
- }
942
- });
943
- }
944
- }
945
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
946
- finally {
947
- try {
948
- if (normalizedEntries_1_1 && !normalizedEntries_1_1.done && (_a = normalizedEntries_1.return)) _a.call(normalizedEntries_1);
949
- }
950
- finally { if (e_17) throw e_17.error; }
951
- }
952
- return (0, ai_run_evidence_1.buildAIRunCost)(entries);
953
- }
954
- function collectCommitEvents(commits, events) {
955
- var e_18, _a;
956
- try {
957
- for (var _b = __values(commits.slice(0, 80)), _c = _b.next(); !_c.done; _c = _b.next()) {
958
- var commit = _c.value;
959
- pushEvent(events, {
960
- type: 'git_commit',
961
- message: cleanText(commit.message || commit.subject || commit.title || commit.hash || commit.sha, 1200),
962
- recordedAt: eventDate(commit),
963
- metadata: {
964
- sha: commit.sha || commit.hash,
965
- branch: commit.branch,
966
- author: commit.author
967
- }
968
- });
969
- }
970
- }
971
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
972
- finally {
973
- try {
974
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
975
- }
976
- finally { if (e_18) throw e_18.error; }
977
- }
978
- }
979
- function statusFromBoolean(value, fallback) {
980
- if (value === true) {
981
- return 'pass';
982
- }
983
- if (value === false) {
984
- return 'fail';
985
- }
986
- return fallback;
987
- }
988
- function collectArtifacts(evidence) {
989
- var e_19, _a, e_20, _b, e_21, _c;
990
- var artifacts = [];
991
- try {
992
- for (var _d = __values(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.artifacts)), _e = _d.next(); !_e.done; _e = _d.next()) {
993
- var entry = _e.value;
994
- artifacts.push({
995
- type: entry.type || 'other',
996
- path: cleanText(entry.path || entry.file || entry.artifactPath, 500),
997
- url: cleanText(entry.url, 500),
998
- title: cleanText(entry.title || entry.name, 300),
999
- caption: cleanText(entry.caption || entry.message, 800),
1000
- metadata: entry.metadata
1001
- });
1002
- }
1003
- }
1004
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
1005
- finally {
1006
- try {
1007
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1008
- }
1009
- finally { if (e_19) throw e_19.error; }
1010
- }
1011
- var screenshots = asArray((evidence === null || evidence === void 0 ? void 0 : evidence.screenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.qaScreenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.browserScreenshots));
1012
- try {
1013
- for (var _f = __values(screenshots.slice(0, 40)), _g = _f.next(); !_g.done; _g = _f.next()) {
1014
- var screenshot = _g.value;
1015
- if (typeof screenshot === 'string') {
1016
- artifacts.push({ type: 'screenshot', path: screenshot });
1017
- }
1018
- else {
1019
- artifacts.push({
1020
- type: 'screenshot',
1021
- path: cleanText(screenshot.path || screenshot.file, 500),
1022
- url: cleanText(screenshot.url, 500),
1023
- title: cleanText(screenshot.title || screenshot.route, 300),
1024
- caption: cleanText(screenshot.caption || screenshot.message, 800),
1025
- metadata: screenshot.metadata
1026
- });
1027
- }
1028
- }
1029
- }
1030
- catch (e_20_1) { e_20 = { error: e_20_1 }; }
1031
- finally {
1032
- try {
1033
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
1034
- }
1035
- finally { if (e_20) throw e_20.error; }
1036
- }
1037
- var artifactRefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.artifactPaths)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.artifact_paths)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.runnerEvidenceArtifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.runner_evidence_artifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.supportQaArtifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.support_qa_artifacts)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.qa_artifacts)), false);
1038
- try {
1039
- for (var _h = __values(artifactRefs.slice(0, 60)), _j = _h.next(); !_j.done; _j = _h.next()) {
1040
- var entry = _j.value;
1041
- if (typeof entry === 'string') {
1042
- artifacts.push({ type: 'other', path: cleanText(entry, 500) });
1043
- }
1044
- else if (entry && typeof entry === 'object') {
1045
- artifacts.push({
1046
- type: entry.type || 'other',
1047
- path: cleanText(entry.path || entry.file || entry.artifactPath || entry.artifact_path, 500),
1048
- url: cleanText(entry.url, 500),
1049
- title: cleanText(entry.title || entry.name || entry.label, 300),
1050
- caption: cleanText(entry.caption || entry.message || entry.summary, 800),
1051
- metadata: entry.metadata
1052
- });
1053
- }
1054
- }
1055
- }
1056
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
1057
- finally {
1058
- try {
1059
- if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
1060
- }
1061
- finally { if (e_21) throw e_21.error; }
1062
- }
1063
- return artifacts;
1064
- }
1065
- function collectInfraChecks(evidence) {
1066
- var e_22, _a;
1067
- var _b;
1068
- var checks = [];
1069
- try {
1070
- for (var _c = __values(asArray((evidence === null || evidence === void 0 ? void 0 : evidence.infraChecks) || (evidence === null || evidence === void 0 ? void 0 : evidence.preflightChecks))), _d = _c.next(); !_d.done; _d = _c.next()) {
1071
- var entry = _d.value;
1072
- checks.push({
1073
- name: cleanText(entry.name || entry.check || entry.key, 160) || 'infra_check',
1074
- status: entry.status || statusFromBoolean(entry.passed),
1075
- message: cleanText(entry.message || entry.error || entry.reason, 1000),
1076
- path: cleanText(entry.path, 500),
1077
- durationMs: Number((_b = entry.durationMs) !== null && _b !== void 0 ? _b : entry.duration_ms) || undefined,
1078
- metadata: entry.metadata,
1079
- checkedAt: eventDate(entry)
1080
- });
1081
- }
1082
- }
1083
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
1084
- finally {
1085
- try {
1086
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1087
- }
1088
- finally { if (e_22) throw e_22.error; }
1089
- }
1090
- if (evidence === null || evidence === void 0 ? void 0 : evidence.preflightStatus) {
1091
- checks.push({
1092
- name: 'qa_preflight',
1093
- status: evidence.preflightStatus,
1094
- message: cleanText(evidence.preflightMessage || evidence.preflightReason, 1000),
1095
- path: cleanText(evidence.preflightArtifactPath || evidence.preflightPath, 500)
1096
- });
1097
- }
1098
- return checks;
1099
- }
1100
- function collectCompileResult(evidence) {
1101
- var _a, _b, _c;
1102
- var build = (evidence === null || evidence === void 0 ? void 0 : evidence.compile) || (evidence === null || evidence === void 0 ? void 0 : evidence.build) || (evidence === null || evidence === void 0 ? void 0 : evidence.buildEvidence) || (evidence === null || evidence === void 0 ? void 0 : evidence.buildResult);
1103
- if (!build && (evidence === null || evidence === void 0 ? void 0 : evidence.compileStatus) === undefined && (evidence === null || evidence === void 0 ? void 0 : evidence.buildStatus) === undefined) {
1104
- return undefined;
1105
- }
1106
- var status = (build === null || build === void 0 ? void 0 : build.status)
1107
- || (evidence === null || evidence === void 0 ? void 0 : evidence.compileStatus)
1108
- || (evidence === null || evidence === void 0 ? void 0 : evidence.buildStatus)
1109
- || statusFromBoolean((_b = (_a = build === null || build === void 0 ? void 0 : build.passed) !== null && _a !== void 0 ? _a : build === null || build === void 0 ? void 0 : build.allExpectedPassed) !== null && _b !== void 0 ? _b : evidence === null || evidence === void 0 ? void 0 : evidence.buildPassed);
1110
- return {
1111
- status: status,
1112
- command: cleanText((build === null || build === void 0 ? void 0 : build.command) || (evidence === null || evidence === void 0 ? void 0 : evidence.buildCommand), 500),
1113
- artifactPath: cleanText((build === null || build === void 0 ? void 0 : build.artifactPath) || (build === null || build === void 0 ? void 0 : build.logPath) || (evidence === null || evidence === void 0 ? void 0 : evidence.buildLogPath), 500),
1114
- message: cleanText((build === null || build === void 0 ? void 0 : build.message) || (build === null || build === void 0 ? void 0 : build.error) || (evidence === null || evidence === void 0 ? void 0 : evidence.buildMessage), 1000),
1115
- durationMs: Number((_c = build === null || build === void 0 ? void 0 : build.durationMs) !== null && _c !== void 0 ? _c : build === null || build === void 0 ? void 0 : build.duration_ms) || undefined,
1116
- staleEvidence: (build === null || build === void 0 ? void 0 : build.staleEvidence) === true || (evidence === null || evidence === void 0 ? void 0 : evidence.staleBuildEvidence) === true,
1117
- recordedAt: eventDate(build || evidence || {})
1118
- };
1119
- }
1120
- function collectRouteProbes(evidence) {
1121
- var e_23, _a, e_24, _b;
1122
- var probes = [];
1123
- var rows = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.routeProbes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.route_probes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.routes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.browserRoutes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.browser_routes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflowProbes)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflow_probes)), false);
1124
- var directProbe = plainObject((evidence === null || evidence === void 0 ? void 0 : evidence.routeProbe) || (evidence === null || evidence === void 0 ? void 0 : evidence.route_probe) || (evidence === null || evidence === void 0 ? void 0 : evidence.workflowProbe) || (evidence === null || evidence === void 0 ? void 0 : evidence.workflow_probe));
1125
- if (Object.keys(directProbe).length) {
1126
- rows.push(directProbe);
1127
- }
1128
- try {
1129
- for (var rows_1 = __values(rows), rows_1_1 = rows_1.next(); !rows_1_1.done; rows_1_1 = rows_1.next()) {
1130
- var entry = rows_1_1.value;
1131
- probes.push({
1132
- route: cleanText(entry.route || entry.path || entry.url, 500) || '/',
1133
- status: entry.status || statusFromBoolean(entry.passed),
1134
- screenshot: cleanText(entry.screenshot || entry.screenshotPath, 500),
1135
- caption: cleanText(entry.caption || entry.message, 1000),
1136
- shellOnly: entry.shellOnly === true,
1137
- authenticated: entry.authenticated === true,
1138
- consoleErrors: asArray(entry.consoleErrors),
1139
- networkErrors: asArray(entry.networkErrors),
1140
- message: cleanText(entry.message || entry.error, 1000),
1141
- recordedAt: eventDate(entry)
1142
- });
1143
- }
1144
- }
1145
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
1146
- finally {
1147
- try {
1148
- if (rows_1_1 && !rows_1_1.done && (_a = rows_1.return)) _a.call(rows_1);
1149
- }
1150
- finally { if (e_23) throw e_23.error; }
1151
- }
1152
- var screenshots = asArray((evidence === null || evidence === void 0 ? void 0 : evidence.screenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.qaScreenshots) || (evidence === null || evidence === void 0 ? void 0 : evidence.browserScreenshots));
1153
- try {
1154
- for (var _c = __values(screenshots.slice(0, 20)), _d = _c.next(); !_d.done; _d = _c.next()) {
1155
- var screenshot = _d.value;
1156
- if (typeof screenshot === 'string') {
1157
- probes.push({ route: '/', status: 'pass', screenshot: screenshot, caption: 'Historical browser screenshot recorded.' });
1158
- }
1159
- else if (screenshot.route || screenshot.path || screenshot.url || screenshot.screenshot || screenshot.file) {
1160
- probes.push({
1161
- route: cleanText(screenshot.route || screenshot.url || screenshot.path, 500) || '/',
1162
- status: screenshot.status || statusFromBoolean(screenshot.passed, 'pass'),
1163
- screenshot: cleanText(screenshot.screenshot || screenshot.screenshotPath || screenshot.file || screenshot.path, 500),
1164
- caption: cleanText(screenshot.caption || screenshot.message, 1000),
1165
- shellOnly: screenshot.shellOnly === true,
1166
- authenticated: screenshot.authenticated === true,
1167
- recordedAt: eventDate(screenshot)
1168
- });
1169
- }
1170
- }
1171
- }
1172
- catch (e_24_1) { e_24 = { error: e_24_1 }; }
1173
- finally {
1174
- try {
1175
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
1176
- }
1177
- finally { if (e_24) throw e_24.error; }
1178
- }
1179
- return probes;
1180
- }
1181
- function collectBusinessAssertions(evidence) {
1182
- var e_25, _a;
1183
- var assertions = [];
1184
- var rows = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.businessAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.business_assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflowAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.workflow_assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.qaRows)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.qa_rows)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.rows)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.supportQaAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.support_qa_assertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.aiQaBusinessAssertions)), false), __read(asArray(evidence === null || evidence === void 0 ? void 0 : evidence.ai_qa_business_assertions)), false);
1185
- try {
1186
- for (var rows_2 = __values(rows), rows_2_1 = rows_2.next(); !rows_2_1.done; rows_2_1 = rows_2.next()) {
1187
- var entry = rows_2_1.value;
1188
- assertions.push({
1189
- assertion: cleanText(entry.assertion || entry.name || entry.label || entry.workflow || entry.expected, 1000) || 'business assertion',
1190
- status: entry.status || entry.outcome || entry.result || statusFromBoolean(entry.passed),
1191
- workflow: cleanText(entry.workflow || entry.workflowName || entry.workflow_name, 400),
1192
- route: cleanText(entry.route || entry.url, 500),
1193
- action: cleanText(entry.action || entry.action_under_test || entry.actionUnderTest, 500),
1194
- expected: cleanText(entry.expected || entry.expected_business_state_change || entry.expectedBusinessStateChange, 1000),
1195
- observed: cleanText(entry.observed || entry.actual || entry.after || entry.after_state || entry.afterState, 1000),
1196
- dataProof: cleanText(entry.dataProof || entry.data_proof || entry.domProof || entry.dom_proof || entry.proof || entry.summary, 1400),
1197
- mongoDelta: plainObject(entry.mongoDelta || entry.mongo_delta),
1198
- artifactPaths: cleanStringList(entry.artifactPaths || entry.artifact_paths || entry.artifacts || entry.screenshots || (entry.screenshot ? [entry.screenshot] : []), 30, 500),
1199
- message: cleanText(entry.message || entry.error || entry.reason, 1000),
1200
- recordedAt: eventDate(entry),
1201
- metadata: __assign(__assign(__assign({}, plainObject(entry.metadata)), (entry.acceptanceBlocked === true || entry.acceptance_blocked === true ? { acceptanceBlocked: true } : {})), (entry.routeOnly === true || entry.route_only === true ? { routeOnly: true } : {}))
1202
- });
1203
- }
1204
- }
1205
- catch (e_25_1) { e_25 = { error: e_25_1 }; }
1206
- finally {
1207
- try {
1208
- if (rows_2_1 && !rows_2_1.done && (_a = rows_2.return)) _a.call(rows_2);
1209
- }
1210
- finally { if (e_25) throw e_25.error; }
1211
- }
1212
- if (!assertions.length && (evidence === null || evidence === void 0 ? void 0 : evidence.qaRunOutcome) === 'business_assertion_passed') {
1213
- assertions.push({
1214
- assertion: cleanText(evidence.aiRunOutcomeReason || evidence.reason || 'Historical business assertion passed.', 1000),
1215
- status: 'pass',
1216
- dataProof: cleanText(evidence.aiRunOutcomeReason || evidence.reason, 1400)
1217
- });
1218
- }
1219
- if (!assertions.length && (evidence === null || evidence === void 0 ? void 0 : evidence.qaRunOutcome) === 'business_assertion_failed') {
1220
- assertions.push({
1221
- assertion: cleanText(evidence.aiRunOutcomeReason || evidence.reason || 'Historical business assertion failed.', 1000),
1222
- status: 'fail',
1223
- observed: cleanText(evidence.aiRunOutcomeReason || evidence.reason, 1000)
1224
- });
1225
- }
1226
- return assertions;
1227
- }
1228
- function buildQaFromEvidence(evidence, now) {
1229
- return (0, ai_run_evidence_1.buildAIQaRun)({
1230
- infraChecks: collectInfraChecks(evidence),
1231
- compile: collectCompileResult(evidence),
1232
- routeProbes: collectRouteProbes(evidence),
1233
- businessAssertions: collectBusinessAssertions(evidence),
1234
- artifacts: collectArtifacts(evidence),
1235
- now: now
1236
- });
1237
- }
1238
- function isoNow(value) {
1239
- if (value instanceof Date) {
1240
- return value.toISOString();
1241
- }
1242
- if (value) {
1243
- var parsed = new Date(value);
1244
- if (!Number.isNaN(parsed.getTime())) {
1245
- return parsed.toISOString();
1246
- }
1247
- }
1248
- return new Date().toISOString();
1249
- }
1250
- function normalizeMatchText(value) {
1251
- return cleanText(value, 3000)
1252
- .toLowerCase()
1253
- .replace(/[^a-z0-9]+/g, ' ')
1254
- .replace(/\s+/g, ' ')
1255
- .trim();
1256
- }
1257
- function importantTokens(value) {
1258
- var stopWords = new Set([
1259
- 'the', 'and', 'that', 'with', 'from', 'after', 'before', 'when', 'then', 'this', 'must',
1260
- 'should', 'will', 'only', 'into', 'have', 'has', 'are', 'was', 'were', 'been'
1261
- ]);
1262
- return new Set(normalizeMatchText(value).split(' ')
1263
- .filter(function (token) { return token.length >= 4 && !stopWords.has(token); }));
1264
- }
1265
- function businessAssertionPassed(assertion) {
1266
- return /^(pass|passed|success|ok|done)$/i.test(cleanText(assertion.status, 40));
1267
- }
1268
- function supportAssertionMatchesDiagnosisProof(assertion, proofPlan) {
1269
- var e_26, _a;
1270
- var metadata = assertion.metadata || {};
1271
- if (metadata.diagnosisProofPlanMatched === true || metadata.proofPlanMatched === true || metadata.supportDiagnosisProof === true) {
1272
- return true;
1273
- }
1274
- var requiredBusinessAssertion = proofPlan.business_assertion || proofPlan.businessAssertion;
1275
- var proofParts = [
1276
- requiredBusinessAssertion,
1277
- proofPlan.after,
1278
- proofPlan.data_assertion || proofPlan.dataAssertion,
1279
- proofPlan.artifact_expectation || proofPlan.artifactExpectation
1280
- ].map(function (part) { return normalizeMatchText(part); }).filter(function (part) { return part.length >= 16; });
1281
- if (!proofParts.length) {
1282
- return true;
1283
- }
1284
- var assertionText = normalizeMatchText([
1285
- assertion.assertion,
1286
- assertion.workflow,
1287
- assertion.action,
1288
- assertion.expected,
1289
- assertion.observed,
1290
- assertion.dataProof,
1291
- assertion.message
1292
- ].filter(Boolean).join(' '));
1293
- if (proofParts.some(function (part) { return assertionText.includes(part); })) {
1294
- return true;
1295
- }
1296
- var proofTokens = importantTokens([
1297
- requiredBusinessAssertion,
1298
- proofPlan.after,
1299
- proofPlan.data_assertion || proofPlan.dataAssertion
1300
- ].filter(Boolean).join(' '));
1301
- var assertionTokens = importantTokens(assertionText);
1302
- if (!proofTokens.size) {
1303
- return true;
1304
- }
1305
- var overlap = 0;
1306
- try {
1307
- for (var proofTokens_1 = __values(proofTokens), proofTokens_1_1 = proofTokens_1.next(); !proofTokens_1_1.done; proofTokens_1_1 = proofTokens_1.next()) {
1308
- var token = proofTokens_1_1.value;
1309
- if (assertionTokens.has(token)) {
1310
- overlap += 1;
1311
- }
1312
- }
1313
- }
1314
- catch (e_26_1) { e_26 = { error: e_26_1 }; }
1315
- finally {
1316
- try {
1317
- if (proofTokens_1_1 && !proofTokens_1_1.done && (_a = proofTokens_1.return)) _a.call(proofTokens_1);
1318
- }
1319
- finally { if (e_26) throw e_26.error; }
1320
- }
1321
- return overlap >= Math.min(4, Math.max(3, Math.ceil(proofTokens.size * 0.45)));
1322
- }
1323
- function supportDiagnosisProofGateResult(diagnosisGate, now) {
1324
- var proofPlan = diagnosisGate.proof_plan || diagnosisGate.proofPlan || {};
1325
- return {
1326
- key: 'support_diagnosis_business_proof',
1327
- label: 'Diagnosis proof plan',
1328
- status: 'blocked',
1329
- reason: 'Support business assertion did not map to the diagnosis proof_plan. Route proof or generic workflow proof cannot accept the ticket.',
1330
- evidenceRefs: [],
1331
- recordedAt: isoNow(now),
1332
- metadata: {
1333
- issueClass: cleanText(diagnosisGate.issue_class || diagnosisGate.issueClass, 120),
1334
- requiredBusinessAssertion: cleanText(proofPlan.business_assertion || proofPlan.businessAssertion, 1000),
1335
- requiredAfter: cleanText(proofPlan.after, 1000),
1336
- requiredDataAssertion: cleanText(proofPlan.data_assertion || proofPlan.dataAssertion, 1000)
1337
- }
1338
- };
1339
- }
1340
- var SUPPORT_ROOT_CAUSE_ENTRY_REQUIRED_FIELDS = [
1341
- 'issue_case',
1342
- 'issue_class',
1343
- 'accepted_hypothesis',
1344
- 'rejected_alternatives',
1345
- 'failing_path',
1346
- 'owner_files',
1347
- 'proof_plan',
1348
- 'evidence'
1349
- ];
1350
- var SUPPORT_ROOT_CAUSE_ENTRY_ISSUE_CLASSES = [
1351
- 'no_op_submit',
1352
- 'missing_wrong_data',
1353
- 'filter_query_mismatch',
1354
- 'invoice_pdf_export',
1355
- 'upload_import',
1356
- 'route_auth_hydration',
1357
- 'slow_query_performance'
1358
- ];
1359
- function supportRootCauseEntryContractGate(contract, now) {
1360
- if (!contract || !Object.keys(contract).length) {
1361
- return undefined;
1362
- }
1363
- var requiredOutput = plainObject(contract.required_output || contract.requiredOutput);
1364
- var ownerPolicy = plainObject(contract.owner_file_policy || contract.ownerFilePolicy);
1365
- var businessProofPolicy = plainObject(contract.business_proof_policy || contract.businessProofPolicy);
1366
- var failurePolicy = plainObject(contract.failure_policy || contract.failurePolicy);
1367
- var probes = asArray(contract.issue_class_probes || contract.issueClassProbes);
1368
- var requiredFields = cleanStringList(requiredOutput.required_fields || requiredOutput.requiredFields, 30, 160);
1369
- var issueClasses = probes.map(function (probe) { return cleanText(probe.issue_class || probe.issueClass, 120); }).filter(Boolean);
1370
- var missingRequiredFields = SUPPORT_ROOT_CAUSE_ENTRY_REQUIRED_FIELDS.filter(function (field) { return !requiredFields.includes(field); });
1371
- var missingIssueClasses = SUPPORT_ROOT_CAUSE_ENTRY_ISSUE_CLASSES.filter(function (issueClass) { return !issueClasses.includes(issueClass); });
1372
- var blockers = [];
1373
- if (!cleanText(contract.contract_id || contract.contractId, 160)) {
1374
- blockers.push('Root-cause entry contract is missing contract_id.');
1375
- }
1376
- if (cleanText(requiredOutput.object_key || requiredOutput.objectKey, 120) !== 'support_diagnosis_gate') {
1377
- blockers.push('Root-cause entry contract must require support_diagnosis_gate output.');
1378
- }
1379
- if (missingRequiredFields.length) {
1380
- blockers.push("Root-cause entry contract missing required output fields: ".concat(missingRequiredFields.join(', '), "."));
1381
- }
1382
- var ownerFileMax = Number(ownerPolicy.max_files || ownerPolicy.maxFiles || 0);
1383
- if (!Number.isFinite(ownerFileMax) || ownerFileMax <= 0 || ownerFileMax > 12) {
1384
- blockers.push('Root-cause entry contract must cap owner_files to a small exact file set.');
1385
- }
1386
- if (ownerPolicy.edits_outside_owner_files_require_revised_diagnosis !== true && ownerPolicy.editsOutsideOwnerFilesRequireRevisedDiagnosis !== true) {
1387
- blockers.push('Root-cause entry contract must require revised diagnosis before edits outside owner_files.');
1388
- }
1389
- if (businessProofPolicy.requires_aiqa_business_assertion !== true && businessProofPolicy.requiresAiqaBusinessAssertion !== true) {
1390
- blockers.push('Root-cause entry contract must require AIQaBusinessAssertion business proof.');
1391
- }
1392
- if (businessProofPolicy.route_load_screenshot_scorecard_model_claim_not_acceptance !== true && businessProofPolicy.routeLoadScreenshotScorecardModelClaimNotAcceptance !== true) {
1393
- blockers.push('Root-cause entry contract must reject route-load/screenshot/scorecard/model-claim acceptance.');
1394
- }
1395
- if (failurePolicy.repeated_failure_without_new_evidence_parks_run !== true && failurePolicy.repeatedFailureWithoutNewEvidenceParksRun !== true) {
1396
- blockers.push('Root-cause entry contract must park repeated failures without new evidence.');
1397
- }
1398
- if (missingIssueClasses.length) {
1399
- blockers.push("Root-cause entry contract missing issue-class probes: ".concat(missingIssueClasses.join(', '), "."));
1400
- }
1401
- var status = blockers.length ? 'fail' : 'pass';
1402
- return {
1403
- key: 'support_root_cause_entry_contract',
1404
- label: 'Root-cause entry contract',
1405
- status: status,
1406
- reason: blockers.length
1407
- ? blockers.join(' ')
1408
- : 'Support run has a structured root-cause-first entry contract with issue-class probes, owner-file policy, and business-proof policy.',
1409
- evidenceRefs: cleanStringList(businessProofPolicy.required_artifacts || businessProofPolicy.requiredArtifacts, 20, 500),
1410
- recordedAt: isoNow(now),
1411
- metadata: {
1412
- contractId: cleanText(contract.contract_id || contract.contractId, 160),
1413
- version: cleanText(contract.version, 120),
1414
- status: cleanText(contract.status, 120),
1415
- requiredOutputKey: cleanText(requiredOutput.object_key || requiredOutput.objectKey, 120),
1416
- requiredFields: requiredFields,
1417
- missingRequiredFields: missingRequiredFields,
1418
- ownerFileMax: ownerFileMax,
1419
- requiresRevisedDiagnosisForOutOfScopeEdits: ownerPolicy.edits_outside_owner_files_require_revised_diagnosis === true || ownerPolicy.editsOutsideOwnerFilesRequireRevisedDiagnosis === true,
1420
- requiresBusinessAssertion: businessProofPolicy.requires_aiqa_business_assertion === true || businessProofPolicy.requiresAiqaBusinessAssertion === true,
1421
- routeOnlyAcceptanceRejected: businessProofPolicy.route_load_screenshot_scorecard_model_claim_not_acceptance === true || businessProofPolicy.routeLoadScreenshotScorecardModelClaimNotAcceptance === true,
1422
- issueClassProbeCount: issueClasses.length,
1423
- issueClasses: issueClasses,
1424
- missingIssueClasses: missingIssueClasses
1425
- }
1426
- };
1427
- }
1428
- function applySupportDiagnosisProofGate(qa, diagnosisGate, now) {
1429
- var proofPlan = diagnosisGate.proof_plan || diagnosisGate.proofPlan || {};
1430
- var requiredBusinessAssertion = cleanText(proofPlan.business_assertion || proofPlan.businessAssertion, 1000);
1431
- var requiredAfter = cleanText(proofPlan.after, 1000);
1432
- if (!Object.keys(proofPlan).length || (!requiredBusinessAssertion && !requiredAfter)) {
1433
- return qa;
1434
- }
1435
- var passedAssertions = qa.businessAssertions.filter(businessAssertionPassed);
1436
- if (!passedAssertions.length) {
1437
- return qa;
1438
- }
1439
- if (passedAssertions.some(function (assertion) { return supportAssertionMatchesDiagnosisProof(assertion, proofPlan); })) {
1440
- return qa;
1441
- }
1442
- var gate = supportDiagnosisProofGateResult(diagnosisGate, now);
1443
- return __assign(__assign({}, qa), { outcome: qa.routeProbes.some(function (probe) { return /^(pass|passed|success|ok|done)$/i.test(cleanText(probe.status, 40)); })
1444
- ? 'route_only_pass'
1445
- : 'incomplete', gateResults: __spreadArray(__spreadArray([], __read(qa.gateResults.filter(function (existing) { return !(existing.key === 'qa_business_assertion' && existing.status === 'pass'); })), false), [
1446
- gate
1447
- ], false) });
1448
- }
1449
- var SUPPORT_PRODUCT_REPAIR_STEP_TYPES = new Set([
1450
- 'build_repair',
1451
- 'owner_scoped_repair',
1452
- 'product_repair',
1453
- 'code_repair'
1454
- ]);
1455
- var SUPPORT_PRODUCT_REPAIR_ACTIONS = new Set([
1456
- 'run_owner_scoped_repair',
1457
- 'run_targeted_product_repair',
1458
- 'allow_product_repair'
1459
- ]);
1460
- function supportSourceEditFiles(value) {
1461
- return cleanStringList(value, 80, 500)
1462
- .filter(function (filePath) {
1463
- var normalized = filePath.replace(/\\/g, '/').toLowerCase();
1464
- if (!normalized || /(^|\/)(qa-artifacts|runner-evidence|logs?|tmp|dist|node_modules)(\/|$)/.test(normalized)) {
1465
- return false;
1466
- }
1467
- return /\.(?:ts|tsx|js|jsx|html|scss|css|json|mjs|cjs|vue|svelte|md)$/i.test(normalized);
1468
- });
1469
- }
1470
- function supportRepairActivityFromRecord(value, source, index) {
1471
- var record = plainObject(value);
1472
- if (!Object.keys(record).length) {
1473
- return undefined;
1474
- }
1475
- var stepType = cleanText(record.stepType || record.step_type || record.type, 120);
1476
- var action = cleanText(record.action || record.primaryAction || record.primary_action || record.allowedDispatchAction || record.allowed_dispatch_action, 120);
1477
- var lane = cleanText(record.lane || record.phase || record.category, 120).toLowerCase();
1478
- var changedFiles = supportSourceEditFiles(record.changedFiles
1479
- || record.changed_files
1480
- || record.modifiedFiles
1481
- || record.modified_files
1482
- || record.editedFiles
1483
- || record.edited_files
1484
- || record.files);
1485
- var explicitProductRepair = SUPPORT_PRODUCT_REPAIR_STEP_TYPES.has(stepType)
1486
- || SUPPORT_PRODUCT_REPAIR_ACTIONS.has(action)
1487
- || (lane === 'build' && changedFiles.length > 0);
1488
- if (!explicitProductRepair) {
1489
- return undefined;
1490
- }
1491
- var activityRef = cleanText(record.microtaskId
1492
- || record.microtask_id
1493
- || record.taskId
1494
- || record.task_id
1495
- || record.jobId
1496
- || record.job_id
1497
- || record._id
1498
- || record.id
1499
- || "".concat(source, ":").concat(index), 240);
1500
- return { changedFiles: changedFiles, activityRef: activityRef };
1501
- }
1502
- function supportProductRepairEvidence(input, evidence) {
1503
- var job = input.job || {};
1504
- var records = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.supportV5StepHistory)), false), __read(asArray(job.support_v5_step_history)), false), __read(asArray(job.stepHistory)), false), __read(asArray(job.step_history)), false), __read(asArray(evidence.supportV5StepHistory)), false), __read(asArray(evidence.support_v5_step_history)), false), __read(asArray(evidence.stepHistory)), false), __read(asArray(evidence.step_history)), false), __read(asArray(input.taskEvents)), false), __read(asArray(input.aiJobs)), false), __read(asArray(input.buildPlans)), false);
1505
- var activityRefs = [];
1506
- var changedFiles = [];
1507
- var activityCount = 0;
1508
- records.forEach(function (record, index) {
1509
- var activity = supportRepairActivityFromRecord(record, 'support_repair_activity', index);
1510
- if (!activity) {
1511
- return;
1512
- }
1513
- activityCount += 1;
1514
- if (activity.activityRef) {
1515
- activityRefs.push(activity.activityRef);
1516
- }
1517
- changedFiles.push.apply(changedFiles, __spreadArray([], __read(activity.changedFiles), false));
1518
- });
1519
- var directChangedFiles = supportSourceEditFiles(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.changedFiles)), false), __read(asArray(job.changed_files)), false), __read(asArray(job.modifiedFiles)), false), __read(asArray(job.modified_files)), false), __read(asArray(job.editedFiles)), false), __read(asArray(job.edited_files)), false), __read(asArray(evidence.changedFiles)), false), __read(asArray(evidence.changed_files)), false), __read(asArray(evidence.modifiedFiles)), false), __read(asArray(evidence.modified_files)), false), __read(asArray(evidence.editedFiles)), false), __read(asArray(evidence.edited_files)), false), __read(asArray(input.commits).flatMap(function (commit) { return asArray(commit.changedFiles || commit.changed_files || commit.files); })), false));
1520
- if (directChangedFiles.length) {
1521
- activityCount += 1;
1522
- activityRefs.push('changed_files');
1523
- changedFiles.push.apply(changedFiles, __spreadArray([], __read(directChangedFiles), false));
1524
- }
1525
- var uniqueChangedFiles = Array.from(new Set(changedFiles.map(function (filePath) { return cleanText(filePath, 500); }).filter(Boolean))).slice(0, 80);
1526
- return {
1527
- attempted: activityCount > 0,
1528
- changedFiles: uniqueChangedFiles,
1529
- activityRefs: Array.from(new Set(activityRefs.map(function (ref) { return cleanText(ref, 240); }).filter(Boolean))).slice(0, 40),
1530
- activityCount: activityCount
1531
- };
1532
- }
1533
- function supportDiagnosisBeforeRepairGate(diagnosisGate, repairEvidence, now) {
1534
- var _a, _b;
1535
- if (!repairEvidence.attempted) {
1536
- return undefined;
1537
- }
1538
- var validation = (0, support_runner_v5_1.validateResolveIOSupportDiagnosisGate)(diagnosisGate);
1539
- var status = validation.valid ? 'pass' : 'blocked';
1540
- return {
1541
- key: 'support_diagnosis_before_repair',
1542
- label: 'Support diagnosis before repair',
1543
- status: status,
1544
- reason: validation.valid
1545
- ? 'Support product repair has a valid root-cause diagnosis gate and owner-file scope.'
1546
- : 'Support product repair is blocked until a valid SupportDiagnosisGate records reproduction/classification, accepted hypothesis, rejected alternatives, owner_files, and before/action/after proof.',
1547
- evidenceRefs: repairEvidence.changedFiles,
1548
- recordedAt: isoNow(now),
1549
- metadata: {
1550
- repairAttempted: true,
1551
- activityCount: repairEvidence.activityCount,
1552
- activityRefs: repairEvidence.activityRefs,
1553
- changedFiles: repairEvidence.changedFiles,
1554
- diagnosisValid: validation.valid,
1555
- diagnosisStatus: validation.status,
1556
- blockers: validation.blockers,
1557
- ownerFiles: ((_a = validation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || [],
1558
- issueClass: (_b = validation.normalized) === null || _b === void 0 ? void 0 : _b.issue_class,
1559
- productRepairAllowed: validation.valid,
1560
- allowedDispatchAction: validation.valid ? 'run_owner_scoped_repair' : 'run_read_only_diagnosis',
1561
- requiredEvidence: validation.valid
1562
- ? ['AIQaBusinessAssertion mapped to diagnosis proof_plan before acceptance']
1563
- : ['support_diagnosis_gate JSON', 'reproduction or blocked-reproduction reason', 'accepted_hypothesis with evidence', 'owner_files', 'proof_plan before/action/after']
1564
- }
1565
- };
1566
- }
1567
- function supportOwnerFileScopeGate(diagnosisGate, repairEvidence, now) {
1568
- if (!repairEvidence.attempted) {
1569
- return undefined;
1570
- }
1571
- var validation = (0, support_runner_v5_1.validateResolveIOSupportDiagnosisGate)(diagnosisGate);
1572
- if (!validation.valid || !validation.normalized) {
1573
- return undefined;
1574
- }
1575
- var outsideOwnerFiles = (0, support_runner_v5_1.changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles)(validation.normalized, repairEvidence.changedFiles, { allowTests: true });
1576
- var status = outsideOwnerFiles.length ? 'blocked' : 'pass';
1577
- return {
1578
- key: 'support_owner_file_scope',
1579
- label: 'Support owner-file scope',
1580
- status: status,
1581
- reason: outsideOwnerFiles.length
1582
- ? "Support repair changed files outside diagnosis owner_files; revise diagnosis with new evidence before broadening edits: ".concat(outsideOwnerFiles.join(', '))
1583
- : 'Support repair stayed within diagnosis owner_files; test-only changes are allowed as supporting evidence.',
1584
- evidenceRefs: outsideOwnerFiles.length ? outsideOwnerFiles : repairEvidence.changedFiles,
1585
- recordedAt: isoNow(now),
1586
- metadata: {
1587
- repairAttempted: true,
1588
- diagnosisValid: true,
1589
- issueClass: validation.normalized.issue_class,
1590
- ownerFiles: validation.normalized.owner_files,
1591
- changedFiles: repairEvidence.changedFiles,
1592
- outsideOwnerFiles: outsideOwnerFiles,
1593
- allowedTestFilesOutsideOwnerScope: true,
1594
- productRepairAllowed: outsideOwnerFiles.length === 0,
1595
- allowedDispatchAction: outsideOwnerFiles.length ? 'run_read_only_diagnosis' : 'run_business_proof_qa',
1596
- requiredEvidence: outsideOwnerFiles.length
1597
- ? ['revised SupportDiagnosisGate with evidence for each new owner file', 'updated failing_path and proof_plan matching broadened scope']
1598
- : ['compile/unit proof', 'AIQaBusinessAssertion mapped to diagnosis proof_plan']
1599
- }
1600
- };
1601
- }
1602
- function evidenceObject() {
1603
- var e_27, _a;
1604
- var values = [];
1605
- for (var _i = 0; _i < arguments.length; _i++) {
1606
- values[_i] = arguments[_i];
1607
- }
1608
- try {
1609
- for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
1610
- var value = values_1_1.value;
1611
- if (value && typeof value === 'object' && !Array.isArray(value)) {
1612
- return value;
1613
- }
1614
- }
1615
- }
1616
- catch (e_27_1) { e_27 = { error: e_27_1 }; }
1617
- finally {
1618
- try {
1619
- if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
1620
- }
1621
- finally { if (e_27) throw e_27.error; }
1622
- }
1623
- return {};
1624
- }
1625
- function mergeEvidenceRecords() {
1626
- var e_28, _a, e_29, _b;
1627
- var values = [];
1628
- for (var _i = 0; _i < arguments.length; _i++) {
1629
- values[_i] = arguments[_i];
1630
- }
1631
- var merged = {};
1632
- try {
1633
- for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) {
1634
- var value = values_2_1.value;
1635
- var source = plainObject(value);
1636
- try {
1637
- for (var _c = (e_29 = void 0, __values(Object.entries(source))), _d = _c.next(); !_d.done; _d = _c.next()) {
1638
- var _e = __read(_d.value, 2), key = _e[0], entry = _e[1];
1639
- if (entry === undefined || entry === null || entry === '') {
1640
- continue;
1641
- }
1642
- if (Array.isArray(entry)) {
1643
- merged[key] = __spreadArray(__spreadArray([], __read(asArray(merged[key])), false), __read(entry), false);
1644
- continue;
1645
- }
1646
- if (plainObject(entry) === entry && plainObject(merged[key]) === merged[key]) {
1647
- merged[key] = __assign(__assign({}, merged[key]), entry);
1648
- continue;
1649
- }
1650
- merged[key] = entry;
1651
- }
1652
- }
1653
- catch (e_29_1) { e_29 = { error: e_29_1 }; }
1654
- finally {
1655
- try {
1656
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
1657
- }
1658
- finally { if (e_29) throw e_29.error; }
1659
- }
1660
- }
1661
- }
1662
- catch (e_28_1) { e_28 = { error: e_28_1 }; }
1663
- finally {
1664
- try {
1665
- if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2);
1666
- }
1667
- finally { if (e_28) throw e_28.error; }
1668
- }
1669
- return merged;
1670
- }
1671
- function buildSupportQaEvidence(input) {
1672
- var job = input.job || {};
1673
- var ticket = input.ticket || {};
1674
- var qaCursor = plainObject(job.supportQaValidationCursor || job.support_qa_validation_cursor);
1675
- var autonomousDecision = plainObject(job.supportV5AutonomousDecision || job.support_v5_autonomous_decision);
1676
- var ticketAutomation = plainObject(ticket.automation);
1677
- var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
1678
- var preflightGate = supportPreflightGateObject(ticket, job, __assign(__assign({}, plainObject(input.qaEvidence)), { supportV5AutonomousDecision: autonomousDecision }));
1679
- var businessProofReadiness = plainObject(autonomousDecision.businessProofReadiness
1680
- || autonomousDecision.business_proof_readiness
1681
- || job.businessProofReadiness
1682
- || job.business_proof_readiness);
1683
- var customerReplyPolicy = plainObject(autonomousDecision.customerReplyPolicy
1684
- || autonomousDecision.customer_reply_policy
1685
- || job.customerReplyPolicy
1686
- || job.customer_reply_policy);
1687
- var customerReplyReadiness = plainObject(autonomousDecision.customerReplyReadiness
1688
- || autonomousDecision.customer_reply_readiness
1689
- || customerReplyPolicy.readinessContract
1690
- || customerReplyPolicy.readiness_contract
1691
- || job.customerReplyReadiness
1692
- || job.customer_reply_readiness);
1693
- var managerRecoveryExecutionProof = plainObject(job.managerRecoveryExecutionProof
1694
- || job.manager_recovery_execution_proof
1695
- || job.supportManagerRecoveryExecutionProof
1696
- || job.support_manager_recovery_execution_proof
1697
- || autonomousDecision.recoveryExecutionProof
1698
- || autonomousDecision.recovery_execution_proof
1699
- || ticketManager.last_recovery_execution_proof
1700
- || ticketManager.recovery_execution_proof);
1701
- var humanReviewPacket = plainObject(autonomousDecision.humanReviewPacket
1702
- || autonomousDecision.human_review_packet
1703
- || customerReplyPolicy.humanReviewPacket
1704
- || customerReplyPolicy.human_review_packet
1705
- || job.humanReviewPacket
1706
- || job.human_review_packet);
1707
- var evidence = mergeEvidenceRecords(qaCursor, job.qaEvidence, job.qa_evidence, ticket.qaEvidence, ticket.qa_evidence, input.qaEvidence);
1708
- evidence.supportQaAssertions = __spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.supportQaAssertions)), false), __read(asArray(job.support_qa_assertions)), false), __read(asArray(evidence.supportQaAssertions)), false);
1709
- evidence.aiQaBusinessAssertions = __spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.aiQaBusinessAssertions)), false), __read(asArray(job.ai_qa_business_assertions)), false), __read(asArray(evidence.aiQaBusinessAssertions)), false);
1710
- evidence.runnerEvidenceArtifacts = __spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.runnerEvidenceArtifacts)), false), __read(asArray(job.runner_evidence_artifacts)), false), __read(asArray(evidence.runnerEvidenceArtifacts)), false);
1711
- evidence.supportQaArtifacts = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.supportQaArtifacts)), false), __read(asArray(job.support_qa_artifacts)), false), __read(asArray(job.qa_artifacts)), false), __read(asArray(evidence.supportQaArtifacts)), false);
1712
- if (Object.keys(businessProofReadiness).length) {
1713
- evidence.businessProofReadiness = businessProofReadiness;
1714
- }
1715
- if (Object.keys(customerReplyPolicy).length) {
1716
- evidence.customerReplyPolicy = __assign(__assign({}, customerReplyPolicy), (Object.keys(humanReviewPacket).length ? { humanReviewPacket: humanReviewPacket } : {}));
1717
- }
1718
- else if (Object.keys(humanReviewPacket).length) {
1719
- evidence.customerReplyPolicy = { humanReviewPacket: humanReviewPacket };
1720
- }
1721
- if (Object.keys(customerReplyReadiness).length) {
1722
- evidence.customerReplyReadiness = customerReplyReadiness;
1723
- }
1724
- if (Object.keys(managerRecoveryExecutionProof).length) {
1725
- evidence.managerRecoveryExecutionProof = managerRecoveryExecutionProof;
1726
- }
1727
- if (Object.keys(preflightGate).length) {
1728
- evidence.supportV5PreflightGate = preflightGate;
1729
- applySupportPreflightGateToQaEvidence(evidence, preflightGate);
1730
- }
1731
- return evidence;
1732
- }
1733
- function supportPreflightGateObject(ticket, job, evidence) {
1734
- var _a, _b;
1735
- var autonomousDecision = plainObject(job.supportV5AutonomousDecision
1736
- || job.support_v5_autonomous_decision
1737
- || evidence.supportV5AutonomousDecision
1738
- || evidence.support_v5_autonomous_decision
1739
- || ticket.supportV5AutonomousDecision
1740
- || ticket.support_v5_autonomous_decision);
1741
- var ticketAutomation = plainObject(ticket.automation);
1742
- var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
1743
- return evidenceObject(job.supportV5PreflightGate, job.support_v5_preflight_gate, job.preflightGate, job.preflight_gate, evidence.supportV5PreflightGate, evidence.support_v5_preflight_gate, evidence.preflightGate, evidence.preflight_gate, autonomousDecision.preflightGate, autonomousDecision.preflight_gate, (_a = autonomousDecision.rootCauseReadiness) === null || _a === void 0 ? void 0 : _a.preflightGate, (_b = autonomousDecision.root_cause_readiness) === null || _b === void 0 ? void 0 : _b.preflight_gate, ticket.supportV5PreflightGate, ticket.support_v5_preflight_gate, ticketManager.supportV5PreflightGate, ticketManager.support_v5_preflight_gate, ticketManager.preflightGate, ticketManager.preflight_gate);
1744
- }
1745
- function supportPreflightStatus(value) {
1746
- return cleanText(value, 120).toLowerCase();
1747
- }
1748
- function supportPreflightFailedChecks(preflightGate) {
1749
- var failed = __spreadArray(__spreadArray([], __read(asArray(preflightGate.failedChecks || preflightGate.failed_checks)), false), __read(asArray(preflightGate.checks).filter(function (check) {
1750
- var status = supportPreflightStatus(check.status || check.state || check.outcome);
1751
- return /fail|failed|blocked|missing|error/.test(status);
1752
- })), false);
1753
- var seen = new Set();
1754
- return failed.filter(function (check) {
1755
- var key = "".concat(cleanText(check.name || check.check || check.key, 160), ":").concat(cleanText(check.summary || check.message || check.error || check.reason, 500));
1756
- if (seen.has(key)) {
1757
- return false;
1758
- }
1759
- seen.add(key);
1760
- return true;
1761
- });
1762
- }
1763
- function supportPreflightArtifactPaths(preflightGate, checks) {
1764
- return Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(cleanStringList(preflightGate.artifactPaths || preflightGate.artifact_paths, 60, 500)), false), __read(checks.flatMap(function (check) { return cleanStringList(check.artifactPaths || check.artifact_paths || check.artifacts, 20, 500); })), false), __read(checks.map(function (check) { return cleanText(check.artifactPath || check.artifact_path || check.path || check.file, 500); }).filter(Boolean)), false))).slice(0, 80);
1765
- }
1766
- function supportPreflightCheckMessage(check) {
1767
- return cleanText(check.summary || check.message || check.error || check.reason || check.status, 1000);
1768
- }
1769
- function applySupportPreflightGateToQaEvidence(evidence, preflightGate) {
1770
- var _a;
1771
- var status = supportPreflightStatus(preflightGate.status);
1772
- var failureClass = supportPreflightStatus(preflightGate.failureClass || preflightGate.failure_class);
1773
- var failedChecks = supportPreflightFailedChecks(preflightGate);
1774
- var artifactPaths = supportPreflightArtifactPaths(preflightGate, failedChecks);
1775
- var compileResult = plainObject(preflightGate.compileResult || preflightGate.compile_result);
1776
- var compileFailed = status === 'compile_failed'
1777
- || failureClass === 'compile'
1778
- || cleanText(compileResult.failureClass || compileResult.failure_class, 120).toLowerCase() === 'compile'
1779
- || failedChecks.some(function (check) {
1780
- var name = supportPreflightStatus(check.name || check.check || check.key);
1781
- var checkClass = supportPreflightStatus(check.failureClass || check.failure_class);
1782
- return name === 'compile' || checkClass === 'compile';
1783
- });
1784
- if (compileFailed) {
1785
- var compileCheck = Object.keys(compileResult).length ? compileResult : failedChecks[0] || {};
1786
- evidence.compile = __assign(__assign({}, plainObject(evidence.compile || evidence.build || evidence.buildResult || evidence.build_result)), { status: cleanText(compileCheck.status || preflightGate.status || 'fail', 80) || 'fail', command: cleanText(compileCheck.command || preflightGate.command || preflightGate.nextCommand || preflightGate.next_command, 500), artifactPath: artifactPaths[0] || cleanText(compileCheck.artifactPath || compileCheck.artifact_path || compileCheck.path, 500), message: supportPreflightCheckMessage(compileCheck) || cleanText(preflightGate.reason || ((_a = preflightGate.blockers) === null || _a === void 0 ? void 0 : _a[0]) || 'Support compile preflight failed before browser QA.', 1000), metadata: {
1787
- source: 'supportV5PreflightGate',
1788
- preflightStatus: status,
1789
- preflightEvidenceHash: cleanText(preflightGate.evidenceHash || preflightGate.evidence_hash, 200),
1790
- nextCommand: cleanText(preflightGate.nextCommand || preflightGate.next_command, 180)
1791
- } });
1792
- return;
1793
- }
1794
- var blocksRepair = preflightGate.blocksProductRepair === true || preflightGate.blocks_product_repair === true || /infra_failed|blocked|missing/.test(status);
1795
- var checks = failedChecks.length
1796
- ? failedChecks
1797
- : Object.keys(preflightGate).length && (blocksRepair || status === 'passed')
1798
- ? [{
1799
- name: 'support_preflight',
1800
- status: status === 'passed' ? 'pass' : 'blocked',
1801
- summary: cleanStringList(preflightGate.blockers, 4, 500).join('; ') || cleanText(preflightGate.reason || preflightGate.status, 1000),
1802
- artifactPaths: artifactPaths
1803
- }]
1804
- : [];
1805
- if (!checks.length) {
1806
- return;
1807
- }
1808
- evidence.infraChecks = __spreadArray(__spreadArray([], __read(asArray(evidence.infraChecks)), false), __read(checks.map(function (check) { return ({
1809
- name: cleanText(check.name || check.check || check.key, 160) || 'support_preflight',
1810
- status: cleanText(check.status || check.state || check.outcome || (status === 'passed' ? 'pass' : 'blocked'), 80),
1811
- message: supportPreflightCheckMessage(check) || cleanStringList(preflightGate.blockers, 3, 500).join('; '),
1812
- path: cleanText(check.path || check.artifactPath || check.artifact_path, 500) || artifactPaths[0],
1813
- metadata: {
1814
- source: 'supportV5PreflightGate',
1815
- preflightStatus: status,
1816
- preflightFailureClass: failureClass,
1817
- preflightEvidenceHash: cleanText(preflightGate.evidenceHash || preflightGate.evidence_hash, 200),
1818
- nextCommand: cleanText(preflightGate.nextCommand || preflightGate.next_command, 180)
1819
- }
1820
- }); })), false);
1821
- }
1822
- function supportPreflightGateResult(preflightGate, now) {
1823
- if (!preflightGate || !Object.keys(preflightGate).length) {
1824
- return undefined;
1825
- }
1826
- var statusText = supportPreflightStatus(preflightGate.status);
1827
- var ready = preflightGate.ready === true;
1828
- var blocksProductRepair = preflightGate.blocksProductRepair === true || preflightGate.blocks_product_repair === true;
1829
- var failedChecks = supportPreflightFailedChecks(preflightGate);
1830
- var artifactPaths = supportPreflightArtifactPaths(preflightGate, failedChecks);
1831
- var gateStatus = ready || statusText === 'passed'
1832
- ? 'pass'
1833
- : /compile_failed|infra_failed|fail|failed/.test(statusText)
1834
- ? 'fail'
1835
- : blocksProductRepair || /missing|blocked/.test(statusText)
1836
- ? 'blocked'
1837
- : 'warn';
1838
- var blockers = cleanStringList(preflightGate.blockers, 20, 500);
1839
- return {
1840
- key: 'support_preflight_gate',
1841
- label: 'Support preflight gate',
1842
- status: gateStatus,
1843
- reason: gateStatus === 'pass'
1844
- ? 'Support deterministic preflight passed before product-code repair.'
1845
- : cleanText(blockers.join('; ') || preflightGate.reason || "Support deterministic preflight is ".concat(statusText || 'not ready', " before product-code repair."), 1200),
1846
- evidenceRefs: artifactPaths,
1847
- recordedAt: isoNow(now || preflightGate.recordedAt || preflightGate.recorded_at),
1848
- metadata: {
1849
- ready: ready,
1850
- required: preflightGate.required === true,
1851
- status: statusText,
1852
- failureClass: cleanText(preflightGate.failureClass || preflightGate.failure_class, 120),
1853
- nextCommand: cleanText(preflightGate.nextCommand || preflightGate.next_command, 180),
1854
- blocksProductRepair: blocksProductRepair,
1855
- blocksModelRepair: preflightGate.blocksModelRepair === true || preflightGate.blocks_model_repair === true,
1856
- failedChecks: failedChecks.map(function (check) { return cleanText(check.name || check.check || check.key, 160); }).filter(Boolean),
1857
- requiredEvidence: cleanStringList(preflightGate.requiredEvidence || preflightGate.required_evidence, 20, 500),
1858
- evidenceHash: cleanText(preflightGate.evidenceHash || preflightGate.evidence_hash, 200)
1859
- }
1860
- };
1861
- }
1862
- function supportBusinessProofReadinessGate(readiness, now) {
1863
- if (!readiness || !Object.keys(readiness).length) {
1864
- return undefined;
1865
- }
1866
- var ready = readiness.ready === true;
1867
- var readinessStatus = cleanText(readiness.status, 120).toLowerCase();
1868
- var blockers = cleanStringList(readiness.blockers, 20, 500);
1869
- var artifactPaths = cleanStringList(readiness.artifactPaths || readiness.artifact_paths, 40, 500);
1870
- var proofFingerprint = cleanText(readiness.proofFingerprint || readiness.proof_fingerprint, 160);
1871
- var artifactFingerprint = cleanText(readiness.artifactFingerprint || readiness.artifact_fingerprint, 160);
1872
- var proofFreshness = cleanText(readiness.proofFreshness || readiness.proof_freshness, 120);
1873
- var status = ready
1874
- ? 'pass'
1875
- : /fail|failed/.test(readinessStatus)
1876
- ? 'fail'
1877
- : /missing|route_only|blocked|weak|stale|incomplete/.test(readinessStatus)
1878
- ? 'blocked'
1879
- : 'warn';
1880
- return {
1881
- key: 'support_business_proof_readiness',
1882
- label: 'Support business proof readiness',
1883
- status: status,
1884
- reason: cleanText(readiness.reason || blockers.join('; ') || readinessStatus || 'Support business proof readiness recorded.', 1200),
1885
- evidenceRefs: artifactPaths,
1886
- recordedAt: isoNow(now || readiness.recordedAt || readiness.recorded_at),
1887
- metadata: {
1888
- ready: ready,
1889
- status: readinessStatus,
1890
- blockers: blockers,
1891
- requiredEvidence: cleanStringList(readiness.requiredEvidence || readiness.required_evidence, 20, 500),
1892
- proofFingerprint: proofFingerprint,
1893
- artifactFingerprint: artifactFingerprint,
1894
- proofFreshness: proofFreshness
1895
- }
1896
- };
1897
- }
1898
- function supportCustomerReplyPolicyGate(policy, now) {
1899
- if (!policy || !Object.keys(policy).length) {
1900
- return undefined;
1901
- }
1902
- var action = cleanText(policy.action, 120);
1903
- var safety = cleanText(policy.safety, 120);
1904
- var reason = cleanText(policy.reason, 1200);
1905
- var canDraft = policy.canDraftCustomerReply === true || policy.can_draft_customer_reply === true;
1906
- var canSend = policy.canSendCustomerReply === true || policy.can_send_customer_reply === true;
1907
- var reviewPacket = plainObject(policy.humanReviewPacket || policy.human_review_packet);
1908
- var draftBasis = plainObject(policy.draftBasis || policy.draft_basis);
1909
- var clarificationValidation = (0, support_runner_v5_1.validateResolveIOSupportClarificationContract)(policy.clarificationContract || policy.clarification_contract || {});
1910
- var clarificationContract = clarificationValidation.normalized;
1911
- var reviewType = cleanText(reviewPacket.reviewType || reviewPacket.review_type, 160);
1912
- var evidenceRefs = cleanStringList(reviewPacket.evidenceRefs || reviewPacket.evidence_refs, 40, 500);
1913
- var blockers = cleanStringList(policy.blockers || reviewPacket.blockers, 20, 500);
1914
- var gateStatus = canSend
1915
- ? 'blocked'
1916
- : action === 'draft_resolution_reply' && canDraft
1917
- ? 'warn'
1918
- : action === 'ask_clarification' && canDraft
1919
- ? (clarificationValidation.valid ? 'warn' : 'blocked')
1920
- : 'blocked';
1921
- var mergedBlockers = Array.from(new Set(__spreadArray(__spreadArray([], __read(blockers), false), __read((action === 'ask_clarification' ? clarificationValidation.blockers : [])), false)));
1922
- return {
1923
- key: 'support_customer_reply_policy',
1924
- label: 'Support customer reply policy',
1925
- status: gateStatus,
1926
- reason: reason || mergedBlockers.join('; ') || action || 'Support customer reply policy recorded.',
1927
- evidenceRefs: evidenceRefs,
1928
- recordedAt: isoNow(now || policy.recordedAt || policy.recorded_at || reviewPacket.createdAt || reviewPacket.created_at),
1929
- metadata: {
1930
- action: action,
1931
- safety: safety,
1932
- canDraftCustomerReply: canDraft,
1933
- canSendCustomerReply: canSend,
1934
- confidenceLevel: cleanText(policy.confidenceLevel || policy.confidence_level, 120),
1935
- issueClass: cleanText(draftBasis.issueClass || draftBasis.issue_class, 120),
1936
- issueClassProbePlanId: cleanText(draftBasis.issueClassProbePlanId || draftBasis.issue_class_probe_plan_id, 180),
1937
- issueClassProbePlanStatus: cleanText(draftBasis.issueClassProbePlanStatus || draftBasis.issue_class_probe_plan_status, 120),
1938
- reviewType: reviewType,
1939
- primaryAction: cleanText(reviewPacket.primaryAction || reviewPacket.primary_action, 160),
1940
- requiresHumanApproval: reviewPacket.requiresHumanApproval !== false && reviewPacket.requires_human_approval !== false,
1941
- questionPresent: !!cleanText(policy.clarificationQuestion || policy.clarification_question || reviewPacket.question, 1000),
1942
- clarificationContractStatus: cleanText(clarificationContract.status, 120),
1943
- clarificationMissingField: cleanText(clarificationContract.missingField, 120),
1944
- clarificationOneQuestionOnly: clarificationContract.oneQuestionOnly === true,
1945
- clarificationParksTicket: clarificationContract.parksTicketUntilCustomerReply === true,
1946
- blockers: mergedBlockers
1947
- }
1948
- };
1949
- }
1950
- function supportCustomerReplyReadinessGate(contract, now) {
1951
- if (!contract || !Object.keys(contract).length) {
1952
- return undefined;
1953
- }
1954
- var validation = (0, support_runner_v5_1.validateResolveIOSupportCustomerReplyReadinessContract)(contract);
1955
- var normalized = validation.normalized;
1956
- var status = cleanText(normalized.status, 120);
1957
- var gateStatus = normalized.canSendCustomerReply
1958
- ? 'blocked'
1959
- : validation.valid && (status === 'draft_ready' || status === 'clarification_required')
1960
- ? 'warn'
1961
- : 'blocked';
1962
- return {
1963
- key: 'support_customer_reply_readiness',
1964
- label: 'Support customer reply readiness',
1965
- status: gateStatus,
1966
- reason: normalized.reason || validation.blockers.join('; ') || status || 'Support customer reply readiness recorded.',
1967
- evidenceRefs: normalized.evidenceRefs,
1968
- recordedAt: isoNow(now || normalized.createdAt),
1969
- metadata: {
1970
- contractId: normalized.contractId,
1971
- status: status,
1972
- policyAction: normalized.policyAction,
1973
- reviewType: normalized.reviewType,
1974
- primaryCommand: normalized.primaryCommand,
1975
- canDraftCustomerReply: normalized.canDraftCustomerReply,
1976
- canSendCustomerReply: normalized.canSendCustomerReply,
1977
- requiresHumanApproval: normalized.requiresHumanApproval,
1978
- proofBacked: normalized.proofBacked,
1979
- businessProofReady: normalized.businessProofReady,
1980
- releaseReady: normalized.releaseReady,
1981
- diagnosisReady: normalized.diagnosisReady,
1982
- issueClassProbePlanReady: normalized.issueClassProbePlanReady,
1983
- clarificationRequired: normalized.clarificationRequired,
1984
- blockers: Array.from(new Set(__spreadArray(__spreadArray([], __read(normalized.blockers), false), __read(validation.blockers), false))),
1985
- requiredEvidence: normalized.requiredEvidence,
1986
- nextCommands: normalized.nextCommands,
1987
- forbiddenActions: normalized.forbiddenActions
1988
- }
1989
- };
1990
- }
1991
- function supportNextActionContractObject(ticket, job, evidence) {
1992
- var ticketAutomation = plainObject(ticket.automation);
1993
- var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
1994
- var autonomousDecision = plainObject(job.supportV5AutonomousDecision
1995
- || job.support_v5_autonomous_decision
1996
- || evidence.supportV5AutonomousDecision
1997
- || evidence.support_v5_autonomous_decision
1998
- || ticket.supportV5AutonomousDecision
1999
- || ticket.support_v5_autonomous_decision);
2000
- return evidenceObject(autonomousDecision.nextActionContract, autonomousDecision.next_action_contract, job.supportV5NextActionContract, job.support_v5_next_action_contract, job.nextActionContract, job.next_action_contract, evidence.supportV5NextActionContract, evidence.support_v5_next_action_contract, evidence.nextActionContract, evidence.next_action_contract, ticket.supportV5NextActionContract, ticket.support_v5_next_action_contract, ticket.nextActionContract, ticket.next_action_contract, ticketManager.nextActionContract, ticketManager.next_action_contract);
2001
- }
2002
- function supportNextActionContractRequired(ticket, job, evidence) {
2003
- var ticketAutomation = plainObject(ticket.automation);
2004
- var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2005
- var workflowMarkers = [
2006
- job.supportWorkflowMode,
2007
- job.workflowMode,
2008
- job.workflow_mode,
2009
- job.supportWorkflowVersion,
2010
- job.support_workflow_version,
2011
- ticket.supportWorkflowMode,
2012
- ticket.workflowMode,
2013
- ticket.workflow_mode
2014
- ].map(function (value) { return cleanText(value, 80).toLowerCase(); });
2015
- return workflowMarkers.some(function (value) { return value === 'support_v5' || value === 'v5'; })
2016
- || !!job.supportV5SupervisorState
2017
- || !!job.supportV5MicrotaskLedger
2018
- || !!job.supportV5StepHistory
2019
- || !!job.supportV5DiagnosisGate
2020
- || !!job.supportV5DiagnosisEvidencePack
2021
- || !!job.support_v5_supervisor_state
2022
- || !!job.support_v5_microtask_ledger
2023
- || !!job.support_v5_step_history
2024
- || !!job.support_v5_diagnosis_gate
2025
- || !!job.support_v5_diagnosis_evidence_pack
2026
- || !!job.supportRootCauseEntryContract
2027
- || !!job.support_root_cause_entry_contract
2028
- || !!evidence.supportV5AutonomousDecision
2029
- || !!evidence.support_v5_autonomous_decision
2030
- || !!evidence.rootCauseReadiness
2031
- || !!evidence.root_cause_readiness
2032
- || !!ticketManager.root_cause_entry_contract
2033
- || !!ticketManager.rootCauseEntryContract
2034
- || !!ticketManager.last_watchdog_decision;
2035
- }
2036
- function supportNextActionContractMetadata(contract) {
2037
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
2038
- var decisionBasis = plainObject(contract.decisionBasis || contract.decision_basis);
2039
- var costRisk = plainObject(contract.costRisk || contract.cost_risk);
2040
- var source = {
2041
- contractId: cleanText(contract.contractId || contract.contract_id, 200),
2042
- action: cleanText(contract.action, 160),
2043
- label: cleanText(contract.label, 300),
2044
- primaryCommand: cleanText(contract.primaryCommand || contract.primary_command, 240),
2045
- lane: cleanText(contract.lane, 120),
2046
- stepType: cleanText(contract.stepType || contract.step_type, 120),
2047
- safeToAutoRun: booleanFlag((_a = contract.safeToAutoRun) !== null && _a !== void 0 ? _a : contract.safe_to_auto_run),
2048
- requiresHumanApproval: booleanFlag((_b = contract.requiresHumanApproval) !== null && _b !== void 0 ? _b : contract.requires_human_approval),
2049
- canRunWithoutCodexMonitor: booleanFlag((_c = contract.canRunWithoutCodexMonitor) !== null && _c !== void 0 ? _c : contract.can_run_without_codex_monitor),
2050
- codexFallbackRequired: booleanFlag((_d = contract.codexFallbackRequired) !== null && _d !== void 0 ? _d : contract.codex_fallback_required),
2051
- codexFallbackReason: cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000),
2052
- rootCauseFirstSatisfied: booleanFlag((_e = contract.rootCauseFirstSatisfied) !== null && _e !== void 0 ? _e : contract.root_cause_first_satisfied),
2053
- preconditions: cleanStringList(contract.preconditions, 40, 500),
2054
- expectedStateTransition: cleanText(contract.expectedStateTransition || contract.expected_state_transition, 1000),
2055
- successEvidence: cleanStringList(contract.successEvidence || contract.success_evidence, 40, 500),
2056
- stopConditions: cleanStringList(contract.stopConditions || contract.stop_conditions, 40, 500),
2057
- forbiddenActions: cleanStringList(contract.forbiddenActions || contract.forbidden_actions, 40, 500),
2058
- ownerFiles: cleanStringList(contract.ownerFiles || contract.owner_files || decisionBasis.ownerFiles || decisionBasis.owner_files, 40, 500),
2059
- blockers: cleanStringList(contract.blockers, 40, 500),
2060
- nextCommands: cleanStringList(contract.nextCommands || contract.next_commands, 40, 500),
2061
- costRisk: {
2062
- level: cleanText(costRisk.level || contract.costRiskLevel || contract.cost_risk_level, 80),
2063
- estimatedUsd: numberValue((_h = (_g = (_f = costRisk.estimatedUsd) !== null && _f !== void 0 ? _f : costRisk.estimated_usd) !== null && _g !== void 0 ? _g : contract.estimatedUsd) !== null && _h !== void 0 ? _h : contract.estimated_usd),
2064
- reason: cleanText(costRisk.reason, 800)
2065
- },
2066
- diagnosisValid: booleanFlag((_j = decisionBasis.diagnosisValid) !== null && _j !== void 0 ? _j : decisionBasis.diagnosis_valid),
2067
- ownerFilesReady: booleanFlag((_k = decisionBasis.ownerFilesReady) !== null && _k !== void 0 ? _k : decisionBasis.owner_files_ready),
2068
- proofPlanReady: booleanFlag((_l = decisionBasis.proofPlanReady) !== null && _l !== void 0 ? _l : decisionBasis.proof_plan_ready),
2069
- businessProofReady: booleanFlag((_m = decisionBasis.businessProofReady) !== null && _m !== void 0 ? _m : decisionBasis.business_proof_ready),
2070
- evidenceFreshnessStatus: cleanText(decisionBasis.evidenceFreshnessStatus || decisionBasis.evidence_freshness_status, 120),
2071
- evidenceStrength: cleanText(decisionBasis.evidenceStrength || decisionBasis.evidence_strength, 120),
2072
- failureClass: cleanText(decisionBasis.failureClass || decisionBasis.failure_class, 120),
2073
- blockerFingerprint: cleanText(decisionBasis.blockerFingerprint || decisionBasis.blocker_fingerprint, 200),
2074
- evidenceHash: cleanText(decisionBasis.evidenceHash || decisionBasis.evidence_hash, 200),
2075
- sameFailureCount: numberValue((_o = decisionBasis.sameFailureCount) !== null && _o !== void 0 ? _o : decisionBasis.same_failure_count),
2076
- preflightReady: booleanFlag((_p = decisionBasis.preflightReady) !== null && _p !== void 0 ? _p : decisionBasis.preflight_ready),
2077
- preflightStatus: cleanText(decisionBasis.preflightStatus || decisionBasis.preflight_status, 120),
2078
- preflightFailureClass: cleanText(decisionBasis.preflightFailureClass || decisionBasis.preflight_failure_class, 120),
2079
- preflightEvidenceHash: cleanText(decisionBasis.preflightEvidenceHash || decisionBasis.preflight_evidence_hash, 200),
2080
- hotfixCommitRequired: booleanFlag((_s = (_r = (_q = decisionBasis.hotfixCommitRequired) !== null && _q !== void 0 ? _q : decisionBasis.hotfix_commit_required) !== null && _r !== void 0 ? _r : contract.hotfixCommitRequired) !== null && _s !== void 0 ? _s : contract.hotfix_commit_required),
2081
- liveHotfixBlockedUntilCommit: booleanFlag((_v = (_u = (_t = decisionBasis.liveHotfixBlockedUntilCommit) !== null && _t !== void 0 ? _t : decisionBasis.live_hotfix_blocked_until_commit) !== null && _u !== void 0 ? _u : contract.liveHotfixBlockedUntilCommit) !== null && _v !== void 0 ? _v : contract.live_hotfix_blocked_until_commit)
2082
- };
2083
- return source;
2084
- }
2085
- function supportNextActionContractGate(contract, now, required) {
2086
- if (required === void 0) { required = false; }
2087
- if (!contract || !Object.keys(contract).length) {
2088
- if (!required) {
2089
- return undefined;
2090
- }
2091
- var blocker = 'Support V5 run is missing a validated next-action contract, so the manager cannot prove one safe primary action without external Codex monitoring.';
2092
- return {
2093
- key: 'support_next_action_contract',
2094
- label: 'Support next-action contract',
2095
- status: 'blocked',
2096
- reason: blocker,
2097
- evidenceRefs: [],
2098
- recordedAt: isoNow(now),
2099
- metadata: {
2100
- required: true,
2101
- missingContract: true,
2102
- safeToAutoRun: false,
2103
- canRunWithoutCodexMonitor: false,
2104
- codexFallbackRequired: true,
2105
- codexFallbackReason: 'missing_support_next_action_contract',
2106
- blockers: [blocker],
2107
- missingSafetyFlags: ['safeToAutoRun', 'canRunWithoutCodexMonitor', 'codexFallbackRequired']
2108
- }
2109
- };
2110
- }
2111
- var metadata = supportNextActionContractMetadata(contract);
2112
- var blockers = cleanStringList(metadata.blockers, 40, 500);
2113
- if (metadata.safeToAutoRun === false) {
2114
- blockers.push('Next action contract marks the action unsafe for autonomous run.');
2115
- }
2116
- if (metadata.canRunWithoutCodexMonitor === false) {
2117
- blockers.push('Next action requires Codex fallback/monitoring instead of manager-only execution.');
2118
- }
2119
- if (metadata.codexFallbackRequired === true) {
2120
- blockers.push(metadata.codexFallbackReason || 'Next action contract requires Codex fallback.');
2121
- }
2122
- if (metadata.requiresHumanApproval === true) {
2123
- blockers.push('Next action contract requires human approval.');
2124
- }
2125
- if (metadata.liveHotfixBlockedUntilCommit === true) {
2126
- blockers.push('Live hotfix is blocked until the manager records and pushes the GitHub commit proof.');
2127
- }
2128
- var missingSafetyFlags = [
2129
- metadata.safeToAutoRun === undefined ? 'safeToAutoRun' : '',
2130
- metadata.canRunWithoutCodexMonitor === undefined ? 'canRunWithoutCodexMonitor' : '',
2131
- metadata.codexFallbackRequired === undefined ? 'codexFallbackRequired' : ''
2132
- ].filter(Boolean);
2133
- var status = blockers.length
2134
- ? 'blocked'
2135
- : missingSafetyFlags.length
2136
- ? 'warn'
2137
- : 'pass';
2138
- var actionLabel = metadata.label || metadata.action || metadata.primaryCommand || 'support next action';
2139
- return {
2140
- key: 'support_next_action_contract',
2141
- label: 'Support next-action contract',
2142
- status: status,
2143
- reason: blockers.length
2144
- ? blockers.join(' ')
2145
- : missingSafetyFlags.length
2146
- ? "Support next-action contract is present for ".concat(actionLabel, ", but missing explicit safety flags: ").concat(missingSafetyFlags.join(', '), ".")
2147
- : "Support next-action contract allows ".concat(actionLabel, " without Codex monitoring."),
2148
- evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(metadata.successEvidence), false), __read(metadata.preconditions), false), __read(metadata.stopConditions), false), 40, 500),
2149
- recordedAt: isoNow(now || contract.createdAt || contract.created_at || contract.recordedAt || contract.recorded_at),
2150
- metadata: __assign(__assign({}, metadata), { blockers: blockers, missingSafetyFlags: missingSafetyFlags })
2151
- };
2152
- }
2153
- function supportDiagnosisEvidencePackObject(ticket, job, evidence) {
2154
- var ticketAutomation = plainObject(ticket.automation);
2155
- var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2156
- return evidenceObject(job.supportV5DiagnosisEvidencePack, job.support_v5_diagnosis_evidence_pack, job.diagnosisEvidencePack, job.diagnosis_evidence_pack, evidence.supportV5DiagnosisEvidencePack, evidence.support_v5_diagnosis_evidence_pack, evidence.diagnosisEvidencePack, evidence.diagnosis_evidence_pack, ticket.supportV5DiagnosisEvidencePack, ticket.support_v5_diagnosis_evidence_pack, ticket.diagnosisEvidencePack, ticket.diagnosis_evidence_pack, ticketManager.diagnosisEvidencePack, ticketManager.diagnosis_evidence_pack);
2157
- }
2158
- function supportIssueClassProbePlanObject(ticket, job, evidence) {
2159
- var ticketAutomation = plainObject(ticket.automation);
2160
- var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2161
- var autonomousDecision = plainObject(job.supportV5AutonomousDecision
2162
- || job.support_v5_autonomous_decision
2163
- || evidence.supportV5AutonomousDecision
2164
- || evidence.support_v5_autonomous_decision
2165
- || ticket.supportV5AutonomousDecision
2166
- || ticket.support_v5_autonomous_decision);
2167
- return evidenceObject(autonomousDecision.issueClassProbePlan, autonomousDecision.issue_class_probe_plan, job.supportV5IssueClassProbePlan, job.support_v5_issue_class_probe_plan, job.issueClassProbePlan, job.issue_class_probe_plan, evidence.supportV5IssueClassProbePlan, evidence.support_v5_issue_class_probe_plan, evidence.issueClassProbePlan, evidence.issue_class_probe_plan, ticket.supportV5IssueClassProbePlan, ticket.support_v5_issue_class_probe_plan, ticket.issueClassProbePlan, ticket.issue_class_probe_plan, ticketManager.issueClassProbePlan, ticketManager.issue_class_probe_plan);
2168
- }
2169
- function supportSimilarFixHintsObject(ticket, job, evidence) {
2170
- var ticketAutomation = plainObject(ticket.automation);
2171
- var ticketManager = plainObject(ticketAutomation.manager || ticket.manager);
2172
- return evidenceObject(job.supportRootCauseSimilarFixHints, job.support_root_cause_similar_fix_hints, job.similarFixHints, job.similar_fix_hints, evidence.supportRootCauseSimilarFixHints, evidence.support_root_cause_similar_fix_hints, evidence.similarFixHints, evidence.similar_fix_hints, ticket.supportRootCauseSimilarFixHints, ticket.support_root_cause_similar_fix_hints, ticketManager.rootCauseSimilarFixHints, ticketManager.root_cause_similar_fix_hints);
2173
- }
2174
- function supportDiagnosisEvidencePackGate(pack, now) {
2175
- if (!pack || !Object.keys(pack).length) {
2176
- return undefined;
2177
- }
2178
- var statusText = cleanText(pack.status, 120);
2179
- var diagnosisValid = pack.diagnosisValid === true || pack.diagnosis_valid === true;
2180
- var validationBlockers = cleanStringList(pack.validationBlockers || pack.validation_blockers, 40, 500);
2181
- var similarSelection = plainObject(pack.similarCaseSelection || pack.similar_case_selection);
2182
- var rankedHints = asArray(similarSelection.ranked);
2183
- var gateStatus = diagnosisValid || statusText === 'diagnosis_ready'
2184
- ? 'pass'
2185
- : statusText === 'blocked'
2186
- ? 'blocked'
2187
- : 'warn';
2188
- return {
2189
- key: 'support_diagnosis_evidence_pack',
2190
- label: 'Support diagnosis evidence pack',
2191
- status: gateStatus,
2192
- reason: gateStatus === 'pass'
2193
- ? 'Support diagnosis evidence pack has a valid root-cause diagnosis and advisory similar-fix context.'
2194
- : validationBlockers.join('; ') || 'Support diagnosis evidence pack requires read-only root-cause evidence before repair.',
2195
- evidenceRefs: cleanStringList(pack.requiredEvidence || pack.required_evidence, 30, 500),
2196
- recordedAt: isoNow(now || pack.generatedAt || pack.generated_at),
2197
- metadata: {
2198
- packId: cleanText(pack.packId || pack.pack_id, 180),
2199
- status: statusText,
2200
- readOnly: pack.readOnly !== false && pack.read_only !== false,
2201
- sourceEditsAllowed: pack.sourceEditsAllowed === true || pack.source_edits_allowed === true,
2202
- rootCauseFirstRequired: pack.rootCauseFirstRequired !== false && pack.root_cause_first_required !== false,
2203
- requiredOutputKey: cleanText(pack.requiredOutputKey || pack.required_output_key, 120),
2204
- requiredFields: cleanStringList(pack.requiredFields || pack.required_fields, 20, 160),
2205
- forbiddenActions: cleanStringList(pack.forbiddenActions || pack.forbidden_actions, 20, 500),
2206
- diagnosisValid: diagnosisValid,
2207
- diagnosisStatus: cleanText(pack.diagnosisStatus || pack.diagnosis_status, 120),
2208
- validationBlockers: validationBlockers,
2209
- issueClassHint: cleanText(pack.issueClassHint || pack.issue_class_hint, 120),
2210
- ownerFileHints: cleanStringList(pack.ownerFileHints || pack.owner_file_hints, 20, 500),
2211
- similarHintCount: rankedHints.length,
2212
- similarHintsAdvisoryOnly: true,
2213
- issueClassProbeCount: asArray(pack.issueClassProbeCatalog || pack.issue_class_probe_catalog).length
2214
- }
2215
- };
2216
- }
2217
- function supportIssueClassProbePlanGate(plan, diagnosisGate, now, required) {
2218
- if (required === void 0) { required = false; }
2219
- if (!plan || !Object.keys(plan).length) {
2220
- if (!required) {
2221
- return undefined;
2222
- }
2223
- var blocker = 'Support V5 run is missing IssueClassProbePlan, so business proof cannot be accepted from route-only or generic QA.';
2224
- return {
2225
- key: 'support_issue_class_probe_plan',
2226
- label: 'Support issue-class probe plan',
2227
- status: 'blocked',
2228
- reason: blocker,
2229
- evidenceRefs: [],
2230
- recordedAt: isoNow(now),
2231
- metadata: {
2232
- required: true,
2233
- missingPlan: true,
2234
- issueClassProbePlanReady: false,
2235
- acceptanceGate: 'aiqa_business_assertion',
2236
- blockers: [blocker],
2237
- falsePassBlockers: ['route load only', 'generic clickthrough only', 'scorecard-only pass']
2238
- }
2239
- };
2240
- }
2241
- var validation = (0, support_runner_v5_1.validateResolveIOSupportIssueClassProbePlan)(plan, diagnosisGate, now);
2242
- var normalized = plainObject(validation.normalized || plan);
2243
- var activeProbe = plainObject(validation.activeProbe || normalized.activeProbe || normalized.active_probe);
2244
- var blockers = cleanStringList(validation.blockers || normalized.blockers, 40, 500);
2245
- var requiredArtifacts = cleanStringList(normalized.requiredArtifacts
2246
- || normalized.required_artifacts
2247
- || activeProbe.required_artifacts, 30, 500);
2248
- var falsePassBlockers = cleanStringList(normalized.falsePassBlockers
2249
- || normalized.false_pass_blockers
2250
- || activeProbe.false_pass_blockers, 30, 500);
2251
- var status = validation.valid ? 'pass' : 'blocked';
2252
- var issueClass = cleanText(normalized.issue_class || normalized.issueClass || activeProbe.issue_class, 120);
2253
- var route = cleanText(activeProbe.route, 500);
2254
- var action = cleanText(activeProbe.action, 1000);
2255
- return {
2256
- key: 'support_issue_class_probe_plan',
2257
- label: 'Support issue-class probe plan',
2258
- status: status,
2259
- reason: validation.valid
2260
- ? "Support issue-class probe plan is ready for ".concat(issueClass || 'the diagnosed issue', " and requires AIQaBusinessAssertion proof.")
2261
- : blockers.join('; ') || 'Support issue-class probe plan is incomplete.',
2262
- evidenceRefs: requiredArtifacts,
2263
- recordedAt: isoNow(now || normalized.generatedAt || normalized.generated_at),
2264
- metadata: {
2265
- planId: cleanText(normalized.planId || normalized.plan_id, 180),
2266
- status: cleanText(validation.status || normalized.status, 120),
2267
- issueClass: issueClass,
2268
- diagnosisValid: normalized.diagnosisValid === true || normalized.diagnosis_valid === true,
2269
- issueClassProbePlanReady: validation.valid === true && validation.status === 'ready',
2270
- activeRoute: route,
2271
- action: action,
2272
- expectedEvidence: cleanText(activeProbe.expected_evidence || activeProbe.expectedEvidence, 1200),
2273
- expectedBusinessProof: cleanText(activeProbe.expected_business_proof || activeProbe.expectedBusinessProof, 1200),
2274
- acceptanceGate: cleanText(normalized.acceptanceGate || normalized.acceptance_gate || activeProbe.acceptance_gate, 120),
2275
- requiredArtifacts: requiredArtifacts,
2276
- falsePassBlockers: falsePassBlockers,
2277
- blockers: blockers,
2278
- activeProbe: {
2279
- issueClass: issueClass,
2280
- route: route,
2281
- action: action,
2282
- probeType: cleanText(activeProbe.probe_type || activeProbe.probeType, 120),
2283
- failureClass: cleanText(activeProbe.failure_class || activeProbe.failureClass, 120),
2284
- blocksAcceptanceWithoutBusinessAssertion: activeProbe.blocks_acceptance_without_business_assertion === true
2285
- || activeProbe.blocksAcceptanceWithoutBusinessAssertion === true
2286
- }
2287
- }
2288
- };
2289
- }
2290
- function firstNonEmptyText(values, max) {
2291
- var e_30, _a;
2292
- if (max === void 0) { max = 1000; }
2293
- try {
2294
- for (var values_3 = __values(values), values_3_1 = values_3.next(); !values_3_1.done; values_3_1 = values_3.next()) {
2295
- var value = values_3_1.value;
2296
- var normalized = idText(value, max);
2297
- if (normalized) {
2298
- return normalized;
2299
- }
2300
- }
2301
- }
2302
- catch (e_30_1) { e_30 = { error: e_30_1 }; }
2303
- finally {
2304
- try {
2305
- if (values_3_1 && !values_3_1.done && (_a = values_3.return)) _a.call(values_3);
2306
- }
2307
- finally { if (e_30) throw e_30.error; }
2308
- }
2309
- return undefined;
2310
- }
2311
- function booleanFlag(value) {
2312
- if (value === true || value === false) {
2313
- return value;
2314
- }
2315
- if (typeof value === 'string') {
2316
- var normalized = value.trim().toLowerCase();
2317
- if (/^(true|yes|1|passed|pass|ready|safe)$/.test(normalized)) {
2318
- return true;
2319
- }
2320
- if (/^(false|no|0|failed|fail|blocked|unsafe)$/.test(normalized)) {
2321
- return false;
2322
- }
2323
- }
2324
- return undefined;
2325
- }
2326
- function numberValue(value) {
2327
- var parsed = Number(value);
2328
- return Number.isFinite(parsed) ? parsed : undefined;
2329
- }
2330
- function buildAICoderQaEvidence(input) {
2331
- var _a, _b, _c;
2332
- var app = input.app || {};
2333
- var job = input.job || {};
2334
- var workflowMemory = plainObject(job.aiCoderV6WorkflowMemory
2335
- || job.ai_coder_v6_workflow_memory
2336
- || app.aiCoderV6WorkflowMemory
2337
- || app.ai_coder_v6_workflow_memory);
2338
- var evidence = mergeEvidenceRecords(job.qaEvidence, job.qa_evidence, app.qaEvidence, app.qa_evidence, input.qaEvidence);
2339
- evidence.workflowQaRows = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(workflowMemory.workflowQaRows)), false), __read(asArray(workflowMemory.workflow_qa_rows)), false), __read(asArray(job.workflowQaRows)), false), __read(asArray(job.workflow_qa_rows)), false), __read(asArray(app.workflowQaRows)), false), __read(asArray(app.workflow_qa_rows)), false), __read(asArray(evidence.workflowQaRows)), false), __read(asArray(evidence.workflow_qa_rows)), false);
2340
- evidence.businessAssertions = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.aiQaBusinessAssertions)), false), __read(asArray(job.ai_qa_business_assertions)), false), __read(asArray(job.businessAssertions)), false), __read(asArray(job.business_assertions)), false), __read(asArray(app.businessAssertions)), false), __read(asArray(app.business_assertions)), false), __read(asArray(evidence.businessAssertions)), false), __read(asArray(evidence.business_assertions)), false);
2341
- evidence.routeProbes = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(job.workflowProbes)), false), __read(asArray(job.workflow_probes)), false), __read(asArray(evidence.routeProbes)), false), __read(asArray(evidence.route_probes)), false);
2342
- evidence.artifactPaths = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(workflowMemory.businessProofArtifacts)), false), __read(asArray(workflowMemory.business_proof_artifacts)), false), __read(asArray(job.artifactPaths)), false), __read(asArray(job.artifact_paths)), false), __read(asArray(app.artifactPaths)), false), __read(asArray(app.artifact_paths)), false), __read(asArray(evidence.artifactPaths)), false), __read(asArray(evidence.artifact_paths)), false);
2343
- evidence.journeyContract = evidence.journeyContract
2344
- || evidence.journey_contract
2345
- || job.journeyContract
2346
- || job.journey_contract
2347
- || app.journeyContract
2348
- || app.journey_contract
2349
- || workflowMemory.journeyContract
2350
- || workflowMemory.journey_contract;
2351
- evidence.journeyContractMarkdown = evidence.journeyContractMarkdown
2352
- || evidence.journey_contract_markdown
2353
- || job.journeyContractMarkdown
2354
- || job.journey_contract_markdown
2355
- || app.journeyContractMarkdown
2356
- || app.journey_contract_markdown;
2357
- evidence.journeyContractPath = firstNonEmptyText([
2358
- evidence.journeyContractPath,
2359
- evidence.journey_contract_path,
2360
- workflowMemory.journeyContractPath,
2361
- workflowMemory.journey_contract_path,
2362
- job.journeyContractPath,
2363
- job.journey_contract_path,
2364
- app.journeyContractPath,
2365
- app.journey_contract_path
2366
- ], 500) || 'docs/APP_JOURNEY_CONTRACT.md';
2367
- evidence.deployStatus = firstNonEmptyText([
2368
- evidence.deployStatus,
2369
- evidence.deploy_status,
2370
- job.deployStatus,
2371
- job.deploy_status,
2372
- job.testDeployStatus,
2373
- job.test_deploy_status,
2374
- app.deployStatus,
2375
- app.deploy_status
2376
- ], 160);
2377
- evidence.publishStatus = firstNonEmptyText([
2378
- evidence.publishStatus,
2379
- evidence.publish_status,
2380
- evidence.pullRequestStatus,
2381
- evidence.pull_request_status,
2382
- job.publishStatus,
2383
- job.publish_status,
2384
- job.pullRequestStatus,
2385
- job.pull_request_status,
2386
- app.publishStatus,
2387
- app.publish_status
2388
- ], 160);
2389
- evidence.sampleDataStatus = firstNonEmptyText([
2390
- evidence.sampleDataStatus,
2391
- evidence.sample_data_status,
2392
- job.sampleDataStatus,
2393
- job.sample_data_status,
2394
- app.sampleDataStatus,
2395
- app.sample_data_status
2396
- ], 160) || statusFromBoolean((_c = (_b = (_a = evidence.sampleDataReady) !== null && _a !== void 0 ? _a : evidence.hasSampleData) !== null && _b !== void 0 ? _b : job.sampleDataReady) !== null && _c !== void 0 ? _c : app.sampleDataReady);
2397
- return evidence;
2398
- }
2399
- function normalizeAICoderWorkflowProofReadiness(value, now) {
2400
- if (!value || !Object.keys(value).length) {
2401
- return undefined;
2402
- }
2403
- var ready = value.ready === true;
2404
- var status = cleanText(value.status, 120) || (ready ? 'ready' : 'blocked');
2405
- return {
2406
- ready: ready,
2407
- status: status,
2408
- reason: cleanText(value.reason || value.summary || status, 1200),
2409
- blockers: cleanStringList(value.blockers, 40, 500),
2410
- journeyContractValid: value.journeyContractValid === true || value.journey_contract_valid === true,
2411
- primaryWorkflowId: cleanText(value.primaryWorkflowId || value.primary_workflow_id, 200),
2412
- passedWorkflowRows: cleanStringList(value.passedWorkflowRows || value.passed_workflow_rows, 80, 300),
2413
- missingWorkflowRows: cleanStringList(value.missingWorkflowRows || value.missing_workflow_rows, 80, 300),
2414
- failedWorkflowRows: cleanStringList(value.failedWorkflowRows || value.failed_workflow_rows, 80, 300),
2415
- passedBusinessAssertions: cleanStringList(value.passedBusinessAssertions || value.passed_business_assertions, 80, 500),
2416
- routeOnly: value.routeOnly === true || value.route_only === true,
2417
- scorecardOnly: value.scorecardOnly === true || value.scorecard_only === true,
2418
- sampleDataReady: value.sampleDataReady === true || value.sample_data_ready === true,
2419
- releaseBlockers: cleanStringList(value.releaseBlockers || value.release_blockers, 40, 500),
2420
- artifactPaths: cleanStringList(value.artifactPaths || value.artifact_paths, 80, 500),
2421
- workflowProofFingerprint: cleanText(value.workflowProofFingerprint || value.workflow_proof_fingerprint, 200),
2422
- artifactFingerprint: cleanText(value.artifactFingerprint || value.artifact_fingerprint, 200),
2423
- proofFreshness: cleanText(value.proofFreshness || value.proof_freshness, 80),
2424
- nextAction: cleanText(value.nextAction || value.next_action, 1000),
2425
- evaluatedAt: isoNow(now || value.evaluatedAt || value.evaluated_at || value.recordedAt || value.recorded_at)
2426
- };
2427
- }
2428
- function aicoderJourneyContractValidationFromEvidence(evidence) {
2429
- var journeyInput = evidence.journeyContract !== undefined && evidence.journeyContract !== null
2430
- ? evidence.journeyContract
2431
- : evidence.journeyContractMarkdown;
2432
- var hasJourneyInput = journeyInput !== undefined && journeyInput !== null && cleanText(journeyInput, 100).length > 0;
2433
- if (!hasJourneyInput) {
2434
- return {
2435
- valid: false,
2436
- contract: null,
2437
- issues: [{
2438
- code: 'missing_contract',
2439
- path: cleanText(evidence.journeyContractPath, 500) || 'docs/APP_JOURNEY_CONTRACT.md',
2440
- message: 'docs/APP_JOURNEY_CONTRACT.md with structured journey_contract JSON is required before AICoder build, workflow QA, wow UI, publish, or acceptance.',
2441
- severity: 'error'
2442
- }],
2443
- workflowQaRows: [],
2444
- primaryWorkflowId: ''
2445
- };
2446
- }
2447
- return (0, aicoder_runner_v6_1.validateResolveIOAICoderJourneyContract)(journeyInput, {
2448
- requireMarkdownEnvelope: typeof journeyInput === 'string'
2449
- });
2450
- }
2451
- function aicoderJourneyContractGate(validation, evidence, now) {
2452
- var errorIssues = validation.issues.filter(function (issue) { return issue.severity === 'error'; });
2453
- var warningIssues = validation.issues.filter(function (issue) { return issue.severity === 'warning'; });
2454
- var status = validation.valid
2455
- ? (warningIssues.length ? 'warn' : 'pass')
2456
- : 'blocked';
2457
- var path = cleanText(evidence.journeyContractPath, 500) || 'docs/APP_JOURNEY_CONTRACT.md';
2458
- return {
2459
- key: 'aicoder_journey_contract',
2460
- label: 'AICoder journey contract',
2461
- status: status,
2462
- reason: validation.valid
2463
- ? (warningIssues.length
2464
- ? "Journey contract is valid with warnings: ".concat(warningIssues.map(function (issue) { return issue.message; }).slice(0, 3).join(' | '))
2465
- : 'Journey contract validates first/next/last workflow, data story, completion states, and QA assertions.')
2466
- : (errorIssues.map(function (issue) { return issue.message; }).slice(0, 5).join(' | ') || 'AICoder Journey Contract is missing or invalid.'),
2467
- evidenceRefs: [path],
2468
- recordedAt: isoNow(now),
2469
- metadata: {
2470
- path: path,
2471
- valid: validation.valid,
2472
- primaryWorkflowId: cleanText(validation.primaryWorkflowId, 200),
2473
- workflowQaRowCount: validation.workflowQaRows.length,
2474
- errorCount: errorIssues.length,
2475
- warningCount: warningIssues.length,
2476
- issueCodes: cleanStringList(validation.issues.map(function (issue) { return issue.code; }), 40, 120),
2477
- issues: validation.issues.slice(0, 20).map(function (issue) { return ({
2478
- code: cleanText(issue.code, 120),
2479
- path: cleanText(issue.path, 500),
2480
- severity: issue.severity,
2481
- message: cleanText(issue.message, 800)
2482
- }); }),
2483
- blocksBuildUntilValid: !validation.valid,
2484
- blocksWorkflowQaUntilValid: !validation.valid,
2485
- blocksWowUiUntilWorkflowProof: !validation.valid,
2486
- blocksPublishUntilWorkflowProof: !validation.valid,
2487
- nextAction: validation.valid
2488
- ? 'Generate workflow QA rows from journey_contract.qa_assertions and execute the north-star workflow.'
2489
- : 'Generate or repair docs/APP_JOURNEY_CONTRACT.md before app build, wow UI, publish, or acceptance.'
2490
- }
2491
- };
2492
- }
2493
- function aicoderWorkflowProofReadinessGate(readiness, now) {
2494
- var status = readiness.ready
2495
- ? 'pass'
2496
- : readiness.status === 'release_blocked' || readiness.status === 'journey_invalid' || readiness.status === 'sample_data_missing'
2497
- ? 'fail'
2498
- : 'blocked';
2499
- return {
2500
- key: 'aicoder_workflow_proof_readiness',
2501
- label: 'AICoder workflow proof readiness',
2502
- status: status,
2503
- reason: readiness.reason || readiness.blockers.join('; ') || readiness.status,
2504
- evidenceRefs: readiness.artifactPaths,
2505
- recordedAt: isoNow(now || readiness.evaluatedAt),
2506
- metadata: {
2507
- ready: readiness.ready,
2508
- status: readiness.status,
2509
- primaryWorkflowId: readiness.primaryWorkflowId,
2510
- journeyContractValid: readiness.journeyContractValid,
2511
- blockers: readiness.blockers,
2512
- passedWorkflowRows: readiness.passedWorkflowRows,
2513
- missingWorkflowRows: readiness.missingWorkflowRows,
2514
- failedWorkflowRows: readiness.failedWorkflowRows,
2515
- passedBusinessAssertions: readiness.passedBusinessAssertions,
2516
- routeOnly: readiness.routeOnly,
2517
- scorecardOnly: readiness.scorecardOnly,
2518
- sampleDataReady: readiness.sampleDataReady,
2519
- releaseBlockers: readiness.releaseBlockers,
2520
- workflowProofFingerprint: readiness.workflowProofFingerprint,
2521
- artifactFingerprint: readiness.artifactFingerprint,
2522
- proofFreshness: readiness.proofFreshness,
2523
- nextAction: readiness.nextAction
2524
- }
2525
- };
2526
- }
2527
- function aicoderWorkflowProofCheckpointObject(app, job, evidence) {
2528
- var workflowMemory = plainObject(job.aiCoderV6WorkflowMemory
2529
- || job.ai_coder_v6_workflow_memory
2530
- || app.aiCoderV6WorkflowMemory
2531
- || app.ai_coder_v6_workflow_memory
2532
- || evidence.aiCoderV6WorkflowMemory
2533
- || evidence.ai_coder_v6_workflow_memory);
2534
- var continuationDecision = plainObject(job.aicoderV6ContinuationDecision
2535
- || job.aiCoderV6ContinuationDecision
2536
- || job.aicoder_v6_continuation_decision
2537
- || job.ai_coder_v6_continuation_decision
2538
- || app.aicoderV6ContinuationDecision
2539
- || app.aiCoderV6ContinuationDecision
2540
- || app.aicoder_v6_continuation_decision
2541
- || evidence.aicoderV6ContinuationDecision
2542
- || evidence.aiCoderV6ContinuationDecision
2543
- || evidence.aicoder_v6_continuation_decision);
2544
- return evidenceObject(continuationDecision.workflowProofCheckpoint, continuationDecision.workflow_proof_checkpoint, workflowMemory.workflowProofCheckpoint, workflowMemory.workflow_proof_checkpoint, job.workflowProofCheckpoint, job.workflow_proof_checkpoint, job.aicoderWorkflowProofCheckpoint, job.aicoder_workflow_proof_checkpoint, app.workflowProofCheckpoint, app.workflow_proof_checkpoint, evidence.workflowProofCheckpoint, evidence.workflow_proof_checkpoint, evidence.aicoderWorkflowProofCheckpoint, evidence.aicoder_workflow_proof_checkpoint);
2545
- }
2546
- function aicoderWorkflowProofCheckpointGate(checkpoint, now) {
2547
- var _a, _b, _c, _d, _e;
2548
- if (!checkpoint || !Object.keys(checkpoint).length) {
2549
- return undefined;
2550
- }
2551
- var blocksProductRepairUntilJourneyContract = booleanFlag((_a = checkpoint.blocksProductRepairUntilJourneyContract) !== null && _a !== void 0 ? _a : checkpoint.blocks_product_repair_until_journey_contract) === true;
2552
- var blocksPublishUntilWorkflowProof = booleanFlag((_b = checkpoint.blocksPublishUntilWorkflowProof) !== null && _b !== void 0 ? _b : checkpoint.blocks_publish_until_workflow_proof) === true;
2553
- var blocksPublishUntilReleaseGate = booleanFlag((_c = checkpoint.blocksPublishUntilReleaseGate) !== null && _c !== void 0 ? _c : checkpoint.blocks_publish_until_release_gate) === true;
2554
- var blocksWowUiUntilWorkflowProof = booleanFlag((_d = checkpoint.blocksWowUiUntilWorkflowProof) !== null && _d !== void 0 ? _d : checkpoint.blocks_wow_ui_until_workflow_proof) === true;
2555
- var statusText = cleanText(checkpoint.status, 120);
2556
- var required = booleanFlag(checkpoint.required) !== false;
2557
- var blockers = cleanStringList(checkpoint.blockers, 40, 500);
2558
- if (blocksProductRepairUntilJourneyContract) {
2559
- blockers.push('Product repair is blocked until the journey contract is valid.');
2560
- }
2561
- if (blocksPublishUntilWorkflowProof) {
2562
- blockers.push('Publish is blocked until workflow business proof passes.');
2563
- }
2564
- if (blocksPublishUntilReleaseGate) {
2565
- blockers.push('Publish is blocked until release gate evidence passes.');
2566
- }
2567
- if (blocksWowUiUntilWorkflowProof) {
2568
- blockers.push('Wow UI polish is blocked until workflow proof exists.');
2569
- }
2570
- var gateStatus = !required || statusText === 'ready_to_continue'
2571
- ? 'pass'
2572
- : blockers.length
2573
- ? 'blocked'
2574
- : 'warn';
2575
- return {
2576
- key: 'aicoder_workflow_proof_checkpoint',
2577
- label: 'AICoder workflow proof checkpoint',
2578
- status: gateStatus,
2579
- reason: gateStatus === 'pass'
2580
- ? 'AICoder workflow checkpoint allows the next action.'
2581
- : (blockers.join(' ') || cleanText(checkpoint.nextAction || checkpoint.next_action || statusText, 1200) || 'AICoder workflow checkpoint requires more proof before continuing.'),
2582
- evidenceRefs: cleanStringList(__spreadArray(__spreadArray([], __read(asArray(checkpoint.requiredEvidence || checkpoint.required_evidence)), false), __read(asArray(checkpoint.requiredResetEvidence || checkpoint.required_reset_evidence)), false), 40, 500),
2583
- recordedAt: isoNow(now || checkpoint.recordedAt || checkpoint.recorded_at || checkpoint.createdAt || checkpoint.created_at),
2584
- metadata: {
2585
- required: required,
2586
- status: statusText,
2587
- readinessStatus: cleanText(checkpoint.readinessStatus || checkpoint.readiness_status, 120),
2588
- nextGate: cleanText(checkpoint.nextGate || checkpoint.next_gate, 120),
2589
- nextAction: cleanText(checkpoint.nextAction || checkpoint.next_action, 1000),
2590
- startingFailureClass: cleanText(checkpoint.startingFailureClass || checkpoint.starting_failure_class, 120),
2591
- startingBlockerFingerprint: cleanText(checkpoint.startingBlockerFingerprint || checkpoint.starting_blocker_fingerprint, 200),
2592
- startingEvidenceHash: cleanText(checkpoint.startingEvidenceHash || checkpoint.starting_evidence_hash, 200),
2593
- workflowProofFingerprint: cleanText(checkpoint.workflowProofFingerprint || checkpoint.workflow_proof_fingerprint, 200),
2594
- artifactFingerprint: cleanText(checkpoint.artifactFingerprint || checkpoint.artifact_fingerprint, 200),
2595
- requiredEvidence: cleanStringList(checkpoint.requiredEvidence || checkpoint.required_evidence, 40, 500),
2596
- requiredResetEvidence: cleanStringList(checkpoint.requiredResetEvidence || checkpoint.required_reset_evidence, 40, 500),
2597
- successRequiresWorkflowBusinessProof: booleanFlag((_e = checkpoint.successRequiresWorkflowBusinessProof) !== null && _e !== void 0 ? _e : checkpoint.success_requires_workflow_business_proof) === true,
2598
- blocksProductRepairUntilJourneyContract: blocksProductRepairUntilJourneyContract,
2599
- blocksPublishUntilWorkflowProof: blocksPublishUntilWorkflowProof,
2600
- blocksPublishUntilReleaseGate: blocksPublishUntilReleaseGate,
2601
- blocksWowUiUntilWorkflowProof: blocksWowUiUntilWorkflowProof,
2602
- blockers: blockers
2603
- }
2604
- };
2605
- }
2606
- function aicoderNextActionContractObject(app, job, evidence) {
2607
- var continuationDecision = plainObject(job.aicoderV6ContinuationDecision
2608
- || job.aiCoderV6ContinuationDecision
2609
- || job.aicoder_v6_continuation_decision
2610
- || job.ai_coder_v6_continuation_decision
2611
- || app.aicoderV6ContinuationDecision
2612
- || app.aiCoderV6ContinuationDecision
2613
- || app.aicoder_v6_continuation_decision
2614
- || evidence.aicoderV6ContinuationDecision
2615
- || evidence.aiCoderV6ContinuationDecision
2616
- || evidence.aicoder_v6_continuation_decision);
2617
- return evidenceObject(continuationDecision.nextActionContract, continuationDecision.next_action_contract, job.nextActionContract, job.next_action_contract, job.aicoderNextActionContract, job.aicoder_next_action_contract, job.aiCoderNextActionContract, job.ai_coder_next_action_contract, app.nextActionContract, app.next_action_contract, evidence.nextActionContract, evidence.next_action_contract, evidence.aicoderNextActionContract, evidence.aicoder_next_action_contract);
2618
- }
2619
- function aicoderNextActionContractGate(contract, now) {
2620
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2621
- if (!contract || !Object.keys(contract).length) {
2622
- return undefined;
2623
- }
2624
- var safeToAutoRun = booleanFlag((_a = contract.safeToAutoRun) !== null && _a !== void 0 ? _a : contract.safe_to_auto_run) === true;
2625
- var requiresHumanApproval = booleanFlag((_b = contract.requiresHumanApproval) !== null && _b !== void 0 ? _b : contract.requires_human_approval) === true;
2626
- var canRunWithoutCodexMonitor = booleanFlag((_c = contract.canRunWithoutCodexMonitor) !== null && _c !== void 0 ? _c : contract.can_run_without_codex_monitor) === true;
2627
- var codexFallbackRequired = booleanFlag((_d = contract.codexFallbackRequired) !== null && _d !== void 0 ? _d : contract.codex_fallback_required) === true;
2628
- var sourceBlockers = cleanStringList(contract.blockers, 40, 500);
2629
- var primaryCommand = cleanText(contract.primaryCommand || contract.primary_command, 200);
2630
- var liveHotfixBlockedUntilCommit = booleanFlag((_g = (_f = (_e = contract.liveHotfixBlockedUntilCommit) !== null && _e !== void 0 ? _e : contract.live_hotfix_blocked_until_commit) !== null && _f !== void 0 ? _f : plainObject(contract.decisionBasis || contract.decision_basis).liveHotfixBlockedUntilCommit) !== null && _g !== void 0 ? _g : plainObject(contract.decisionBasis || contract.decision_basis).live_hotfix_blocked_until_commit) === true;
2631
- var safetyBlockers = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((safeToAutoRun ? [] : ['AICoder next action is not marked safe to auto-run.'])), false), __read((canRunWithoutCodexMonitor ? [] : ['AICoder next action requires Codex fallback/monitoring instead of manager-only execution.'])), false), __read((codexFallbackRequired ? [cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000) || 'AICoder next action contract requires Codex fallback.'] : [])), false), __read((requiresHumanApproval ? ['AICoder next action requires human approval.'] : [])), false), __read((liveHotfixBlockedUntilCommit ? ['Live AICoder hotfix is blocked until GitHub commit and push proof is recorded.'] : [])), false))).filter(Boolean).slice(0, 40);
2632
- var contractBlockers = safetyBlockers.length
2633
- ? Array.from(new Set(__spreadArray(__spreadArray([], __read(sourceBlockers), false), __read(safetyBlockers), false))).slice(0, 40)
2634
- : [];
2635
- var missingSafetyFlags = [
2636
- contract.safeToAutoRun === undefined && contract.safe_to_auto_run === undefined ? 'safeToAutoRun' : '',
2637
- contract.canRunWithoutCodexMonitor === undefined && contract.can_run_without_codex_monitor === undefined ? 'canRunWithoutCodexMonitor' : '',
2638
- contract.codexFallbackRequired === undefined && contract.codex_fallback_required === undefined ? 'codexFallbackRequired' : ''
2639
- ].filter(Boolean);
2640
- var gateStatus = contractBlockers.length
2641
- ? 'blocked'
2642
- : missingSafetyFlags.length
2643
- ? 'warn'
2644
- : 'pass';
2645
- return {
2646
- key: 'aicoder_next_action_contract',
2647
- label: 'AICoder next action contract',
2648
- status: gateStatus,
2649
- reason: gateStatus === 'pass'
2650
- ? "AICoder can run ".concat(primaryCommand || 'the next action', " without a Codex monitor.")
2651
- : (contractBlockers.join(' ') || cleanText(contract.codexFallbackReason || contract.codex_fallback_reason || contract.expectedStateTransition || contract.expected_state_transition, 1200) || 'AICoder next action is not safe to run unattended.'),
2652
- evidenceRefs: cleanStringList(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(contract.preconditions)), false), __read(asArray(contract.successEvidence || contract.success_evidence)), false), __read(asArray(contract.stopConditions || contract.stop_conditions)), false), 40, 500),
2653
- recordedAt: isoNow(now || contract.createdAt || contract.created_at || contract.recordedAt || contract.recorded_at),
2654
- metadata: {
2655
- contractId: cleanText(contract.contractId || contract.contract_id, 200),
2656
- action: cleanText(contract.action, 120),
2657
- label: cleanText(contract.label, 200),
2658
- primaryCommand: primaryCommand,
2659
- lane: cleanText(contract.lane, 120),
2660
- stepType: cleanText(contract.stepType || contract.step_type, 120),
2661
- safeToAutoRun: safeToAutoRun,
2662
- requiresHumanApproval: requiresHumanApproval,
2663
- canRunWithoutCodexMonitor: canRunWithoutCodexMonitor,
2664
- codexFallbackRequired: codexFallbackRequired,
2665
- codexFallbackReason: cleanText(contract.codexFallbackReason || contract.codex_fallback_reason, 1000),
2666
- costRisk: cleanText(contract.costRisk || contract.cost_risk, 120),
2667
- workflowFirstSatisfied: booleanFlag((_h = contract.workflowFirstSatisfied) !== null && _h !== void 0 ? _h : contract.workflow_first_satisfied) === true,
2668
- hotfixCommitRequired: booleanFlag((_l = (_k = (_j = contract.hotfixCommitRequired) !== null && _j !== void 0 ? _j : contract.hotfix_commit_required) !== null && _k !== void 0 ? _k : plainObject(contract.decisionBasis || contract.decision_basis).hotfixCommitRequired) !== null && _l !== void 0 ? _l : plainObject(contract.decisionBasis || contract.decision_basis).hotfix_commit_required) === true,
2669
- liveHotfixBlockedUntilCommit: liveHotfixBlockedUntilCommit,
2670
- decisionBasis: plainObject(contract.decisionBasis || contract.decision_basis),
2671
- preconditions: cleanStringList(contract.preconditions, 40, 500),
2672
- expectedStateTransition: cleanText(contract.expectedStateTransition || contract.expected_state_transition, 1000),
2673
- successEvidence: cleanStringList(contract.successEvidence || contract.success_evidence, 40, 500),
2674
- requiredHotfixCommitProof: cleanStringList(contract.requiredHotfixCommitProof || contract.required_hotfix_commit_proof, 20, 240),
2675
- stopConditions: cleanStringList(contract.stopConditions || contract.stop_conditions, 40, 500),
2676
- forbiddenActions: cleanStringList(contract.forbiddenActions || contract.forbidden_actions, 40, 500),
2677
- nextCommands: cleanStringList(contract.nextCommands || contract.next_commands, 40, 240),
2678
- blockers: contractBlockers,
2679
- contextBlockers: sourceBlockers,
2680
- safetyBlockers: safetyBlockers,
2681
- missingSafetyFlags: missingSafetyFlags,
2682
- ownerFiles: cleanStringList(contract.ownerFiles || contract.owner_files, 40, 500)
2683
- }
2684
- };
2685
- }
2686
- function adapterStatusPassed(value) {
2687
- var normalized = cleanText(value, 120).toLowerCase();
2688
- return !!normalized && /(pass|passed|success|succeeded|ok|done|complete|completed|ready|saved|published|deployed)/i.test(normalized);
2689
- }
2690
- function applyAICoderWorkflowProofGate(qa, readiness, now) {
2691
- if (readiness.ready
2692
- || readiness.status === 'release_blocked'
2693
- || qa.outcome === 'infra_failed'
2694
- || qa.outcome === 'compile_failed'
2695
- || qa.outcome === 'route_failed'
2696
- || qa.outcome === 'business_assertion_failed') {
2697
- return qa;
2698
- }
2699
- var gate = aicoderWorkflowProofReadinessGate(readiness, now);
2700
- return __assign(__assign({}, qa), { outcome: qa.routeProbes.some(function (probe) { return adapterStatusPassed(probe.status); })
2701
- ? 'route_only_pass'
2702
- : 'incomplete', gateResults: __spreadArray(__spreadArray([], __read(qa.gateResults.filter(function (existing) { return !(existing.key === 'qa_business_assertion' && existing.status === 'pass'); })), false), [
2703
- gate
2704
- ], false) });
2705
- }
2706
- function assistantQualityObject(input) {
2707
- var _a, _b;
2708
- var conversation = input.conversation || {};
2709
- var latestAssistantMessage = __spreadArray([], __read(asArray(input.messages)), false).reverse()
2710
- .find(function (message) { return /assistant/i.test(cleanText(message.role || message.authorRole || message.type, 80)); });
2711
- return plainObject(input.answerQuality
2712
- || conversation.answerQuality
2713
- || conversation.answer_quality
2714
- || conversation.assistantAnswerQuality
2715
- || conversation.assistant_answer_quality
2716
- || (latestAssistantMessage === null || latestAssistantMessage === void 0 ? void 0 : latestAssistantMessage.answerQuality)
2717
- || (latestAssistantMessage === null || latestAssistantMessage === void 0 ? void 0 : latestAssistantMessage.answer_quality)
2718
- || ((_a = latestAssistantMessage === null || latestAssistantMessage === void 0 ? void 0 : latestAssistantMessage.metadata) === null || _a === void 0 ? void 0 : _a.answerQuality)
2719
- || ((_b = latestAssistantMessage === null || latestAssistantMessage === void 0 ? void 0 : latestAssistantMessage.metadata) === null || _b === void 0 ? void 0 : _b.answer_quality));
2720
- }
2721
- function assistantConfidenceLevel(value) {
2722
- 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, 80).toLowerCase();
2723
- if (/^high$/.test(normalized)) {
2724
- return 'high';
2725
- }
2726
- if (/^medium$/.test(normalized)) {
2727
- return 'medium';
2728
- }
2729
- if (/^low$/.test(normalized)) {
2730
- return 'low';
2731
- }
2732
- return 'unknown';
2733
- }
2734
- function assistantQueryStatus(value) {
2735
- var normalized = cleanText((value === null || value === void 0 ? void 0 : value.status) || (value === null || value === void 0 ? void 0 : value.queryStatus) || (value === null || value === void 0 ? void 0 : value.query_status) || value, 120).toLowerCase().replace(/[\s-]+/g, '_');
2736
- if (/^(ok|success|answered|data_found|data)$/.test(normalized)) {
2737
- return 'ok';
2738
- }
2739
- if (/^(no_data|no_results|empty|not_found)$/.test(normalized)) {
2740
- return 'no_data';
2741
- }
2742
- if (/^(query_error|mongo_error|error|failed)$/.test(normalized)) {
2743
- return 'query_error';
2744
- }
2745
- if (/^(permission_error|permission_denied|forbidden|unauthorized)$/.test(normalized)) {
2746
- return 'permission_error';
2747
- }
2748
- return 'unknown';
2749
- }
2750
- function asObjectList(value) {
2751
- return asArray(value).filter(function (entry) { return entry && typeof entry === 'object' && !Array.isArray(entry); });
2752
- }
2753
- function assistantEvidenceRefs(quality) {
2754
- return cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(quality.evidenceRefs)), false), __read(asArray(quality.evidence_refs)), false), __read(asArray(quality.citationRefs)), false), __read(asArray(quality.citation_refs)), false), __read(asArray(quality.artifactPaths)), false), __read(asArray(quality.artifact_paths)), false), __read(asObjectList(quality.citations).map(function (citation) { return citation.path || citation.url || citation.id || citation.ref; })), false), __read(asObjectList(quality.evidence).map(function (entry) { return entry.path || entry.url || entry.id || entry.ref; })), false), 80, 500);
2755
- }
2756
- function assistantCitationRefs(quality) {
2757
- return cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(quality.citationRefs)), false), __read(asArray(quality.citation_refs)), false), __read(asObjectList(quality.citations).map(function (citation) { return citation.path || citation.url || citation.id || citation.ref; })), false), __read(asObjectList(quality.evidence).map(function (entry) { return entry.citation || entry.ref || entry.path || entry.url; })), false), 80, 500);
2758
- }
2759
- function assistantQueryExecutions(quality) {
2760
- var queryExecution = plainObject(quality.queryExecution || quality.query_execution);
2761
- var toolResult = plainObject(quality.toolResult || quality.tool_result);
2762
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asObjectList(quality.queryExecutions)), false), __read(asObjectList(quality.query_executions)), false), __read(asObjectList(quality.dataQueries)), false), __read(asObjectList(quality.data_queries)), false), __read(asObjectList(quality.toolResults)), false), __read(asObjectList(quality.tool_results)), false), __read(asObjectList(quality.mongoReads)), false), __read(asObjectList(quality.mongo_reads)), false), __read(asObjectList(quality.mongoAggregations)), false), __read(asObjectList(quality.mongo_aggregations)), false), __read((Object.keys(queryExecution).length ? [queryExecution] : [])), false), __read((Object.keys(toolResult).length ? [toolResult] : [])), false).filter(function (entry) { return Object.keys(entry).length; });
2763
- }
2764
- function assistantQueryEvidenceRefs(quality, executions) {
2765
- if (executions === void 0) { executions = assistantQueryExecutions(quality); }
2766
- return cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(quality.queryEvidenceRefs)), false), __read(asArray(quality.query_evidence_refs)), false), __read(asArray(quality.toolResultRefs)), false), __read(asArray(quality.tool_result_refs)), false), __read(asArray(quality.queryResultRefs)), false), __read(asArray(quality.query_result_refs)), false), __read(executions.map(function (execution) {
2767
- return execution.id
2768
- || execution._id
2769
- || execution.ref
2770
- || execution.toolResultId
2771
- || execution.tool_result_id
2772
- || execution.toolCallId
2773
- || execution.tool_call_id
2774
- || execution.artifactPath
2775
- || execution.artifact_path
2776
- || execution.path
2777
- || execution.url;
2778
- })), false), 80, 500);
2779
- }
2780
- function assistantNextActions(quality) {
2781
- return cleanStringList(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(quality.nextActions)), false), __read(asArray(quality.next_actions)), false), __read(asArray(quality.recommendedActions)), false), __read(asArray(quality.recommended_actions)), false), 20, 500);
2782
- }
2783
- function normalizedIsoDay(value) {
2784
- if (!value) {
2785
- return '';
2786
- }
2787
- var date = value instanceof Date ? value : new Date(value);
2788
- if (!Number.isFinite(date.getTime())) {
2789
- return cleanText(value, 40).slice(0, 10);
2790
- }
2791
- return date.toISOString().slice(0, 10);
2792
- }
2793
- function assistantDateWindowObject(quality) {
2794
- var _a, _b, _c;
2795
- var dateWindow = plainObject(quality.dateWindow || quality.date_window);
2796
- var nestedWindow = plainObject(((_b = (_a = quality.verification) === null || _a === void 0 ? void 0 : _a.metrics) === null || _b === void 0 ? void 0 : _b.window) || ((_c = quality.metrics) === null || _c === void 0 ? void 0 : _c.window));
2797
- return Object.keys(dateWindow).length ? dateWindow : nestedWindow;
2798
- }
2799
- function collectMongoProjectionObjects(value, result) {
2800
- var e_31, _a;
2801
- if (result === void 0) { result = []; }
2802
- if (!value || typeof value !== 'object') {
2803
- return result;
2804
- }
2805
- if (Array.isArray(value)) {
2806
- try {
2807
- for (var value_3 = __values(value), value_3_1 = value_3.next(); !value_3_1.done; value_3_1 = value_3.next()) {
2808
- var entry = value_3_1.value;
2809
- collectMongoProjectionObjects(entry, result);
2810
- }
2811
- }
2812
- catch (e_31_1) { e_31 = { error: e_31_1 }; }
2813
- finally {
2814
- try {
2815
- if (value_3_1 && !value_3_1.done && (_a = value_3.return)) _a.call(value_3);
2816
- }
2817
- finally { if (e_31) throw e_31.error; }
2818
- }
2819
- return result;
2820
- }
2821
- if (value.projection && typeof value.projection === 'object' && !Array.isArray(value.projection)) {
2822
- result.push(value.projection);
2823
- }
2824
- if (value.options && typeof value.options === 'object' && !Array.isArray(value.options) && value.options.projection) {
2825
- collectMongoProjectionObjects({ projection: value.options.projection }, result);
2826
- }
2827
- if (value.query && typeof value.query === 'object') {
2828
- collectMongoProjectionObjects(value.query, result);
2829
- }
2830
- if (value.mongoQuery && typeof value.mongoQuery === 'object') {
2831
- collectMongoProjectionObjects(value.mongoQuery, result);
2832
- }
2833
- if (value.mongo_query && typeof value.mongo_query === 'object') {
2834
- collectMongoProjectionObjects(value.mongo_query, result);
2835
- }
2836
- return result;
2837
- }
2838
- function projectionHasPositionalOperator(projection) {
2839
- return Object.keys(projection || {}).some(function (key) { return /\.(?:\$|\$\[)|\.\$$/.test(key); });
2840
- }
2841
- function assistantQueryShapeLegal(quality) {
2842
- if (quality.legalQueryShape === true || quality.legal_query_shape === true) {
2843
- return true;
2844
- }
2845
- if (quality.legalQueryShape === false || quality.legal_query_shape === false || quality.illegalQueryShape === true || quality.illegal_query_shape === true) {
2846
- return false;
2847
- }
2848
- var queryShape = plainObject(quality.queryShape || quality.query_shape);
2849
- if (queryShape.legal === true || queryShape.status === 'pass') {
2850
- return true;
2851
- }
2852
- if (queryShape.legal === false || queryShape.status === 'fail') {
2853
- return false;
2854
- }
2855
- var projections = collectMongoProjectionObjects(quality);
2856
- if (projections.some(projectionHasPositionalOperator)) {
2857
- return false;
2858
- }
2859
- return true;
2860
- }
2861
- function assistantCorrectnessFailed(checks) {
2862
- return checks
2863
- .filter(function (check) {
2864
- var status = cleanText(check.status || (check.passed === true ? 'pass' : check.passed === false ? 'fail' : ''), 80).toLowerCase();
2865
- return /^(fail|failed|blocked|incorrect|wrong|error)$/.test(status);
2866
- })
2867
- .map(function (check) { return cleanText(check.assertion || check.name || check.case || check.reason || 'assistant correctness check failed', 300); })
2868
- .slice(0, 20);
2869
- }
2870
- function evaluateAssistantAnswerQuality(input) {
2871
- var _a, _b;
2872
- if (input === void 0) { input = {}; }
2873
- var quality = plainObject(input.answerQuality);
2874
- var now = isoNow(input.now);
2875
- var correctnessChecks = asArray(input.correctnessChecks);
2876
- var failedChecks = assistantCorrectnessFailed(correctnessChecks);
2877
- var queryStatus = assistantQueryStatus(quality.queryStatus || quality.query_status || quality.queryResult || quality.query_result);
2878
- var confidenceLevel = assistantConfidenceLevel(quality.confidence || quality.confidenceLevel || quality.confidence_level);
2879
- var evidenceRefs = assistantEvidenceRefs(quality);
2880
- var citationRefs = assistantCitationRefs(quality);
2881
- var queryExecutions = assistantQueryExecutions(quality);
2882
- var queryEvidenceRefs = assistantQueryEvidenceRefs(quality, queryExecutions);
2883
- var nextActions = assistantNextActions(quality);
2884
- var requiresCurrentDate = quality.requiresCurrentDate === true || quality.requires_current_date === true;
2885
- var dateWindowRequired = quality.requiresDateWindow === true
2886
- || quality.requires_date_window === true
2887
- || quality.dateWindowRequired === true
2888
- || quality.date_window_required === true;
2889
- var requiresCitations = quality.requiresCitations !== false && quality.requires_citations !== false;
2890
- var requiresNextAction = quality.requiresNextAction !== false && quality.requires_next_action !== false;
2891
- var dateWindow = assistantDateWindowObject(quality);
2892
- var dateWindowStart = cleanText(dateWindow.startDate || dateWindow.start_date || dateWindow.start, 80);
2893
- var dateWindowEnd = cleanText(dateWindow.endDate || dateWindow.end_date || dateWindow.end, 80);
2894
- var dateWindowPresent = !!dateWindowStart && !!dateWindowEnd;
2895
- var dateBasis = cleanText(quality.currentDateUsed
2896
- || quality.current_date_used
2897
- || quality.dateBasis
2898
- || quality.date_basis
2899
- || ((_a = quality.dateWindow) === null || _a === void 0 ? void 0 : _a.basisDate)
2900
- || ((_b = quality.date_window) === null || _b === void 0 ? void 0 : _b.basis_date), 80);
2901
- var expectedCurrentDate = cleanText(quality.expectedCurrentDate || quality.expected_current_date, 80)
2902
- || normalizedIsoDay(input.now);
2903
- var noDataConfirmed = quality.noDataConfirmed === true
2904
- || quality.no_data_confirmed === true
2905
- || quality.confirmedNoData === true
2906
- || quality.confirmed_no_data === true;
2907
- var legalQueryShape = assistantQueryShapeLegal(quality);
2908
- var queryEvidenceRequired = quality.requiresQueryEvidence !== false
2909
- && quality.requires_query_evidence !== false
2910
- && (queryStatus === 'ok' || queryStatus === 'no_data');
2911
- var queryEvidencePresent = queryExecutions.length > 0 || queryEvidenceRefs.length > 0;
2912
- var blockers = [];
2913
- var status = 'ready';
2914
- var reason = 'Assistant answer has structured data evidence, legal query shape, citations, confidence, and next action.';
2915
- if (!Object.keys(quality).length) {
2916
- status = 'missing_data_source';
2917
- blockers.push('Assistant answerQuality evidence is missing.');
2918
- reason = 'Assistant answer cannot be accepted without structured answerQuality evidence.';
2919
- }
2920
- else if (failedChecks.length) {
2921
- status = 'incorrect';
2922
- blockers.push.apply(blockers, __spreadArray([], __read(failedChecks), false));
2923
- reason = 'Assistant correctness checks failed.';
2924
- }
2925
- else if (queryStatus === 'permission_error') {
2926
- status = 'permission_error';
2927
- blockers.push('Assistant data query was blocked by permission or authorization.');
2928
- reason = 'Assistant must report permission-error state and avoid claiming no data or success.';
2929
- }
2930
- else if (queryStatus === 'query_error') {
2931
- status = 'query_error';
2932
- blockers.push('Assistant data query failed.');
2933
- reason = 'Assistant must report query-error state and avoid claiming no data or success.';
2934
- }
2935
- else if (!legalQueryShape) {
2936
- status = 'illegal_query_shape';
2937
- blockers.push('Assistant query shape is illegal or uses an unsafe Mongo projection shape.');
2938
- reason = 'Assistant must use legal Mongo query/projection shapes before answering.';
2939
- }
2940
- else if (requiresCurrentDate && (!dateBasis || normalizedIsoDay(dateBasis) !== normalizedIsoDay(expectedCurrentDate))) {
2941
- status = 'date_incorrect';
2942
- blockers.push("Expected current date ".concat(normalizedIsoDay(expectedCurrentDate) || expectedCurrentDate, ", got ").concat(dateBasis || 'missing date basis', "."));
2943
- reason = 'Assistant answer did not prove it used the actual current date.';
2944
- }
2945
- else if (dateWindowRequired && !dateWindowPresent) {
2946
- status = 'missing_date_window';
2947
- blockers.push('Assistant dated answer did not record concrete date-window start and end evidence.');
2948
- reason = 'Assistant dated answers must record the exact query date window used.';
2949
- }
2950
- else if (queryStatus === 'unknown') {
2951
- status = 'missing_data_source';
2952
- blockers.push('Assistant answer did not record queryStatus ok/no_data/query_error/permission_error.');
2953
- reason = 'Assistant answer must classify data access result before acceptance.';
2954
- }
2955
- else if (queryStatus === 'no_data' && !noDataConfirmed) {
2956
- status = 'no_data_unverified';
2957
- blockers.push('No-data answer was not confirmed by a probe or query evidence.');
2958
- reason = 'Assistant no-data answers require explicit noDataConfirmed evidence.';
2959
- }
2960
- else if (queryEvidenceRequired && !queryEvidencePresent) {
2961
- status = 'missing_query_proof';
2962
- blockers.push('Assistant data answer did not record a structured query execution, tool result, or query evidence reference.');
2963
- reason = 'Assistant answers from system data require structured query/tool execution proof before acceptance.';
2964
- }
2965
- else if (requiresCitations && !citationRefs.length && !evidenceRefs.length) {
2966
- status = 'missing_citations';
2967
- blockers.push('Assistant answer has no cited evidence or artifact reference.');
2968
- reason = 'Assistant answer must cite system data evidence.';
2969
- }
2970
- else if (confidenceLevel === 'low' || confidenceLevel === 'unknown') {
2971
- status = 'low_confidence';
2972
- blockers.push('Assistant answer confidence is low or unknown.');
2973
- reason = 'Assistant answer requires recorded medium/high confidence.';
2974
- }
2975
- else if (requiresNextAction && !nextActions.length) {
2976
- status = 'missing_next_action';
2977
- blockers.push('Assistant answer did not record next actions.');
2978
- reason = 'Assistant answer must provide a next action or explicit no-action state.';
2979
- }
2980
- return {
2981
- ready: status === 'ready',
2982
- status: status,
2983
- reason: reason,
2984
- blockers: blockers,
2985
- queryStatus: queryStatus,
2986
- confidenceLevel: confidenceLevel,
2987
- dateBasis: dateBasis || undefined,
2988
- expectedCurrentDate: expectedCurrentDate || undefined,
2989
- dateWindowRequired: dateWindowRequired,
2990
- dateWindowPresent: dateWindowPresent,
2991
- dateWindow: dateWindowPresent ? {
2992
- startDate: dateWindowStart,
2993
- endDate: dateWindowEnd,
2994
- mode: cleanText(dateWindow.mode || dateWindow.type, 80) || undefined,
2995
- months: typeof dateWindow.months === 'number' ? dateWindow.months : undefined
2996
- } : undefined,
2997
- noDataConfirmed: noDataConfirmed,
2998
- legalQueryShape: legalQueryShape,
2999
- citationRefs: citationRefs,
3000
- queryEvidenceRequired: queryEvidenceRequired,
3001
- queryEvidencePresent: queryEvidencePresent,
3002
- queryEvidenceRefs: queryEvidenceRefs,
3003
- queryExecutionCount: queryExecutions.length,
3004
- nextActions: nextActions,
3005
- evidenceRefs: evidenceRefs,
3006
- failedChecks: failedChecks,
3007
- recordedAt: now
3008
- };
3009
- }
3010
- function assistantAnswerQualityGate(decision, now) {
3011
- var status = decision.ready
3012
- ? 'pass'
3013
- : /incorrect|date_incorrect|missing_date_window|illegal_query_shape/.test(decision.status)
3014
- ? 'fail'
3015
- : 'blocked';
3016
- return {
3017
- key: 'assistant_answer_quality',
3018
- label: 'Assistant answer quality',
3019
- status: status,
3020
- reason: decision.reason,
3021
- evidenceRefs: decision.evidenceRefs.length ? decision.evidenceRefs : decision.citationRefs,
3022
- recordedAt: isoNow(now || decision.recordedAt),
3023
- metadata: {
3024
- ready: decision.ready,
3025
- status: decision.status,
3026
- queryStatus: decision.queryStatus,
3027
- confidenceLevel: decision.confidenceLevel,
3028
- dateBasis: decision.dateBasis,
3029
- expectedCurrentDate: decision.expectedCurrentDate,
3030
- dateWindowRequired: decision.dateWindowRequired,
3031
- dateWindowPresent: decision.dateWindowPresent,
3032
- dateWindow: decision.dateWindow,
3033
- noDataConfirmed: decision.noDataConfirmed,
3034
- legalQueryShape: decision.legalQueryShape,
3035
- citationRefs: decision.citationRefs,
3036
- queryEvidenceRequired: decision.queryEvidenceRequired,
3037
- queryEvidencePresent: decision.queryEvidencePresent,
3038
- queryEvidenceRefs: decision.queryEvidenceRefs,
3039
- queryExecutionCount: decision.queryExecutionCount,
3040
- nextActions: decision.nextActions,
3041
- blockers: decision.blockers,
3042
- failedChecks: decision.failedChecks
3043
- }
3044
- };
3045
- }
3046
- function assistantActionabilityStatus(decision) {
3047
- switch (decision.status) {
3048
- case 'ready':
3049
- return 'ready_to_answer';
3050
- case 'query_error':
3051
- return 'needs_query_repair';
3052
- case 'permission_error':
3053
- return 'needs_permission';
3054
- case 'no_data_unverified':
3055
- return 'needs_no_data_verification';
3056
- case 'date_incorrect':
3057
- case 'missing_date_window':
3058
- return 'needs_date_window_repair';
3059
- case 'illegal_query_shape':
3060
- return 'needs_query_shape_repair';
3061
- case 'missing_data_source':
3062
- case 'missing_query_proof':
3063
- case 'missing_citations':
3064
- return 'needs_evidence';
3065
- case 'low_confidence':
3066
- return 'needs_confidence_review';
3067
- case 'missing_next_action':
3068
- return 'needs_next_action';
3069
- case 'incorrect':
3070
- return 'incorrect';
3071
- default:
3072
- return 'blocked';
3073
- }
3074
- }
3075
- function assistantActionabilityCommand(status) {
3076
- switch (status) {
3077
- case 'ready_to_answer':
3078
- return 'answer_from_verified_system_data';
3079
- case 'needs_query_repair':
3080
- return 'repair_assistant_query_and_rerun';
3081
- case 'needs_permission':
3082
- return 'request_assistant_data_permission';
3083
- case 'needs_no_data_verification':
3084
- return 'verify_no_data_with_scoped_probe';
3085
- case 'needs_date_window_repair':
3086
- return 'repair_assistant_date_window_and_rerun';
3087
- case 'needs_query_shape_repair':
3088
- return 'repair_assistant_mongo_query_shape';
3089
- case 'needs_confidence_review':
3090
- return 'review_assistant_confidence_evidence';
3091
- case 'needs_next_action':
3092
- return 'add_assistant_next_action';
3093
- case 'incorrect':
3094
- return 'repair_assistant_answer_from_failed_check';
3095
- case 'needs_evidence':
3096
- case 'blocked':
3097
- default:
3098
- return 'collect_assistant_answer_evidence';
3099
- }
3100
- }
3101
- function assistantActionabilityLabel(status) {
3102
- switch (status) {
3103
- case 'ready_to_answer':
3104
- return 'Answer From Verified Data';
3105
- case 'needs_query_repair':
3106
- return 'Repair Query';
3107
- case 'needs_permission':
3108
- return 'Request Data Permission';
3109
- case 'needs_no_data_verification':
3110
- return 'Verify No Data';
3111
- case 'needs_date_window_repair':
3112
- return 'Repair Date Window';
3113
- case 'needs_query_shape_repair':
3114
- return 'Repair Query Shape';
3115
- case 'needs_confidence_review':
3116
- return 'Review Confidence';
3117
- case 'needs_next_action':
3118
- return 'Add Next Action';
3119
- case 'incorrect':
3120
- return 'Repair Incorrect Answer';
3121
- default:
3122
- return 'Collect Answer Evidence';
3123
- }
3124
- }
3125
- function buildAssistantAnswerActionabilityContract(decision, now) {
3126
- var status = assistantActionabilityStatus(decision);
3127
- var primaryCommand = assistantActionabilityCommand(status);
3128
- var ready = status === 'ready_to_answer';
3129
- var noDataReady = ready && decision.queryStatus === 'no_data' && decision.noDataConfirmed;
3130
- var canAnswerCustomer = ready && (decision.queryStatus === 'ok'
3131
- || noDataReady
3132
- || decision.queryEvidenceRequired === false);
3133
- var canDraftSupportReply = canAnswerCustomer && decision.confidenceLevel === 'high';
3134
- var requiresHumanReview = !canAnswerCustomer || canDraftSupportReply;
3135
- var cheapRepair = /needs_(?:no_data|date_window|query_shape|next_action)|needs_evidence/.test(status);
3136
- var blockers = decision.blockers.length
3137
- ? decision.blockers
3138
- : (ready ? [] : [decision.reason]);
3139
- var requiredEvidence = Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((decision.queryEvidenceRequired ? ['structured query/tool execution proof'] : [])), false), __read((decision.dateWindowRequired ? ['concrete date-window start and end'] : [])), false), __read((decision.queryStatus === 'no_data' ? ['noDataConfirmed=true from scoped probe or query evidence'] : [])), false), __read((decision.legalQueryShape ? [] : ['legal Mongo query/projection shape'])), false), __read((decision.citationRefs.length || decision.evidenceRefs.length ? [] : ['citationRefs or evidenceRefs'])), false), __read((decision.nextActions.length ? [] : ['one explicit next action or no-action state'])), false), __read((decision.confidenceLevel === 'low' || decision.confidenceLevel === 'unknown' ? ['medium/high confidence evidence'] : [])), false))).slice(0, 20);
3140
- return {
3141
- contractId: "assistant-actionability:".concat(decision.status, ":").concat(decision.queryStatus, ":").concat(decision.recordedAt),
3142
- status: status,
3143
- primaryCommand: primaryCommand,
3144
- label: assistantActionabilityLabel(status),
3145
- canAnswerCustomer: canAnswerCustomer,
3146
- canDraftSupportReply: canDraftSupportReply,
3147
- canSendCustomerReply: false,
3148
- requiresHumanReview: requiresHumanReview,
3149
- canRunWithoutCodexMonitor: ready || cheapRepair,
3150
- codexFallbackRequired: !ready && !cheapRepair,
3151
- costRisk: ready
3152
- ? 'free_or_deterministic'
3153
- : status === 'needs_permission'
3154
- ? 'manual_blocked'
3155
- : (status === 'needs_query_repair' || status === 'incorrect' ? 'small_model_or_qa' : 'free_or_deterministic'),
3156
- queryResultClass: decision.queryStatus,
3157
- confidenceLevel: decision.confidenceLevel,
3158
- decisionBasis: {
3159
- answerQualityStatus: decision.status,
3160
- queryStatus: decision.queryStatus,
3161
- queryEvidencePresent: decision.queryEvidencePresent,
3162
- noDataConfirmed: decision.noDataConfirmed,
3163
- legalQueryShape: decision.legalQueryShape,
3164
- dateWindowRequired: decision.dateWindowRequired,
3165
- dateWindowPresent: decision.dateWindowPresent,
3166
- citationCount: decision.citationRefs.length + decision.evidenceRefs.length,
3167
- nextActionCount: decision.nextActions.length
3168
- },
3169
- requiredEvidence: requiredEvidence,
3170
- successEvidence: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((ready ? ['assistant answer quality gate passed'] : [])), false), __read((decision.queryEvidenceRefs.length ? decision.queryEvidenceRefs : [])), false), __read((decision.citationRefs.length ? decision.citationRefs : [])), false), __read((decision.evidenceRefs.length ? decision.evidenceRefs : [])), false))).slice(0, 20),
3171
- blockers: blockers,
3172
- nextActions: decision.nextActions,
3173
- nextCommands: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
3174
- primaryCommand
3175
- ], __read((status === 'needs_query_repair' ? ['fix_query_error', 'rerun_assistant_query'] : [])), false), __read((status === 'needs_no_data_verification' ? ['run_tiny_shape_probe', 'record_no_data_confirmed'] : [])), false), __read((status === 'needs_date_window_repair' ? ['resolve_current_date', 'record_concrete_date_window', 'rerun_assistant_query'] : [])), false), __read((status === 'needs_query_shape_repair' ? ['rewrite_illegal_projection', 'rerun_query_shape_validator'] : [])), false), __read((status === 'needs_permission' ? ['request_permission_or_choose_allowed_route'] : [])), false), [
3176
- 'record_assistant_actionability_result'
3177
- ], false))).slice(0, 20),
3178
- forbiddenActions: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
3179
- 'Do not answer from keyword or route guesses without verified query evidence.',
3180
- 'Do not claim no data when queryStatus is query_error or permission_error.'
3181
- ], __read((decision.queryStatus === 'no_data' && !decision.noDataConfirmed ? ['Do not present no-data answer until noDataConfirmed=true.'] : [])), false), __read((decision.legalQueryShape ? [] : ['Do not answer from illegal Mongo projection/query shape.'])), false), __read((decision.dateWindowRequired && !decision.dateWindowPresent ? ['Do not answer dated questions without concrete start/end date evidence.'] : [])), false), __read((decision.confidenceLevel === 'low' || decision.confidenceLevel === 'unknown' ? ['Do not draft support/customer reply from low or unknown confidence.'] : [])), false))).slice(0, 20),
3182
- evidenceRefs: Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(decision.queryEvidenceRefs), false), __read(decision.citationRefs), false), __read(decision.evidenceRefs), false))).slice(0, 40),
3183
- recordedAt: isoNow(now || decision.recordedAt)
3184
- };
3185
- }
3186
- function assistantAnswerActionabilityGate(contract, now) {
3187
- var status = contract.status === 'ready_to_answer'
3188
- ? 'pass'
3189
- : contract.status === 'incorrect' || contract.status === 'needs_query_shape_repair' || contract.status === 'needs_date_window_repair'
3190
- ? 'fail'
3191
- : 'blocked';
3192
- return {
3193
- key: 'assistant_answer_actionability',
3194
- label: 'Assistant answer actionability',
3195
- status: status,
3196
- reason: status === 'pass'
3197
- ? 'Assistant answer can proceed from verified structured evidence.'
3198
- : (contract.blockers.join(' ') || 'Assistant answer is blocked until actionability evidence is complete.'),
3199
- evidenceRefs: contract.evidenceRefs,
3200
- recordedAt: isoNow(now || contract.recordedAt),
3201
- metadata: {
3202
- contractId: contract.contractId,
3203
- status: contract.status,
3204
- primaryCommand: contract.primaryCommand,
3205
- label: contract.label,
3206
- canAnswerCustomer: contract.canAnswerCustomer,
3207
- canDraftSupportReply: contract.canDraftSupportReply,
3208
- canSendCustomerReply: contract.canSendCustomerReply,
3209
- requiresHumanReview: contract.requiresHumanReview,
3210
- canRunWithoutCodexMonitor: contract.canRunWithoutCodexMonitor,
3211
- codexFallbackRequired: contract.codexFallbackRequired,
3212
- costRisk: contract.costRisk,
3213
- queryResultClass: contract.queryResultClass,
3214
- confidenceLevel: contract.confidenceLevel,
3215
- decisionBasis: contract.decisionBasis,
3216
- requiredEvidence: contract.requiredEvidence,
3217
- successEvidence: contract.successEvidence,
3218
- blockers: contract.blockers,
3219
- nextActions: contract.nextActions,
3220
- nextCommands: contract.nextCommands,
3221
- forbiddenActions: contract.forbiddenActions
3222
- }
3223
- };
3224
- }
3225
- function applyAssistantAnswerQualityGate(qa, decision, now) {
3226
- var gate = assistantAnswerQualityGate(decision, now);
3227
- if (decision.ready) {
3228
- return __assign(__assign({}, qa), { gateResults: __spreadArray(__spreadArray([], __read(qa.gateResults), false), [gate], false) });
3229
- }
3230
- return __assign(__assign({}, qa), { outcome: /incorrect|date_incorrect|missing_date_window|illegal_query_shape/.test(decision.status)
3231
- ? 'business_assertion_failed'
3232
- : 'incomplete', gateResults: __spreadArray(__spreadArray([], __read(qa.gateResults.filter(function (existing) { return !(existing.key === 'qa_business_assertion' && existing.status === 'pass'); })), false), [
3233
- gate
3234
- ], false) });
3235
- }
3236
- function buildSupportAIRunFromEvidence(input) {
3237
- var e_32, _a, e_33, _b;
3238
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72;
3239
- var ticket = input.ticket || {};
3240
- var job = input.job || {};
3241
- var evidence = buildSupportQaEvidence(input);
3242
- var events = [];
3243
- var gates = [];
3244
- var sourceIds = {};
3245
- addSourceId(sourceIds, 'ticketId', ticket._id || ticket.id || job.ticketId || job.supportTicketId);
3246
- addSourceId(sourceIds, 'ticketNumber', ticket.ticketNumber || ticket.number || job.ticketNumber);
3247
- addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
3248
- addSourceId(sourceIds, 'buildPlanId', job.buildPlanId || ticket.buildPlanId);
3249
- try {
3250
- for (var _73 = __values(asArray(input.taskEvents)), _74 = _73.next(); !_74.done; _74 = _73.next()) {
3251
- var event_1 = _74.value;
3252
- pushEvent(events, {
3253
- type: event_1.type === 'human_intervention' ? 'human_intervention' : 'log',
3254
- category: cleanText(event_1.category || event_1.phase || event_1.type, 160),
3255
- message: cleanText(event_1.message || event_1.summary || event_1.text || event_1.title, 1800),
3256
- recordedAt: eventDate(event_1),
3257
- metadata: {
3258
- status: event_1.status,
3259
- phase: event_1.phase,
3260
- taskId: event_1.taskId || event_1._id || event_1.id
3261
- }
3262
- });
3263
- }
3264
- }
3265
- catch (e_32_1) { e_32 = { error: e_32_1 }; }
3266
- finally {
3267
- try {
3268
- if (_74 && !_74.done && (_a = _73.return)) _a.call(_73);
3269
- }
3270
- finally { if (e_32) throw e_32.error; }
3271
- }
3272
- try {
3273
- for (var _75 = __values(asArray(input.aiJobs)), _76 = _75.next(); !_76.done; _76 = _75.next()) {
3274
- var aiJob = _76.value;
3275
- pushEvent(events, {
3276
- type: aiJob.model ? 'model_call' : 'log',
3277
- category: cleanText(aiJob.category || aiJob.phase || aiJob.runner, 160),
3278
- message: cleanText(aiJob.summary || aiJob.promptSummary || aiJob.status || aiJob.phase, 1800),
3279
- recordedAt: eventDate(aiJob),
3280
- metadata: {
3281
- id: aiJob._id || aiJob.id,
3282
- model: aiJob.model,
3283
- status: aiJob.status,
3284
- phase: aiJob.phase
3285
- }
3286
- });
3287
- }
3288
- }
3289
- catch (e_33_1) { e_33 = { error: e_33_1 }; }
3290
- finally {
3291
- try {
3292
- if (_76 && !_76.done && (_b = _75.return)) _b.call(_75);
3293
- }
3294
- finally { if (e_33) throw e_33.error; }
3295
- }
3296
- collectCommitEvents(asArray(input.commits), events);
3297
- collectHotfixEvidenceEvents([job, ticket, evidence, input.qaEvidence], events, gates, input.now);
3298
- var noBlindLoopGate = supportManagerNoBlindLoopGate(job, evidence, input.now);
3299
- if (noBlindLoopGate) {
3300
- gates.push(noBlindLoopGate);
3301
- pushEvent(events, {
3302
- type: 'log',
3303
- category: 'manager_no_blind_loop_policy',
3304
- message: noBlindLoopGate.reason,
3305
- artifactPaths: noBlindLoopGate.evidenceRefs,
3306
- recordedAt: noBlindLoopGate.recordedAt,
3307
- metadata: noBlindLoopGate.metadata
3308
- });
3309
- }
3310
- var businessProofReadiness = plainObject(evidence.businessProofReadiness || evidence.business_proof_readiness);
3311
- var businessProofReadinessGate = supportBusinessProofReadinessGate(businessProofReadiness, input.now);
3312
- if (businessProofReadinessGate) {
3313
- gates.push(businessProofReadinessGate);
3314
- pushEvent(events, {
3315
- type: 'qa_business_assertion',
3316
- category: 'support_business_proof_readiness',
3317
- message: businessProofReadinessGate.reason,
3318
- artifactPaths: businessProofReadinessGate.evidenceRefs,
3319
- recordedAt: businessProofReadinessGate.recordedAt,
3320
- metadata: businessProofReadinessGate.metadata
3321
- });
3322
- }
3323
- var customerReplyPolicy = plainObject(evidence.customerReplyPolicy || evidence.customer_reply_policy);
3324
- var customerReplyPolicyGate = supportCustomerReplyPolicyGate(customerReplyPolicy, input.now);
3325
- if (customerReplyPolicyGate) {
3326
- gates.push(customerReplyPolicyGate);
3327
- pushEvent(events, {
3328
- type: 'human_intervention',
3329
- category: 'support_customer_reply_policy',
3330
- message: customerReplyPolicyGate.reason,
3331
- artifactPaths: customerReplyPolicyGate.evidenceRefs,
3332
- recordedAt: customerReplyPolicyGate.recordedAt,
3333
- metadata: customerReplyPolicyGate.metadata
3334
- });
3335
- }
3336
- var customerReplyReadiness = plainObject(evidence.customerReplyReadiness
3337
- || evidence.customer_reply_readiness
3338
- || customerReplyPolicy.readinessContract
3339
- || customerReplyPolicy.readiness_contract);
3340
- var customerReplyReadinessGate = supportCustomerReplyReadinessGate(customerReplyReadiness, input.now);
3341
- if (customerReplyReadinessGate) {
3342
- gates.push(customerReplyReadinessGate);
3343
- pushEvent(events, {
3344
- type: 'human_intervention',
3345
- category: 'support_customer_reply_readiness',
3346
- message: customerReplyReadinessGate.reason,
3347
- artifactPaths: customerReplyReadinessGate.evidenceRefs,
3348
- recordedAt: customerReplyReadinessGate.recordedAt,
3349
- metadata: customerReplyReadinessGate.metadata
3350
- });
3351
- }
3352
- var nextActionContract = supportNextActionContractObject(ticket, job, evidence);
3353
- var nextActionContractRequired = supportNextActionContractRequired(ticket, job, evidence);
3354
- var nextActionContractGate = supportNextActionContractGate(nextActionContract, input.now, nextActionContractRequired);
3355
- if (nextActionContractGate) {
3356
- gates.push(nextActionContractGate);
3357
- pushEvent(events, {
3358
- type: 'log',
3359
- category: 'support_next_action_contract',
3360
- message: nextActionContractGate.reason,
3361
- artifactPaths: nextActionContractGate.evidenceRefs,
3362
- recordedAt: nextActionContractGate.recordedAt,
3363
- metadata: nextActionContractGate.metadata
3364
- });
3365
- }
3366
- var managerRecoveryExecutionProof = plainObject(evidence.managerRecoveryExecutionProof || evidence.manager_recovery_execution_proof);
3367
- var recoveryExecutionProofGate = managerRecoveryExecutionProofGate(managerRecoveryExecutionProof, input.now);
3368
- if (recoveryExecutionProofGate) {
3369
- gates.push(recoveryExecutionProofGate);
3370
- pushEvent(events, {
3371
- type: 'log',
3372
- category: 'manager_recovery_execution_proof',
3373
- message: recoveryExecutionProofGate.reason,
3374
- artifactPaths: recoveryExecutionProofGate.evidenceRefs,
3375
- recordedAt: recoveryExecutionProofGate.recordedAt,
3376
- metadata: recoveryExecutionProofGate.metadata
3377
- });
3378
- }
3379
- var ticketAutomation = plainObject(ticket.automation);
3380
- var ticketManagerState = plainObject(ticketAutomation.manager || ticket.manager);
3381
- var rootCauseEntryContract = evidenceObject(job.supportRootCauseEntryContract, job.support_root_cause_entry_contract, job.rootCauseEntryContract, ticket.supportRootCauseEntryContract, ticket.rootCauseEntryContract, ticketManagerState.root_cause_entry_contract, ticketManagerState.rootCauseEntryContract, evidence.rootCauseEntryContract, evidence.root_cause_entry_contract);
3382
- var rootCauseEntryContractGate = supportRootCauseEntryContractGate(rootCauseEntryContract, input.now);
3383
- if (rootCauseEntryContractGate) {
3384
- gates.push(rootCauseEntryContractGate);
3385
- pushEvent(events, {
3386
- type: 'log',
3387
- category: 'support_root_cause_entry_contract',
3388
- message: rootCauseEntryContractGate.reason,
3389
- artifactPaths: rootCauseEntryContractGate.evidenceRefs,
3390
- recordedAt: rootCauseEntryContractGate.recordedAt,
3391
- metadata: rootCauseEntryContractGate.metadata
3392
- });
3393
- }
3394
- var cost = collectUsageEvents(asArray(input.usageLedger), events);
3395
- var preflightGateSource = supportPreflightGateObject(ticket, job, evidence);
3396
- var preflightGate = supportPreflightGateResult(preflightGateSource, input.now);
3397
- if (preflightGate) {
3398
- gates.push(preflightGate);
3399
- pushEvent(events, {
3400
- type: ((_c = preflightGate.metadata) === null || _c === void 0 ? void 0 : _c.failureClass) === 'compile' || preflightGateSource.status === 'compile_failed' ? 'qa_compile' : 'qa_infra',
3401
- category: 'support_preflight_gate',
3402
- message: preflightGate.reason,
3403
- artifactPaths: preflightGate.evidenceRefs,
3404
- recordedAt: preflightGate.recordedAt,
3405
- metadata: preflightGate.metadata
3406
- });
3407
- }
3408
- var diagnosisGate = evidenceObject(job.supportV5DiagnosisGate, job.support_v5_diagnosis_gate, job.diagnosisGate, ticket.supportV5DiagnosisGate, ticket.diagnosisGate, evidence.diagnosisGate, evidence.supportV5DiagnosisGate);
3409
- var diagnosisEvidencePackSource = supportDiagnosisEvidencePackObject(ticket, job, evidence);
3410
- var similarFixHints = supportSimilarFixHintsObject(ticket, job, evidence);
3411
- var diagnosisEvidencePack = Object.keys(diagnosisEvidencePackSource).length
3412
- ? diagnosisEvidencePackSource
3413
- : (Object.keys(diagnosisGate).length || Object.keys(similarFixHints).length)
3414
- ? (0, support_runner_v5_1.buildResolveIOSupportDiagnosisEvidencePack)({
3415
- diagnosisGate: diagnosisGate,
3416
- similarCaseHints: similarFixHints,
3417
- issueClass: diagnosisGate.issue_class || diagnosisGate.issueClass,
3418
- ownerFiles: diagnosisGate.owner_files || diagnosisGate.ownerFiles,
3419
- text: [
3420
- ticket.title,
3421
- ticket.subject,
3422
- ticket.summary,
3423
- job.title,
3424
- job.summary
3425
- ].filter(Boolean).join(' '),
3426
- now: input.now
3427
- })
3428
- : {};
3429
- var diagnosisEvidencePackGate = supportDiagnosisEvidencePackGate(diagnosisEvidencePack, input.now);
3430
- if (diagnosisEvidencePackGate) {
3431
- gates.push(diagnosisEvidencePackGate);
3432
- pushEvent(events, {
3433
- type: 'log',
3434
- category: 'support_diagnosis_evidence_pack',
3435
- message: diagnosisEvidencePackGate.reason,
3436
- artifactPaths: diagnosisEvidencePackGate.evidenceRefs,
3437
- recordedAt: diagnosisEvidencePackGate.recordedAt,
3438
- metadata: diagnosisEvidencePackGate.metadata
3439
- });
3440
- }
3441
- var issueClassProbePlanSource = supportIssueClassProbePlanObject(ticket, job, evidence);
3442
- var issueClassProbePlan = Object.keys(issueClassProbePlanSource).length
3443
- ? issueClassProbePlanSource
3444
- : Object.keys(diagnosisGate).length
3445
- ? (0, support_runner_v5_1.buildResolveIOSupportIssueClassProbePlan)(diagnosisGate, input.now)
3446
- : {};
3447
- var issueClassProbePlanRequired = nextActionContractRequired || Object.keys(diagnosisGate).length > 0;
3448
- var issueClassProbePlanGate = supportIssueClassProbePlanGate(issueClassProbePlan, diagnosisGate, input.now, issueClassProbePlanRequired);
3449
- if (issueClassProbePlanGate) {
3450
- gates.push(issueClassProbePlanGate);
3451
- pushEvent(events, {
3452
- type: 'log',
3453
- category: 'support_issue_class_probe_plan',
3454
- message: issueClassProbePlanGate.reason,
3455
- artifactPaths: issueClassProbePlanGate.evidenceRefs,
3456
- recordedAt: issueClassProbePlanGate.recordedAt,
3457
- metadata: issueClassProbePlanGate.metadata
3458
- });
3459
- }
3460
- var productRepairEvidence = supportProductRepairEvidence(input, evidence);
3461
- var diagnosisBeforeRepairGate = supportDiagnosisBeforeRepairGate(diagnosisGate, productRepairEvidence, input.now);
3462
- if (diagnosisBeforeRepairGate) {
3463
- gates.push(diagnosisBeforeRepairGate);
3464
- pushEvent(events, {
3465
- type: 'log',
3466
- category: 'support_diagnosis_before_repair',
3467
- message: diagnosisBeforeRepairGate.reason,
3468
- artifactPaths: diagnosisBeforeRepairGate.evidenceRefs,
3469
- recordedAt: diagnosisBeforeRepairGate.recordedAt,
3470
- metadata: diagnosisBeforeRepairGate.metadata
3471
- });
3472
- }
3473
- var ownerFileScopeGate = supportOwnerFileScopeGate(diagnosisGate, productRepairEvidence, input.now);
3474
- if (ownerFileScopeGate) {
3475
- gates.push(ownerFileScopeGate);
3476
- pushEvent(events, {
3477
- type: 'log',
3478
- category: 'support_owner_file_scope',
3479
- message: ownerFileScopeGate.reason,
3480
- artifactPaths: ownerFileScopeGate.evidenceRefs,
3481
- recordedAt: ownerFileScopeGate.recordedAt,
3482
- metadata: ownerFileScopeGate.metadata
3483
- });
3484
- }
3485
- var qa = applySupportDiagnosisProofGate(buildQaFromEvidence(evidence, input.now), diagnosisGate, input.now);
3486
- var diagnosisOwnerFiles = asArray(diagnosisGate.owner_files || diagnosisGate.ownerFiles);
3487
- var diagnosisIssueClass = cleanText(diagnosisGate.issue_class || diagnosisGate.issueClass, 120);
3488
- if (Object.keys(diagnosisGate).length) {
3489
- pushEvent(events, {
3490
- type: 'log',
3491
- category: 'diagnosis_gate',
3492
- message: cleanText(((_d = diagnosisGate.accepted_hypothesis) === null || _d === void 0 ? void 0 : _d.statement) || ((_e = diagnosisGate.acceptedHypothesis) === null || _e === void 0 ? void 0 : _e.statement) || diagnosisGate.summary || 'Support diagnosis gate recorded.', 1800),
3493
- metadata: {
3494
- status: diagnosisGate.status,
3495
- issueClass: diagnosisIssueClass,
3496
- ownerFiles: diagnosisOwnerFiles
3497
- }
3498
- });
3499
- }
3500
- return (0, ai_run_evidence_1.buildAIRun)({
3501
- source: 'support_ticket',
3502
- sourceIds: sourceIds,
3503
- title: firstText(ticket, ['title', 'subject', 'summary']) || firstText(job, ['title', 'summary']),
3504
- status: firstText(job, ['status', 'state']) || firstText(ticket, ['status', 'state']),
3505
- phase: firstText(job, ['phase', 'runnerPhase']),
3506
- startedAt: dateValue(job, ['startedAt', 'createdAt']) || dateValue(ticket, ['createdAt']),
3507
- completedAt: dateValue(job, ['completedAt', 'finishedAt', 'updatedAt']),
3508
- events: events,
3509
- gates: gates,
3510
- qa: qa,
3511
- cost: cost,
3512
- scorecardPassed: evidence.scorecardPassed === true || evidence.scorecardStatus === 'pass',
3513
- deployStatus: evidence.deployStatus,
3514
- publishStatus: evidence.publishStatus,
3515
- sampleDataStatus: evidence.sampleDataStatus,
3516
- manualHandoff: evidence.manualHandoff === true || job.manualHandoff === true,
3517
- stopped: evidence.stopped === true || job.stopped === true,
3518
- rejected: evidence.rejected === true,
3519
- explicitAccepted: evidence.explicitAccepted === true || ticket.accepted === true,
3520
- terminal: /complete|closed|resolved|done|failed|rejected/i.test("".concat(job.status || '', " ").concat(ticket.status || '')),
3521
- now: input.now,
3522
- metadata: {
3523
- versionCount: asArray(input.versions).length,
3524
- buildPlanCount: asArray(input.buildPlans).length,
3525
- hotfixDurability: hotfixDurabilityMetadata(gates),
3526
- managerNoBlindLoopPolicy: managerNoBlindLoopMetadata(noBlindLoopGate),
3527
- diagnosisBeforeRepair: diagnosisBeforeRepairGate ? {
3528
- status: diagnosisBeforeRepairGate.status,
3529
- diagnosisValid: ((_f = diagnosisBeforeRepairGate.metadata) === null || _f === void 0 ? void 0 : _f.diagnosisValid) === true,
3530
- diagnosisStatus: cleanText((_g = diagnosisBeforeRepairGate.metadata) === null || _g === void 0 ? void 0 : _g.diagnosisStatus, 120),
3531
- activityCount: Number(((_h = diagnosisBeforeRepairGate.metadata) === null || _h === void 0 ? void 0 : _h.activityCount) || 0),
3532
- changedFiles: cleanStringList((_j = diagnosisBeforeRepairGate.metadata) === null || _j === void 0 ? void 0 : _j.changedFiles, 40, 500),
3533
- allowedDispatchAction: cleanText((_k = diagnosisBeforeRepairGate.metadata) === null || _k === void 0 ? void 0 : _k.allowedDispatchAction, 160),
3534
- productRepairAllowed: ((_l = diagnosisBeforeRepairGate.metadata) === null || _l === void 0 ? void 0 : _l.productRepairAllowed) === true,
3535
- blockers: cleanStringList((_m = diagnosisBeforeRepairGate.metadata) === null || _m === void 0 ? void 0 : _m.blockers, 20, 500)
3536
- } : undefined,
3537
- ownerFileScope: ownerFileScopeGate ? {
3538
- status: ownerFileScopeGate.status,
3539
- productRepairAllowed: ((_o = ownerFileScopeGate.metadata) === null || _o === void 0 ? void 0 : _o.productRepairAllowed) === true,
3540
- allowedDispatchAction: cleanText((_p = ownerFileScopeGate.metadata) === null || _p === void 0 ? void 0 : _p.allowedDispatchAction, 160),
3541
- ownerFiles: cleanStringList((_q = ownerFileScopeGate.metadata) === null || _q === void 0 ? void 0 : _q.ownerFiles, 40, 500),
3542
- changedFiles: cleanStringList((_r = ownerFileScopeGate.metadata) === null || _r === void 0 ? void 0 : _r.changedFiles, 60, 500),
3543
- outsideOwnerFiles: cleanStringList((_s = ownerFileScopeGate.metadata) === null || _s === void 0 ? void 0 : _s.outsideOwnerFiles, 40, 500),
3544
- allowedTestFilesOutsideOwnerScope: ((_t = ownerFileScopeGate.metadata) === null || _t === void 0 ? void 0 : _t.allowedTestFilesOutsideOwnerScope) === true,
3545
- requiredEvidence: cleanStringList((_u = ownerFileScopeGate.metadata) === null || _u === void 0 ? void 0 : _u.requiredEvidence, 20, 500)
3546
- } : undefined,
3547
- rootCauseEntryContract: Object.keys(rootCauseEntryContract).length ? {
3548
- contractId: cleanText(rootCauseEntryContract.contract_id || rootCauseEntryContract.contractId, 160),
3549
- version: cleanText(rootCauseEntryContract.version, 120),
3550
- status: cleanText(rootCauseEntryContract.status, 120),
3551
- issueClassProbeCount: asArray(rootCauseEntryContract.issue_class_probes || rootCauseEntryContract.issueClassProbes).length,
3552
- ownerFileMax: Number(((_v = rootCauseEntryContract.owner_file_policy) === null || _v === void 0 ? void 0 : _v.max_files) || ((_w = rootCauseEntryContract.ownerFilePolicy) === null || _w === void 0 ? void 0 : _w.maxFiles) || 0) || 0,
3553
- requiresBusinessAssertion: ((_x = rootCauseEntryContract.business_proof_policy) === null || _x === void 0 ? void 0 : _x.requires_aiqa_business_assertion) === true
3554
- || ((_y = rootCauseEntryContract.businessProofPolicy) === null || _y === void 0 ? void 0 : _y.requiresAiqaBusinessAssertion) === true
3555
- } : undefined,
3556
- diagnosis: Object.keys(diagnosisGate).length ? {
3557
- status: cleanText(diagnosisGate.status, 80),
3558
- issueClass: diagnosisIssueClass,
3559
- ownerFiles: diagnosisOwnerFiles,
3560
- acceptedHypothesis: cleanText(((_z = diagnosisGate.accepted_hypothesis) === null || _z === void 0 ? void 0 : _z.statement) || ((_0 = diagnosisGate.acceptedHypothesis) === null || _0 === void 0 ? void 0 : _0.statement), 1000),
3561
- proofPlan: diagnosisGate.proof_plan || diagnosisGate.proofPlan
3562
- } : undefined,
3563
- diagnosisEvidencePack: diagnosisEvidencePackGate ? {
3564
- status: cleanText((_1 = diagnosisEvidencePackGate.metadata) === null || _1 === void 0 ? void 0 : _1.status, 120),
3565
- gateStatus: diagnosisEvidencePackGate.status,
3566
- packId: cleanText((_2 = diagnosisEvidencePackGate.metadata) === null || _2 === void 0 ? void 0 : _2.packId, 180),
3567
- readOnly: ((_3 = diagnosisEvidencePackGate.metadata) === null || _3 === void 0 ? void 0 : _3.readOnly) !== false,
3568
- sourceEditsAllowed: ((_4 = diagnosisEvidencePackGate.metadata) === null || _4 === void 0 ? void 0 : _4.sourceEditsAllowed) === true,
3569
- requiredOutputKey: cleanText((_5 = diagnosisEvidencePackGate.metadata) === null || _5 === void 0 ? void 0 : _5.requiredOutputKey, 120),
3570
- diagnosisValid: ((_6 = diagnosisEvidencePackGate.metadata) === null || _6 === void 0 ? void 0 : _6.diagnosisValid) === true,
3571
- issueClassHint: cleanText((_7 = diagnosisEvidencePackGate.metadata) === null || _7 === void 0 ? void 0 : _7.issueClassHint, 120),
3572
- ownerFileHints: cleanStringList((_8 = diagnosisEvidencePackGate.metadata) === null || _8 === void 0 ? void 0 : _8.ownerFileHints, 20, 500),
3573
- similarHintCount: Number(((_9 = diagnosisEvidencePackGate.metadata) === null || _9 === void 0 ? void 0 : _9.similarHintCount) || 0),
3574
- similarHintsAdvisoryOnly: ((_10 = diagnosisEvidencePackGate.metadata) === null || _10 === void 0 ? void 0 : _10.similarHintsAdvisoryOnly) === true,
3575
- issueClassProbeCount: Number(((_11 = diagnosisEvidencePackGate.metadata) === null || _11 === void 0 ? void 0 : _11.issueClassProbeCount) || 0),
3576
- validationBlockers: cleanStringList((_12 = diagnosisEvidencePackGate.metadata) === null || _12 === void 0 ? void 0 : _12.validationBlockers, 20, 500)
3577
- } : undefined,
3578
- issueClassProbePlan: issueClassProbePlanGate ? {
3579
- status: cleanText((_13 = issueClassProbePlanGate.metadata) === null || _13 === void 0 ? void 0 : _13.status, 120),
3580
- gateStatus: issueClassProbePlanGate.status,
3581
- planId: cleanText((_14 = issueClassProbePlanGate.metadata) === null || _14 === void 0 ? void 0 : _14.planId, 180),
3582
- issueClass: cleanText((_15 = issueClassProbePlanGate.metadata) === null || _15 === void 0 ? void 0 : _15.issueClass, 120),
3583
- diagnosisValid: ((_16 = issueClassProbePlanGate.metadata) === null || _16 === void 0 ? void 0 : _16.diagnosisValid) === true,
3584
- issueClassProbePlanReady: ((_17 = issueClassProbePlanGate.metadata) === null || _17 === void 0 ? void 0 : _17.issueClassProbePlanReady) === true,
3585
- activeRoute: cleanText((_18 = issueClassProbePlanGate.metadata) === null || _18 === void 0 ? void 0 : _18.activeRoute, 500),
3586
- action: cleanText((_19 = issueClassProbePlanGate.metadata) === null || _19 === void 0 ? void 0 : _19.action, 1000),
3587
- expectedBusinessProof: cleanText((_20 = issueClassProbePlanGate.metadata) === null || _20 === void 0 ? void 0 : _20.expectedBusinessProof, 1200),
3588
- acceptanceGate: cleanText((_21 = issueClassProbePlanGate.metadata) === null || _21 === void 0 ? void 0 : _21.acceptanceGate, 120),
3589
- requiredArtifacts: cleanStringList((_22 = issueClassProbePlanGate.metadata) === null || _22 === void 0 ? void 0 : _22.requiredArtifacts, 20, 500),
3590
- falsePassBlockers: cleanStringList((_23 = issueClassProbePlanGate.metadata) === null || _23 === void 0 ? void 0 : _23.falsePassBlockers, 20, 500),
3591
- blockers: cleanStringList((_24 = issueClassProbePlanGate.metadata) === null || _24 === void 0 ? void 0 : _24.blockers, 20, 500)
3592
- } : undefined,
3593
- businessProofReadiness: Object.keys(businessProofReadiness).length ? {
3594
- ready: businessProofReadiness.ready === true,
3595
- status: cleanText(businessProofReadiness.status, 120),
3596
- reason: cleanText(businessProofReadiness.reason, 1000),
3597
- blockers: cleanStringList(businessProofReadiness.blockers, 20, 500)
3598
- } : undefined,
3599
- nextActionContract: nextActionContractGate ? {
3600
- status: nextActionContractGate.status,
3601
- action: cleanText((_25 = nextActionContractGate.metadata) === null || _25 === void 0 ? void 0 : _25.action, 160),
3602
- primaryCommand: cleanText((_26 = nextActionContractGate.metadata) === null || _26 === void 0 ? void 0 : _26.primaryCommand, 240),
3603
- safeToAutoRun: ((_27 = nextActionContractGate.metadata) === null || _27 === void 0 ? void 0 : _27.safeToAutoRun) === true,
3604
- canRunWithoutCodexMonitor: ((_28 = nextActionContractGate.metadata) === null || _28 === void 0 ? void 0 : _28.canRunWithoutCodexMonitor) === true,
3605
- codexFallbackRequired: ((_29 = nextActionContractGate.metadata) === null || _29 === void 0 ? void 0 : _29.codexFallbackRequired) === true,
3606
- requiresHumanApproval: ((_30 = nextActionContractGate.metadata) === null || _30 === void 0 ? void 0 : _30.requiresHumanApproval) === true,
3607
- rootCauseFirstSatisfied: ((_31 = nextActionContractGate.metadata) === null || _31 === void 0 ? void 0 : _31.rootCauseFirstSatisfied) === true,
3608
- hotfixCommitRequired: ((_32 = nextActionContractGate.metadata) === null || _32 === void 0 ? void 0 : _32.hotfixCommitRequired) === true,
3609
- liveHotfixBlockedUntilCommit: ((_33 = nextActionContractGate.metadata) === null || _33 === void 0 ? void 0 : _33.liveHotfixBlockedUntilCommit) === true,
3610
- failureClass: cleanText((_34 = nextActionContractGate.metadata) === null || _34 === void 0 ? void 0 : _34.failureClass, 120),
3611
- evidenceFreshnessStatus: cleanText((_35 = nextActionContractGate.metadata) === null || _35 === void 0 ? void 0 : _35.evidenceFreshnessStatus, 120),
3612
- sameFailureCount: Number(((_36 = nextActionContractGate.metadata) === null || _36 === void 0 ? void 0 : _36.sameFailureCount) || 0),
3613
- blockers: cleanStringList((_37 = nextActionContractGate.metadata) === null || _37 === void 0 ? void 0 : _37.blockers, 20, 500)
3614
- } : undefined,
3615
- managerRecoveryExecutionProof: recoveryExecutionProofGate ? {
3616
- status: cleanText((_38 = recoveryExecutionProofGate.metadata) === null || _38 === void 0 ? void 0 : _38.status, 120),
3617
- gateStatus: recoveryExecutionProofGate.status,
3618
- canContinueRun: ((_39 = recoveryExecutionProofGate.metadata) === null || _39 === void 0 ? void 0 : _39.canContinueRun) === true,
3619
- canRunProductRepair: ((_40 = recoveryExecutionProofGate.metadata) === null || _40 === void 0 ? void 0 : _40.canRunProductRepair) === true,
3620
- canRunExpensiveModel: ((_41 = recoveryExecutionProofGate.metadata) === null || _41 === void 0 ? void 0 : _41.canRunExpensiveModel) === true,
3621
- canResetLoopBudget: ((_42 = recoveryExecutionProofGate.metadata) === null || _42 === void 0 ? void 0 : _42.canResetLoopBudget) === true,
3622
- newEvidence: ((_43 = recoveryExecutionProofGate.metadata) === null || _43 === void 0 ? void 0 : _43.newEvidence) === true,
3623
- materialEvidence: ((_44 = recoveryExecutionProofGate.metadata) === null || _44 === void 0 ? void 0 : _44.materialEvidence) === true,
3624
- evidenceStrength: cleanText((_45 = recoveryExecutionProofGate.metadata) === null || _45 === void 0 ? void 0 : _45.evidenceStrength, 120),
3625
- nextAllowedAction: cleanText((_46 = recoveryExecutionProofGate.metadata) === null || _46 === void 0 ? void 0 : _46.nextAllowedAction, 180),
3626
- missingEvidence: cleanStringList((_47 = recoveryExecutionProofGate.metadata) === null || _47 === void 0 ? void 0 : _47.missingEvidence, 20, 500),
3627
- blockers: cleanStringList((_48 = recoveryExecutionProofGate.metadata) === null || _48 === void 0 ? void 0 : _48.blockers, 20, 500)
3628
- } : undefined,
3629
- customerReplyPolicy: Object.keys(customerReplyPolicy).length ? {
3630
- action: cleanText(customerReplyPolicy.action, 120),
3631
- safety: cleanText(customerReplyPolicy.safety, 120),
3632
- canDraftCustomerReply: customerReplyPolicy.canDraftCustomerReply === true || customerReplyPolicy.can_draft_customer_reply === true,
3633
- canSendCustomerReply: customerReplyPolicy.canSendCustomerReply === true || customerReplyPolicy.can_send_customer_reply === true,
3634
- reason: cleanText(customerReplyPolicy.reason, 1000),
3635
- reviewType: cleanText(((_49 = customerReplyPolicy.humanReviewPacket) === null || _49 === void 0 ? void 0 : _49.reviewType)
3636
- || ((_50 = customerReplyPolicy.human_review_packet) === null || _50 === void 0 ? void 0 : _50.review_type)
3637
- || ((_51 = customerReplyPolicy.human_review_packet) === null || _51 === void 0 ? void 0 : _51.reviewType), 160),
3638
- primaryAction: cleanText(((_52 = customerReplyPolicy.humanReviewPacket) === null || _52 === void 0 ? void 0 : _52.primaryAction)
3639
- || ((_53 = customerReplyPolicy.human_review_packet) === null || _53 === void 0 ? void 0 : _53.primary_action)
3640
- || ((_54 = customerReplyPolicy.human_review_packet) === null || _54 === void 0 ? void 0 : _54.primaryAction), 160),
3641
- clarificationContract: customerReplyPolicy.clarificationContract || customerReplyPolicy.clarification_contract ? {
3642
- status: cleanText(((_55 = customerReplyPolicy.clarificationContract) === null || _55 === void 0 ? void 0 : _55.status) || ((_56 = customerReplyPolicy.clarification_contract) === null || _56 === void 0 ? void 0 : _56.status), 120),
3643
- missingField: cleanText(((_57 = customerReplyPolicy.clarificationContract) === null || _57 === void 0 ? void 0 : _57.missingField) || ((_58 = customerReplyPolicy.clarification_contract) === null || _58 === void 0 ? void 0 : _58.missing_field), 120),
3644
- oneQuestionOnly: ((_59 = customerReplyPolicy.clarificationContract) === null || _59 === void 0 ? void 0 : _59.oneQuestionOnly) === true || ((_60 = customerReplyPolicy.clarification_contract) === null || _60 === void 0 ? void 0 : _60.one_question_only) === true,
3645
- parksTicketUntilCustomerReply: ((_61 = customerReplyPolicy.clarificationContract) === null || _61 === void 0 ? void 0 : _61.parksTicketUntilCustomerReply) === true || ((_62 = customerReplyPolicy.clarification_contract) === null || _62 === void 0 ? void 0 : _62.parks_ticket_until_customer_reply) === true
3646
- } : undefined
3647
- } : undefined,
3648
- customerReplyReadiness: customerReplyReadinessGate ? {
3649
- status: cleanText((_63 = customerReplyReadinessGate.metadata) === null || _63 === void 0 ? void 0 : _63.status, 120),
3650
- gateStatus: customerReplyReadinessGate.status,
3651
- primaryCommand: cleanText((_64 = customerReplyReadinessGate.metadata) === null || _64 === void 0 ? void 0 : _64.primaryCommand, 180),
3652
- policyAction: cleanText((_65 = customerReplyReadinessGate.metadata) === null || _65 === void 0 ? void 0 : _65.policyAction, 120),
3653
- canDraftCustomerReply: ((_66 = customerReplyReadinessGate.metadata) === null || _66 === void 0 ? void 0 : _66.canDraftCustomerReply) === true,
3654
- canSendCustomerReply: ((_67 = customerReplyReadinessGate.metadata) === null || _67 === void 0 ? void 0 : _67.canSendCustomerReply) === true,
3655
- requiresHumanApproval: ((_68 = customerReplyReadinessGate.metadata) === null || _68 === void 0 ? void 0 : _68.requiresHumanApproval) === true,
3656
- proofBacked: ((_69 = customerReplyReadinessGate.metadata) === null || _69 === void 0 ? void 0 : _69.proofBacked) === true,
3657
- businessProofReady: ((_70 = customerReplyReadinessGate.metadata) === null || _70 === void 0 ? void 0 : _70.businessProofReady) === true,
3658
- releaseReady: ((_71 = customerReplyReadinessGate.metadata) === null || _71 === void 0 ? void 0 : _71.releaseReady) === true,
3659
- blockers: cleanStringList((_72 = customerReplyReadinessGate.metadata) === null || _72 === void 0 ? void 0 : _72.blockers, 20, 500)
3660
- } : undefined
3661
- }
3662
- });
3663
- }
3664
- function buildAICoderAIRunFromEvidence(input) {
3665
- var e_34, _a;
3666
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
3667
- var app = input.app || {};
3668
- var job = input.job || {};
3669
- var evidence = buildAICoderQaEvidence(input);
3670
- var events = [];
3671
- var gates = [];
3672
- var sourceIds = {};
3673
- addSourceId(sourceIds, 'appId', app._id || app.id || job.appId || job.aicoderAppId);
3674
- addSourceId(sourceIds, 'jobId', job._id || job.id || job.jobId);
3675
- addSourceId(sourceIds, 'domain', app.domain || app.customDomain || job.domain);
3676
- try {
3677
- for (var _29 = __values(asArray(input.logs)), _30 = _29.next(); !_30.done; _30 = _29.next()) {
3678
- var log = _30.value;
3679
- pushEvent(events, {
3680
- type: log.type === 'scorecard' ? 'scorecard' : 'log',
3681
- category: cleanText(log.category || log.phase || log.level, 160),
3682
- message: cleanText(log.message || log.summary || log.text || log.title, 1800),
3683
- artifactPaths: asArray(log.artifactPaths || log.artifacts),
3684
- recordedAt: eventDate(log),
3685
- metadata: {
3686
- status: log.status,
3687
- level: log.level,
3688
- score: log.score
3689
- }
3690
- });
3691
- }
3692
- }
3693
- catch (e_34_1) { e_34 = { error: e_34_1 }; }
3694
- finally {
3695
- try {
3696
- if (_30 && !_30.done && (_a = _29.return)) _a.call(_29);
3697
- }
3698
- finally { if (e_34) throw e_34.error; }
3699
- }
3700
- collectCommitEvents(asArray(input.commits), events);
3701
- collectHotfixEvidenceEvents([job, app, evidence, input.qaEvidence], events, gates, input.now);
3702
- var noBlindLoopGate = aicoderManagerNoBlindLoopGate(app, job, evidence, input.now);
3703
- if (noBlindLoopGate) {
3704
- gates.push(noBlindLoopGate);
3705
- pushEvent(events, {
3706
- type: 'log',
3707
- category: 'manager_no_blind_loop_policy',
3708
- message: noBlindLoopGate.reason,
3709
- artifactPaths: noBlindLoopGate.evidenceRefs,
3710
- recordedAt: noBlindLoopGate.recordedAt,
3711
- metadata: noBlindLoopGate.metadata
3712
- });
3713
- }
3714
- var cost = collectUsageEvents(asArray(input.usageLedger), events);
3715
- var journeyContractValidation = aicoderJourneyContractValidationFromEvidence(evidence);
3716
- var journeyContractGate = aicoderJourneyContractGate(journeyContractValidation, evidence, input.now);
3717
- gates.push(journeyContractGate);
3718
- pushEvent(events, {
3719
- type: 'log',
3720
- category: 'aicoder_journey_contract',
3721
- message: journeyContractGate.reason,
3722
- artifactPaths: journeyContractGate.evidenceRefs,
3723
- recordedAt: journeyContractGate.recordedAt,
3724
- metadata: journeyContractGate.metadata
3725
- });
3726
- var scorecardPassed = evidence.scorecardPassed === true
3727
- || evidence.scorecardStatus === 'pass'
3728
- || (Number((_c = (_b = evidence.score) !== null && _b !== void 0 ? _b : evidence.qualityScore) !== null && _c !== void 0 ? _c : 0) >= Number((_e = (_d = evidence.scoreThreshold) !== null && _d !== void 0 ? _d : job.scoreThreshold) !== null && _e !== void 0 ? _e : 90));
3729
- var explicitWorkflowReadiness = normalizeAICoderWorkflowProofReadiness(plainObject(evidence.workflowProofReadiness
3730
- || evidence.workflow_proof_readiness
3731
- || evidence.aicoderWorkflowProofReadiness
3732
- || evidence.aicoder_workflow_proof_readiness
3733
- || job.workflowProofReadiness
3734
- || job.workflow_proof_readiness
3735
- || job.aicoderWorkflowProofReadiness
3736
- || job.aicoder_workflow_proof_readiness), input.now);
3737
- var workflowReadiness = explicitWorkflowReadiness || (0, aicoder_runner_v6_1.evaluateResolveIOAICoderWorkflowProofReadiness)({
3738
- journeyContract: evidence.journeyContract,
3739
- journeyContractMarkdown: evidence.journeyContractMarkdown,
3740
- workflowQaRows: asArray(evidence.workflowQaRows || evidence.workflow_qa_rows),
3741
- businessAssertions: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence.businessAssertions)), false), __read(asArray(evidence.business_assertions)), false), __read(asArray(evidence.workflowAssertions)), false), __read(asArray(evidence.workflow_assertions)), false),
3742
- routeProbes: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence.routeProbes)), false), __read(asArray(evidence.route_probes)), false), __read(asArray(evidence.workflowProbes)), false), __read(asArray(evidence.workflow_probes)), false),
3743
- artifactPaths: __spreadArray(__spreadArray([], __read(asArray(evidence.artifactPaths)), false), __read(asArray(evidence.artifact_paths)), false),
3744
- scorecardPassed: scorecardPassed,
3745
- deployStatus: evidence.deployStatus,
3746
- publishStatus: evidence.publishStatus,
3747
- sampleDataStatus: evidence.sampleDataStatus,
3748
- previousWorkflowProofFingerprint: firstNonEmptyText([
3749
- evidence.previousWorkflowProofFingerprint,
3750
- evidence.previous_workflow_proof_fingerprint,
3751
- job.previousWorkflowProofFingerprint,
3752
- job.previous_workflow_proof_fingerprint,
3753
- app.previousWorkflowProofFingerprint,
3754
- app.previous_workflow_proof_fingerprint
3755
- ], 200),
3756
- previousArtifactFingerprint: firstNonEmptyText([
3757
- evidence.previousArtifactFingerprint,
3758
- evidence.previous_artifact_fingerprint,
3759
- job.previousArtifactFingerprint,
3760
- job.previous_artifact_fingerprint,
3761
- app.previousArtifactFingerprint,
3762
- app.previous_artifact_fingerprint
3763
- ], 200),
3764
- previousWorkflowProofFingerprints: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence.previousWorkflowProofFingerprints)), false), __read(asArray(evidence.previous_workflow_proof_fingerprints)), false), __read(asArray(job.previousWorkflowProofFingerprints)), false), __read(asArray(job.previous_workflow_proof_fingerprints)), false), __read(asArray(app.previousWorkflowProofFingerprints)), false), __read(asArray(app.previous_workflow_proof_fingerprints)), false),
3765
- previousArtifactFingerprints: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(asArray(evidence.previousArtifactFingerprints)), false), __read(asArray(evidence.previous_artifact_fingerprints)), false), __read(asArray(job.previousArtifactFingerprints)), false), __read(asArray(job.previous_artifact_fingerprints)), false), __read(asArray(app.previousArtifactFingerprints)), false), __read(asArray(app.previous_artifact_fingerprints)), false),
3766
- now: input.now
3767
- });
3768
- var workflowReadinessGate = aicoderWorkflowProofReadinessGate(workflowReadiness, input.now);
3769
- gates.push(workflowReadinessGate);
3770
- pushEvent(events, {
3771
- type: 'qa_business_assertion',
3772
- category: 'aicoder_workflow_proof_readiness',
3773
- message: workflowReadinessGate.reason,
3774
- artifactPaths: workflowReadinessGate.evidenceRefs,
3775
- recordedAt: workflowReadinessGate.recordedAt,
3776
- metadata: workflowReadinessGate.metadata
3777
- });
3778
- var workflowProofCheckpoint = aicoderWorkflowProofCheckpointObject(app, job, evidence);
3779
- var workflowProofCheckpointGate = aicoderWorkflowProofCheckpointGate(workflowProofCheckpoint, input.now);
3780
- if (workflowProofCheckpointGate) {
3781
- gates.push(workflowProofCheckpointGate);
3782
- pushEvent(events, {
3783
- type: 'log',
3784
- category: 'aicoder_workflow_proof_checkpoint',
3785
- message: workflowProofCheckpointGate.reason,
3786
- artifactPaths: workflowProofCheckpointGate.evidenceRefs,
3787
- recordedAt: workflowProofCheckpointGate.recordedAt,
3788
- metadata: workflowProofCheckpointGate.metadata
3789
- });
3790
- }
3791
- var nextActionContract = aicoderNextActionContractObject(app, job, evidence);
3792
- var nextActionContractGate = aicoderNextActionContractGate(nextActionContract, input.now);
3793
- if (nextActionContractGate) {
3794
- gates.push(nextActionContractGate);
3795
- pushEvent(events, {
3796
- type: 'log',
3797
- category: 'aicoder_next_action_contract',
3798
- message: nextActionContractGate.reason,
3799
- artifactPaths: nextActionContractGate.evidenceRefs,
3800
- recordedAt: nextActionContractGate.recordedAt,
3801
- metadata: nextActionContractGate.metadata
3802
- });
3803
- }
3804
- var qa = applyAICoderWorkflowProofGate(buildQaFromEvidence(evidence, input.now), workflowReadiness, input.now);
3805
- return (0, ai_run_evidence_1.buildAIRun)({
3806
- source: 'aicoder_app',
3807
- sourceIds: sourceIds,
3808
- title: firstText(app, ['name', 'title']) || firstText(job, ['appName', 'title', 'goal']),
3809
- status: firstText(job, ['status', 'state']) || firstText(app, ['status', 'state']),
3810
- phase: firstText(job, ['phase', 'runnerPhase']),
3811
- startedAt: dateValue(job, ['startedAt', 'createdAt']) || dateValue(app, ['createdAt']),
3812
- completedAt: dateValue(job, ['completedAt', 'finishedAt', 'updatedAt']),
3813
- events: events,
3814
- gates: gates,
3815
- qa: qa,
3816
- cost: cost,
3817
- scorecardPassed: scorecardPassed,
3818
- deployStatus: evidence.deployStatus || statusFromBoolean(evidence.deployReady),
3819
- publishStatus: evidence.publishStatus || evidence.pullRequestStatus,
3820
- sampleDataStatus: evidence.sampleDataStatus || statusFromBoolean((_f = evidence.sampleDataReady) !== null && _f !== void 0 ? _f : evidence.hasSampleData),
3821
- manualHandoff: evidence.manualHandoff === true || job.manualHandoff === true,
3822
- stopped: evidence.stopped === true || job.stopped === true,
3823
- rejected: evidence.rejected === true,
3824
- explicitAccepted: evidence.explicitAccepted === true || app.accepted === true,
3825
- terminal: /complete|closed|resolved|done|failed|rejected/i.test("".concat(job.status || '', " ").concat(job.phase || '')),
3826
- now: input.now,
3827
- metadata: {
3828
- domain: app.domain || app.customDomain || job.domain,
3829
- wowScore: (_g = evidence.wowScore) !== null && _g !== void 0 ? _g : job.wowScore,
3830
- score: (_h = evidence.score) !== null && _h !== void 0 ? _h : evidence.qualityScore,
3831
- hotfixDurability: hotfixDurabilityMetadata(gates),
3832
- managerNoBlindLoopPolicy: managerNoBlindLoopMetadata(noBlindLoopGate),
3833
- journeyContract: {
3834
- status: journeyContractGate.status,
3835
- valid: ((_j = journeyContractGate.metadata) === null || _j === void 0 ? void 0 : _j.valid) === true,
3836
- path: cleanText((_k = journeyContractGate.metadata) === null || _k === void 0 ? void 0 : _k.path, 500),
3837
- primaryWorkflowId: cleanText((_l = journeyContractGate.metadata) === null || _l === void 0 ? void 0 : _l.primaryWorkflowId, 200),
3838
- workflowQaRowCount: Number(((_m = journeyContractGate.metadata) === null || _m === void 0 ? void 0 : _m.workflowQaRowCount) || 0),
3839
- errorCount: Number(((_o = journeyContractGate.metadata) === null || _o === void 0 ? void 0 : _o.errorCount) || 0),
3840
- warningCount: Number(((_p = journeyContractGate.metadata) === null || _p === void 0 ? void 0 : _p.warningCount) || 0),
3841
- issueCodes: cleanStringList((_q = journeyContractGate.metadata) === null || _q === void 0 ? void 0 : _q.issueCodes, 40, 120),
3842
- blocksBuildUntilValid: ((_r = journeyContractGate.metadata) === null || _r === void 0 ? void 0 : _r.blocksBuildUntilValid) === true,
3843
- blocksWorkflowQaUntilValid: ((_s = journeyContractGate.metadata) === null || _s === void 0 ? void 0 : _s.blocksWorkflowQaUntilValid) === true,
3844
- blocksWowUiUntilWorkflowProof: ((_t = journeyContractGate.metadata) === null || _t === void 0 ? void 0 : _t.blocksWowUiUntilWorkflowProof) === true,
3845
- blocksPublishUntilWorkflowProof: ((_u = journeyContractGate.metadata) === null || _u === void 0 ? void 0 : _u.blocksPublishUntilWorkflowProof) === true,
3846
- nextAction: cleanText((_v = journeyContractGate.metadata) === null || _v === void 0 ? void 0 : _v.nextAction, 1000)
3847
- },
3848
- workflowProofReadiness: {
3849
- ready: workflowReadiness.ready,
3850
- status: workflowReadiness.status,
3851
- reason: workflowReadiness.reason,
3852
- blockers: workflowReadiness.blockers,
3853
- primaryWorkflowId: workflowReadiness.primaryWorkflowId,
3854
- passedWorkflowRows: workflowReadiness.passedWorkflowRows,
3855
- missingWorkflowRows: workflowReadiness.missingWorkflowRows,
3856
- failedWorkflowRows: workflowReadiness.failedWorkflowRows,
3857
- sampleDataReady: workflowReadiness.sampleDataReady,
3858
- releaseBlockers: workflowReadiness.releaseBlockers,
3859
- workflowProofFingerprint: workflowReadiness.workflowProofFingerprint,
3860
- artifactFingerprint: workflowReadiness.artifactFingerprint,
3861
- proofFreshness: workflowReadiness.proofFreshness
3862
- },
3863
- workflowProofCheckpoint: workflowProofCheckpointGate ? {
3864
- status: cleanText((_w = workflowProofCheckpointGate.metadata) === null || _w === void 0 ? void 0 : _w.status, 120),
3865
- gateStatus: workflowProofCheckpointGate.status,
3866
- readinessStatus: cleanText((_x = workflowProofCheckpointGate.metadata) === null || _x === void 0 ? void 0 : _x.readinessStatus, 120),
3867
- nextGate: cleanText((_y = workflowProofCheckpointGate.metadata) === null || _y === void 0 ? void 0 : _y.nextGate, 120),
3868
- nextAction: cleanText((_z = workflowProofCheckpointGate.metadata) === null || _z === void 0 ? void 0 : _z.nextAction, 1000),
3869
- blocksProductRepairUntilJourneyContract: ((_0 = workflowProofCheckpointGate.metadata) === null || _0 === void 0 ? void 0 : _0.blocksProductRepairUntilJourneyContract) === true,
3870
- blocksPublishUntilWorkflowProof: ((_1 = workflowProofCheckpointGate.metadata) === null || _1 === void 0 ? void 0 : _1.blocksPublishUntilWorkflowProof) === true,
3871
- blocksPublishUntilReleaseGate: ((_2 = workflowProofCheckpointGate.metadata) === null || _2 === void 0 ? void 0 : _2.blocksPublishUntilReleaseGate) === true,
3872
- blocksWowUiUntilWorkflowProof: ((_3 = workflowProofCheckpointGate.metadata) === null || _3 === void 0 ? void 0 : _3.blocksWowUiUntilWorkflowProof) === true,
3873
- workflowProofFingerprint: cleanText((_4 = workflowProofCheckpointGate.metadata) === null || _4 === void 0 ? void 0 : _4.workflowProofFingerprint, 200),
3874
- artifactFingerprint: cleanText((_5 = workflowProofCheckpointGate.metadata) === null || _5 === void 0 ? void 0 : _5.artifactFingerprint, 200),
3875
- blockers: cleanStringList((_6 = workflowProofCheckpointGate.metadata) === null || _6 === void 0 ? void 0 : _6.blockers, 20, 500)
3876
- } : undefined,
3877
- nextActionContract: nextActionContractGate ? {
3878
- gateStatus: nextActionContractGate.status,
3879
- contractId: cleanText((_7 = nextActionContractGate.metadata) === null || _7 === void 0 ? void 0 : _7.contractId, 200),
3880
- action: cleanText((_8 = nextActionContractGate.metadata) === null || _8 === void 0 ? void 0 : _8.action, 120),
3881
- label: cleanText((_9 = nextActionContractGate.metadata) === null || _9 === void 0 ? void 0 : _9.label, 200),
3882
- primaryCommand: cleanText((_10 = nextActionContractGate.metadata) === null || _10 === void 0 ? void 0 : _10.primaryCommand, 200),
3883
- lane: cleanText((_11 = nextActionContractGate.metadata) === null || _11 === void 0 ? void 0 : _11.lane, 120),
3884
- stepType: cleanText((_12 = nextActionContractGate.metadata) === null || _12 === void 0 ? void 0 : _12.stepType, 120),
3885
- safeToAutoRun: ((_13 = nextActionContractGate.metadata) === null || _13 === void 0 ? void 0 : _13.safeToAutoRun) === true,
3886
- requiresHumanApproval: ((_14 = nextActionContractGate.metadata) === null || _14 === void 0 ? void 0 : _14.requiresHumanApproval) === true,
3887
- canRunWithoutCodexMonitor: ((_15 = nextActionContractGate.metadata) === null || _15 === void 0 ? void 0 : _15.canRunWithoutCodexMonitor) === true,
3888
- codexFallbackRequired: ((_16 = nextActionContractGate.metadata) === null || _16 === void 0 ? void 0 : _16.codexFallbackRequired) === true,
3889
- costRisk: cleanText((_17 = nextActionContractGate.metadata) === null || _17 === void 0 ? void 0 : _17.costRisk, 120),
3890
- workflowFirstSatisfied: ((_18 = nextActionContractGate.metadata) === null || _18 === void 0 ? void 0 : _18.workflowFirstSatisfied) === true,
3891
- hotfixCommitRequired: ((_19 = nextActionContractGate.metadata) === null || _19 === void 0 ? void 0 : _19.hotfixCommitRequired) === true,
3892
- liveHotfixBlockedUntilCommit: ((_20 = nextActionContractGate.metadata) === null || _20 === void 0 ? void 0 : _20.liveHotfixBlockedUntilCommit) === true,
3893
- decisionBasis: plainObject((_21 = nextActionContractGate.metadata) === null || _21 === void 0 ? void 0 : _21.decisionBasis),
3894
- preconditions: cleanStringList((_22 = nextActionContractGate.metadata) === null || _22 === void 0 ? void 0 : _22.preconditions, 20, 500),
3895
- successEvidence: cleanStringList((_23 = nextActionContractGate.metadata) === null || _23 === void 0 ? void 0 : _23.successEvidence, 20, 500),
3896
- requiredHotfixCommitProof: cleanStringList((_24 = nextActionContractGate.metadata) === null || _24 === void 0 ? void 0 : _24.requiredHotfixCommitProof, 20, 240),
3897
- stopConditions: cleanStringList((_25 = nextActionContractGate.metadata) === null || _25 === void 0 ? void 0 : _25.stopConditions, 20, 500),
3898
- forbiddenActions: cleanStringList((_26 = nextActionContractGate.metadata) === null || _26 === void 0 ? void 0 : _26.forbiddenActions, 20, 500),
3899
- nextCommands: cleanStringList((_27 = nextActionContractGate.metadata) === null || _27 === void 0 ? void 0 : _27.nextCommands, 20, 240),
3900
- blockers: cleanStringList((_28 = nextActionContractGate.metadata) === null || _28 === void 0 ? void 0 : _28.blockers, 20, 500)
3901
- } : undefined
3902
- }
3903
- });
3904
- }
3905
- function buildAssistantAIRunFromEvidence(input) {
3906
- var e_35, _a, e_36, _b, e_37, _c;
3907
- var _d, _e, _f, _g;
3908
- var conversation = input.conversation || {};
3909
- var events = [];
3910
- var sourceIds = {};
3911
- addSourceId(sourceIds, 'runId', input.runId);
3912
- addSourceId(sourceIds, 'requestId', input.requestId);
3913
- addSourceId(sourceIds, 'messageId', input.messageId);
3914
- addSourceId(sourceIds, 'conversationId', conversation._id || conversation.id || conversation.conversationId);
3915
- addSourceId(sourceIds, 'userId', conversation.userId || conversation.ownerId);
3916
- try {
3917
- for (var _h = __values(asArray(input.messages)), _j = _h.next(); !_j.done; _j = _h.next()) {
3918
- var message = _j.value;
3919
- pushEvent(events, {
3920
- type: 'assistant_message',
3921
- category: cleanText(message.role || message.authorRole || message.type, 160),
3922
- message: cleanText(message.content || message.text || message.message || message.summary, 1800),
3923
- recordedAt: eventDate(message),
3924
- metadata: {
3925
- id: message._id || message.id,
3926
- role: message.role,
3927
- model: message.model || ((_d = message === null || message === void 0 ? void 0 : message.usage) === null || _d === void 0 ? void 0 : _d.model)
3928
- }
3929
- });
3930
- }
3931
- }
3932
- catch (e_35_1) { e_35 = { error: e_35_1 }; }
3933
- finally {
3934
- try {
3935
- if (_j && !_j.done && (_a = _h.return)) _a.call(_h);
3936
- }
3937
- finally { if (e_35) throw e_35.error; }
3938
- }
3939
- try {
3940
- for (var _k = __values(asArray(input.issueReports)), _l = _k.next(); !_l.done; _l = _k.next()) {
3941
- var report = _l.value;
3942
- pushEvent(events, {
3943
- type: 'human_intervention',
3944
- category: cleanText(report.category || report.status || 'issue_report', 160),
3945
- message: cleanText(report.summary || report.description || report.message || report.title, 1800),
3946
- recordedAt: eventDate(report),
3947
- metadata: {
3948
- id: report._id || report.id,
3949
- status: report.status,
3950
- severity: report.severity
3951
- }
3952
- });
3953
- }
3954
- }
3955
- catch (e_36_1) { e_36 = { error: e_36_1 }; }
3956
- finally {
3957
- try {
3958
- if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
3959
- }
3960
- finally { if (e_36) throw e_36.error; }
3961
- }
3962
- var cost = collectUsageEvents(asArray(input.usageLedger), events);
3963
- var answerQuality = assistantQualityObject(input);
3964
- try {
3965
- for (var _m = __values(assistantQueryExecutions(answerQuality).slice(0, 40)), _o = _m.next(); !_o.done; _o = _m.next()) {
3966
- var execution = _o.value;
3967
- var status_1 = cleanText(execution.status || execution.queryStatus || execution.query_status || execution.resultStatus || execution.result_status, 120);
3968
- var toolName = cleanText(execution.tool || execution.toolName || execution.tool_name || execution.type || 'query', 160);
3969
- var collection = cleanText(execution.collection || execution.collectionName || execution.collection_name, 240);
3970
- pushEvent(events, {
3971
- type: 'assistant_query',
3972
- category: status_1 || toolName,
3973
- message: cleanText(execution.summary || execution.message || "".concat(toolName).concat(collection ? " ".concat(collection) : ''), 1200),
3974
- artifactPaths: cleanStringList(__spreadArray(__spreadArray([
3975
- execution.artifactPath,
3976
- execution.artifact_path,
3977
- execution.path
3978
- ], __read(asArray(execution.artifactPaths)), false), __read(asArray(execution.artifact_paths)), false), 20, 500),
3979
- recordedAt: eventDate(execution),
3980
- metadata: {
3981
- id: execution.id || execution._id || execution.ref,
3982
- tool: toolName,
3983
- status: status_1,
3984
- collection: collection,
3985
- resultCount: (_f = (_e = execution.resultCount) !== null && _e !== void 0 ? _e : execution.result_count) !== null && _f !== void 0 ? _f : execution.count,
3986
- queryStatus: execution.queryStatus || execution.query_status,
3987
- legalQueryShape: (_g = execution.legalQueryShape) !== null && _g !== void 0 ? _g : execution.legal_query_shape
3988
- }
3989
- });
3990
- }
3991
- }
3992
- catch (e_37_1) { e_37 = { error: e_37_1 }; }
3993
- finally {
3994
- try {
3995
- if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
3996
- }
3997
- finally { if (e_37) throw e_37.error; }
3998
- }
3999
- var answerQualityDecision = evaluateAssistantAnswerQuality({
4000
- answerQuality: answerQuality,
4001
- correctnessChecks: input.correctnessChecks,
4002
- now: input.now
4003
- });
4004
- var answerQualityGate = assistantAnswerQualityGate(answerQualityDecision, input.now);
4005
- pushEvent(events, {
4006
- type: 'assistant_message',
4007
- category: 'assistant_answer_quality',
4008
- message: answerQualityGate.reason,
4009
- artifactPaths: answerQualityGate.evidenceRefs,
4010
- recordedAt: answerQualityGate.recordedAt,
4011
- metadata: answerQualityGate.metadata
4012
- });
4013
- var answerActionabilityContract = buildAssistantAnswerActionabilityContract(answerQualityDecision, input.now);
4014
- var answerActionabilityGate = assistantAnswerActionabilityGate(answerActionabilityContract, input.now);
4015
- pushEvent(events, {
4016
- type: 'assistant_message',
4017
- category: 'assistant_answer_actionability',
4018
- message: answerActionabilityGate.reason,
4019
- artifactPaths: answerActionabilityGate.evidenceRefs,
4020
- recordedAt: answerActionabilityGate.recordedAt,
4021
- metadata: answerActionabilityGate.metadata
4022
- });
4023
- var correctnessChecks = asArray(input.correctnessChecks);
4024
- var hasPassedCorrectnessCheck = correctnessChecks.some(function (check) { return /^(pass|passed|success|ok)$/i.test(cleanText(check.status || (check.passed === true ? 'pass' : ''), 80)); });
4025
- var correctnessEvidence = {
4026
- businessAssertions: __spreadArray(__spreadArray([], __read(correctnessChecks.map(function (check) { return ({
4027
- assertion: check.assertion || check.name || check.case || 'assistant correctness check',
4028
- status: check.status || statusFromBoolean(check.passed),
4029
- expected: check.expected,
4030
- observed: check.observed || check.actual,
4031
- dataProof: check.dataProof || check.proof,
4032
- artifactPaths: check.artifactPaths,
4033
- message: check.message || check.reason,
4034
- metadata: check.metadata,
4035
- recordedAt: eventDate(check)
4036
- }); })), false), __read((answerQualityDecision.ready && !hasPassedCorrectnessCheck ? [{
4037
- assertion: 'Assistant answer quality gate passed.',
4038
- status: 'pass',
4039
- expected: 'Correct dates, legal query shape, query result classification, cited evidence, confidence, and next action.',
4040
- observed: answerQualityDecision.reason,
4041
- dataProof: answerQualityDecision.evidenceRefs.concat(answerQualityDecision.citationRefs).join(', '),
4042
- artifactPaths: answerQualityDecision.evidenceRefs,
4043
- message: answerQualityDecision.reason,
4044
- metadata: {
4045
- answerQualityStatus: answerQualityDecision.status,
4046
- queryStatus: answerQualityDecision.queryStatus,
4047
- dateWindowRequired: answerQualityDecision.dateWindowRequired,
4048
- dateWindowPresent: answerQualityDecision.dateWindowPresent,
4049
- dateWindow: answerQualityDecision.dateWindow
4050
- }
4051
- }] : [])), false)
4052
- };
4053
- var qa = applyAssistantAnswerQualityGate(buildQaFromEvidence(correctnessEvidence, input.now), answerQualityDecision, input.now);
4054
- var failedReports = asArray(input.issueReports)
4055
- .filter(function (report) { return /open|new|fail|bug|wrong|incorrect|error/i.test("".concat(report.status || '', " ").concat(report.category || '', " ").concat(report.summary || '')); });
4056
- return (0, ai_run_evidence_1.buildAIRun)({
4057
- id: cleanText(input.runId, 240) || undefined,
4058
- source: 'ai_assistant',
4059
- sourceIds: sourceIds,
4060
- title: firstText(conversation, ['title', 'subject', 'summary']) || 'AI assistant conversation',
4061
- status: firstText(conversation, ['status', 'state']),
4062
- phase: firstText(conversation, ['phase']),
4063
- startedAt: dateValue(conversation, ['startedAt', 'createdAt']),
4064
- completedAt: dateValue(conversation, ['completedAt', 'closedAt', 'updatedAt']),
4065
- events: events,
4066
- gates: [answerActionabilityGate],
4067
- qa: qa,
4068
- cost: cost,
4069
- rejected: failedReports.length > 0 || conversation.rejected === true,
4070
- manualHandoff: conversation.manualHandoff === true,
4071
- stopped: conversation.stopped === true,
4072
- explicitAccepted: conversation.accepted === true,
4073
- terminal: /complete|closed|resolved|done|failed|rejected/i.test("".concat(conversation.status || '')),
4074
- now: input.now,
4075
- metadata: {
4076
- issueReportCount: asArray(input.issueReports).length,
4077
- correctnessCheckCount: correctnessChecks.length,
4078
- answerQuality: {
4079
- ready: answerQualityDecision.ready,
4080
- status: answerQualityDecision.status,
4081
- queryStatus: answerQualityDecision.queryStatus,
4082
- confidenceLevel: answerQualityDecision.confidenceLevel,
4083
- dateBasis: answerQualityDecision.dateBasis,
4084
- expectedCurrentDate: answerQualityDecision.expectedCurrentDate,
4085
- dateWindowRequired: answerQualityDecision.dateWindowRequired,
4086
- dateWindowPresent: answerQualityDecision.dateWindowPresent,
4087
- dateWindow: answerQualityDecision.dateWindow,
4088
- noDataConfirmed: answerQualityDecision.noDataConfirmed,
4089
- legalQueryShape: answerQualityDecision.legalQueryShape,
4090
- citationRefs: answerQualityDecision.citationRefs,
4091
- queryEvidenceRequired: answerQualityDecision.queryEvidenceRequired,
4092
- queryEvidencePresent: answerQualityDecision.queryEvidencePresent,
4093
- queryEvidenceRefs: answerQualityDecision.queryEvidenceRefs,
4094
- queryExecutionCount: answerQualityDecision.queryExecutionCount,
4095
- nextActions: answerQualityDecision.nextActions,
4096
- blockers: answerQualityDecision.blockers
4097
- },
4098
- answerActionability: {
4099
- contractId: answerActionabilityContract.contractId,
4100
- status: answerActionabilityContract.status,
4101
- primaryCommand: answerActionabilityContract.primaryCommand,
4102
- label: answerActionabilityContract.label,
4103
- canAnswerCustomer: answerActionabilityContract.canAnswerCustomer,
4104
- canDraftSupportReply: answerActionabilityContract.canDraftSupportReply,
4105
- canSendCustomerReply: answerActionabilityContract.canSendCustomerReply,
4106
- requiresHumanReview: answerActionabilityContract.requiresHumanReview,
4107
- canRunWithoutCodexMonitor: answerActionabilityContract.canRunWithoutCodexMonitor,
4108
- codexFallbackRequired: answerActionabilityContract.codexFallbackRequired,
4109
- costRisk: answerActionabilityContract.costRisk,
4110
- queryResultClass: answerActionabilityContract.queryResultClass,
4111
- confidenceLevel: answerActionabilityContract.confidenceLevel,
4112
- decisionBasis: answerActionabilityContract.decisionBasis,
4113
- requiredEvidence: answerActionabilityContract.requiredEvidence,
4114
- successEvidence: answerActionabilityContract.successEvidence,
4115
- blockers: answerActionabilityContract.blockers,
4116
- nextActions: answerActionabilityContract.nextActions,
4117
- nextCommands: answerActionabilityContract.nextCommands,
4118
- forbiddenActions: answerActionabilityContract.forbiddenActions
4119
- }
4120
- }
4121
- });
4122
- }
4123
-
4124
- //# sourceMappingURL=ai-run-evidence-adapters.js.map