@resolveio/server-lib 22.3.196 → 22.3.197

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