harnery 0.36.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/dist/commander.d.ts +9 -0
  2. package/dist/commander.d.ts.map +1 -1
  3. package/dist/commander.js +10 -1
  4. package/dist/commands/admission.d.ts +21 -0
  5. package/dist/commands/admission.d.ts.map +1 -0
  6. package/dist/commands/admission.js +565 -0
  7. package/dist/commands/agents.d.ts +7 -0
  8. package/dist/commands/agents.d.ts.map +1 -1
  9. package/dist/commands/agents.js +148 -47
  10. package/dist/commands/artifacts.d.ts.map +1 -1
  11. package/dist/commands/artifacts.js +73 -2
  12. package/dist/commands/browse-ai.d.ts +2 -2
  13. package/dist/commands/browse-ai.d.ts.map +1 -1
  14. package/dist/commands/browse-ai.js +6 -4
  15. package/dist/commands/browse.d.ts.map +1 -1
  16. package/dist/commands/browse.js +360 -21
  17. package/dist/commands/diagnostics.d.ts +4 -0
  18. package/dist/commands/diagnostics.d.ts.map +1 -0
  19. package/dist/commands/diagnostics.js +229 -0
  20. package/dist/commands/fetch.js +1 -0
  21. package/dist/commands/files.d.ts +12 -0
  22. package/dist/commands/files.d.ts.map +1 -1
  23. package/dist/commands/files.js +54 -1
  24. package/dist/commands/governor.d.ts.map +1 -1
  25. package/dist/commands/governor.js +4 -0
  26. package/dist/commands/ledger-v3.d.ts.map +1 -1
  27. package/dist/commands/ledger-v3.js +71 -2
  28. package/dist/commands/qa-record.d.ts +144 -0
  29. package/dist/commands/qa-record.d.ts.map +1 -0
  30. package/dist/commands/qa-record.js +0 -0
  31. package/dist/commands/qa-run.d.ts +8 -0
  32. package/dist/commands/qa-run.d.ts.map +1 -0
  33. package/dist/commands/qa-run.js +396 -0
  34. package/dist/commands/qa-status.d.ts +71 -0
  35. package/dist/commands/qa-status.d.ts.map +1 -0
  36. package/dist/commands/qa-status.js +490 -0
  37. package/dist/commands/qa-verify.d.ts +40 -0
  38. package/dist/commands/qa-verify.d.ts.map +1 -0
  39. package/dist/commands/qa-verify.js +180 -0
  40. package/dist/commands/resources.d.ts +4 -0
  41. package/dist/commands/resources.d.ts.map +1 -0
  42. package/dist/commands/resources.js +29 -0
  43. package/dist/commands/review-pack.d.ts +4 -0
  44. package/dist/commands/review-pack.d.ts.map +1 -0
  45. package/dist/commands/review-pack.js +1001 -0
  46. package/dist/commands/supervisor.d.ts +4 -0
  47. package/dist/commands/supervisor.d.ts.map +1 -0
  48. package/dist/commands/supervisor.js +101 -0
  49. package/dist/commands/web.d.ts.map +1 -1
  50. package/dist/commands/web.js +17 -0
  51. package/dist/commands/workflow.d.ts.map +1 -1
  52. package/dist/commands/workflow.js +4 -0
  53. package/dist/core/agents/cli.js +7 -3
  54. package/dist/core/agents/health.d.ts +17 -0
  55. package/dist/core/agents/health.d.ts.map +1 -0
  56. package/dist/core/agents/health.js +109 -0
  57. package/dist/core/agents/mailbox.d.ts +92 -0
  58. package/dist/core/agents/mailbox.d.ts.map +1 -0
  59. package/dist/core/agents/mailbox.js +325 -0
  60. package/dist/core/agents/qa-signal.d.ts +111 -0
  61. package/dist/core/agents/qa-signal.d.ts.map +1 -0
  62. package/dist/core/agents/qa-signal.js +231 -0
  63. package/dist/core/agents/reconcile-coordination-v3.d.ts +44 -0
  64. package/dist/core/agents/reconcile-coordination-v3.d.ts.map +1 -0
  65. package/dist/core/agents/reconcile-coordination-v3.js +58 -0
  66. package/dist/core/agents/render/prompt-context.d.ts +5 -0
  67. package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
  68. package/dist/core/agents/render/prompt-context.js +34 -13
  69. package/dist/core/agents/render/session-context.d.ts +8 -0
  70. package/dist/core/agents/render/session-context.d.ts.map +1 -1
  71. package/dist/core/agents/render/session-context.js +34 -3
  72. package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
  73. package/dist/core/agents/rules/commit-conflict.js +50 -1
  74. package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
  75. package/dist/core/agents/rules/stop-hook.js +6 -10
  76. package/dist/core/agents/session-finalizer-v3.js +4 -1
  77. package/dist/core/agents/session-name-display.d.ts +20 -5
  78. package/dist/core/agents/session-name-display.d.ts.map +1 -1
  79. package/dist/core/agents/session-name-display.js +67 -7
  80. package/dist/core/agents/state/heartbeat-reader.d.ts +7 -0
  81. package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -1
  82. package/dist/core/agents/state/heartbeat-writer.d.ts +11 -0
  83. package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
  84. package/dist/core/agents/state/heartbeat-writer.js +17 -0
  85. package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
  86. package/dist/core/agents/state/live-coordination-view.js +1 -0
  87. package/dist/core/agents/state/live-coordination-writer.js +5 -0
  88. package/dist/core/artifacts/constants.d.ts +1 -1
  89. package/dist/core/artifacts/constants.js +1 -1
  90. package/dist/core/artifacts/index.d.ts +82 -6
  91. package/dist/core/artifacts/index.d.ts.map +1 -1
  92. package/dist/core/artifacts/index.js +410 -15
  93. package/dist/core/config.d.ts +20 -0
  94. package/dist/core/config.d.ts.map +1 -1
  95. package/dist/core/config.js +59 -0
  96. package/dist/core/diagnostics/advice.d.ts +9 -0
  97. package/dist/core/diagnostics/advice.d.ts.map +1 -0
  98. package/dist/core/diagnostics/advice.js +112 -0
  99. package/dist/core/diagnostics/bundle.d.ts +51 -0
  100. package/dist/core/diagnostics/bundle.d.ts.map +1 -0
  101. package/dist/core/diagnostics/bundle.js +968 -0
  102. package/dist/core/diagnostics/comparison.d.ts +5 -0
  103. package/dist/core/diagnostics/comparison.d.ts.map +1 -0
  104. package/dist/core/diagnostics/comparison.js +444 -0
  105. package/dist/core/diagnostics/contract.d.ts +245 -0
  106. package/dist/core/diagnostics/contract.d.ts.map +1 -0
  107. package/dist/core/diagnostics/contract.js +18 -0
  108. package/dist/core/diagnostics/identity.d.ts +3 -0
  109. package/dist/core/diagnostics/identity.d.ts.map +1 -0
  110. package/dist/core/diagnostics/identity.js +10 -0
  111. package/dist/core/diagnostics/index.d.ts +8 -0
  112. package/dist/core/diagnostics/index.d.ts.map +1 -0
  113. package/dist/core/diagnostics/index.js +7 -0
  114. package/dist/core/diagnostics/replay.d.ts +8 -0
  115. package/dist/core/diagnostics/replay.d.ts.map +1 -0
  116. package/dist/core/diagnostics/replay.js +213 -0
  117. package/dist/core/diagnostics/sanitize.d.ts +9 -0
  118. package/dist/core/diagnostics/sanitize.d.ts.map +1 -0
  119. package/dist/core/diagnostics/sanitize.js +84 -0
  120. package/dist/core/events/legacy-storage/compression.d.ts +13 -0
  121. package/dist/core/events/legacy-storage/compression.d.ts.map +1 -0
  122. package/dist/core/events/legacy-storage/compression.js +107 -0
  123. package/dist/core/events/legacy-storage/index.d.ts +1 -0
  124. package/dist/core/events/legacy-storage/index.d.ts.map +1 -1
  125. package/dist/core/events/legacy-storage/index.js +1 -0
  126. package/dist/core/events/v3/archive-retention.d.ts +33 -0
  127. package/dist/core/events/v3/archive-retention.d.ts.map +1 -0
  128. package/dist/core/events/v3/archive-retention.js +195 -0
  129. package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
  130. package/dist/core/events/v3/bootstrap.js +10 -0
  131. package/dist/core/events/v3/capabilities.d.ts +1 -1
  132. package/dist/core/events/v3/capabilities.d.ts.map +1 -1
  133. package/dist/core/events/v3/capabilities.js +1 -0
  134. package/dist/core/events/v3/coordination-view.d.ts +3 -0
  135. package/dist/core/events/v3/coordination-view.d.ts.map +1 -1
  136. package/dist/core/events/v3/coordination-view.js +69 -8
  137. package/dist/core/events/v3/index.d.ts +1 -0
  138. package/dist/core/events/v3/index.d.ts.map +1 -1
  139. package/dist/core/events/v3/index.js +1 -0
  140. package/dist/core/events/v3/live-routing.d.ts.map +1 -1
  141. package/dist/core/events/v3/live-routing.js +1 -0
  142. package/dist/core/events/v3/producers/hook-base.d.ts +1 -1
  143. package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
  144. package/dist/core/events/v3/producers/hook-base.js +13 -2
  145. package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
  146. package/dist/core/events/v3/producers/intake.js +10 -2
  147. package/dist/core/events/v3/producers/recorder.d.ts +39 -0
  148. package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
  149. package/dist/core/events/v3/producers/recorder.js +350 -17
  150. package/dist/core/hooks/adapter/output.d.ts +8 -0
  151. package/dist/core/hooks/adapter/output.d.ts.map +1 -1
  152. package/dist/core/hooks/adapter/output.js +11 -1
  153. package/dist/core/hooks/cli.js +303 -219
  154. package/dist/core/hooks/health.d.ts +59 -0
  155. package/dist/core/hooks/health.d.ts.map +1 -0
  156. package/dist/core/hooks/health.js +84 -0
  157. package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
  158. package/dist/core/hooks/resolve/transcript.js +10 -3
  159. package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
  160. package/dist/core/hooks/session-name-presence.js +4 -1
  161. package/dist/core/qa-artifacts.d.ts +20 -0
  162. package/dist/core/qa-artifacts.d.ts.map +1 -0
  163. package/dist/core/qa-artifacts.js +110 -0
  164. package/dist/core/resources/contract.d.ts +96 -0
  165. package/dist/core/resources/contract.d.ts.map +1 -0
  166. package/dist/core/resources/contract.js +2 -0
  167. package/dist/core/resources/index.d.ts +6 -0
  168. package/dist/core/resources/index.d.ts.map +1 -0
  169. package/dist/core/resources/index.js +5 -0
  170. package/dist/core/resources/sampler.d.ts +34 -0
  171. package/dist/core/resources/sampler.d.ts.map +1 -0
  172. package/dist/core/resources/sampler.js +458 -0
  173. package/dist/core/resources/service-status.d.ts +3 -0
  174. package/dist/core/resources/service-status.d.ts.map +1 -0
  175. package/dist/core/resources/service-status.js +48 -0
  176. package/dist/core/resources/service.d.ts +26 -0
  177. package/dist/core/resources/service.d.ts.map +1 -0
  178. package/dist/core/resources/service.js +292 -0
  179. package/dist/core/resources/storage.d.ts +13 -0
  180. package/dist/core/resources/storage.d.ts.map +1 -0
  181. package/dist/core/resources/storage.js +30 -0
  182. package/dist/core/storage/atomic-json.d.ts +3 -0
  183. package/dist/core/storage/atomic-json.d.ts.map +1 -0
  184. package/dist/core/storage/atomic-json.js +15 -0
  185. package/dist/core/storage/builtins.d.ts.map +1 -1
  186. package/dist/core/storage/builtins.js +45 -6
  187. package/dist/core/storage/logger.d.ts +2 -0
  188. package/dist/core/storage/logger.d.ts.map +1 -1
  189. package/dist/core/storage/logger.js +2 -0
  190. package/dist/core/storage/query.d.ts +14 -0
  191. package/dist/core/storage/query.d.ts.map +1 -1
  192. package/dist/core/storage/query.js +51 -0
  193. package/dist/core/supervisor/activity.d.ts +4 -0
  194. package/dist/core/supervisor/activity.d.ts.map +1 -0
  195. package/dist/core/supervisor/activity.js +141 -0
  196. package/dist/core/supervisor/contract.d.ts +268 -0
  197. package/dist/core/supervisor/contract.d.ts.map +1 -0
  198. package/dist/core/supervisor/contract.js +35 -0
  199. package/dist/core/supervisor/explanations.d.ts +4 -0
  200. package/dist/core/supervisor/explanations.d.ts.map +1 -0
  201. package/dist/core/supervisor/explanations.js +71 -0
  202. package/dist/core/supervisor/findings.d.ts +20 -0
  203. package/dist/core/supervisor/findings.d.ts.map +1 -0
  204. package/dist/core/supervisor/findings.js +399 -0
  205. package/dist/core/supervisor/history.d.ts +9 -0
  206. package/dist/core/supervisor/history.d.ts.map +1 -0
  207. package/dist/core/supervisor/history.js +46 -0
  208. package/dist/core/supervisor/hook-health-alerts.d.ts +14 -0
  209. package/dist/core/supervisor/hook-health-alerts.d.ts.map +1 -0
  210. package/dist/core/supervisor/hook-health-alerts.js +70 -0
  211. package/dist/core/supervisor/hook-health-storage.d.ts +5 -0
  212. package/dist/core/supervisor/hook-health-storage.d.ts.map +1 -0
  213. package/dist/core/supervisor/hook-health-storage.js +24 -0
  214. package/dist/core/supervisor/hook-health.d.ts +72 -0
  215. package/dist/core/supervisor/hook-health.d.ts.map +1 -0
  216. package/dist/core/supervisor/hook-health.js +203 -0
  217. package/dist/core/supervisor/hooks.d.ts +10 -0
  218. package/dist/core/supervisor/hooks.d.ts.map +1 -0
  219. package/dist/core/supervisor/hooks.js +28 -0
  220. package/dist/core/supervisor/index.d.ts +15 -0
  221. package/dist/core/supervisor/index.d.ts.map +1 -0
  222. package/dist/core/supervisor/index.js +14 -0
  223. package/dist/core/supervisor/log-feed.d.ts +9 -0
  224. package/dist/core/supervisor/log-feed.d.ts.map +1 -0
  225. package/dist/core/supervisor/log-feed.js +103 -0
  226. package/dist/core/supervisor/service.d.ts +29 -0
  227. package/dist/core/supervisor/service.d.ts.map +1 -0
  228. package/dist/core/supervisor/service.js +450 -0
  229. package/dist/core/supervisor/services.d.ts +11 -0
  230. package/dist/core/supervisor/services.d.ts.map +1 -0
  231. package/dist/core/supervisor/services.js +155 -0
  232. package/dist/core/supervisor/status.d.ts +3 -0
  233. package/dist/core/supervisor/status.d.ts.map +1 -0
  234. package/dist/core/supervisor/status.js +48 -0
  235. package/dist/core/supervisor/storage.d.ts +30 -0
  236. package/dist/core/supervisor/storage.d.ts.map +1 -0
  237. package/dist/core/supervisor/storage.js +73 -0
  238. package/dist/core/supervisor/timeline.d.ts +3 -0
  239. package/dist/core/supervisor/timeline.d.ts.map +1 -0
  240. package/dist/core/supervisor/timeline.js +87 -0
  241. package/dist/core/workflow/admission.d.ts +23 -0
  242. package/dist/core/workflow/admission.d.ts.map +1 -0
  243. package/dist/core/workflow/admission.js +136 -0
  244. package/dist/core/workflow/engine.d.ts.map +1 -1
  245. package/dist/core/workflow/engine.js +77 -2
  246. package/dist/core/workflow/index.d.ts +3 -2
  247. package/dist/core/workflow/index.d.ts.map +1 -1
  248. package/dist/core/workflow/index.js +2 -1
  249. package/dist/core/workflow/proof.d.ts +2 -1
  250. package/dist/core/workflow/proof.d.ts.map +1 -1
  251. package/dist/core/workflow/proof.js +39 -1
  252. package/dist/core/workflow/run-state.d.ts +3 -2
  253. package/dist/core/workflow/run-state.d.ts.map +1 -1
  254. package/dist/core/workflow/run-state.js +8 -1
  255. package/dist/core/workflow/types.d.ts +33 -1
  256. package/dist/core/workflow/types.d.ts.map +1 -1
  257. package/dist/core/workflow/types.js +2 -1
  258. package/dist/lib/admission.d.ts +71 -0
  259. package/dist/lib/admission.d.ts.map +1 -0
  260. package/dist/lib/admission.js +264 -0
  261. package/dist/lib/agent-browser/client.d.ts +1 -1
  262. package/dist/lib/agent-browser/client.d.ts.map +1 -1
  263. package/dist/lib/agent-browser/client.js +1 -5
  264. package/dist/lib/browser/capture-fidelity.d.ts +39 -0
  265. package/dist/lib/browser/capture-fidelity.d.ts.map +1 -0
  266. package/dist/lib/browser/capture-fidelity.js +84 -0
  267. package/dist/lib/browser/client.d.ts +46 -1
  268. package/dist/lib/browser/client.d.ts.map +1 -1
  269. package/dist/lib/browser/client.js +168 -9
  270. package/dist/lib/browser/critique.d.ts +38 -1
  271. package/dist/lib/browser/critique.d.ts.map +1 -1
  272. package/dist/lib/browser/critique.js +34 -6
  273. package/dist/lib/browser/index.d.ts +5 -1
  274. package/dist/lib/browser/index.d.ts.map +1 -1
  275. package/dist/lib/browser/index.js +4 -0
  276. package/dist/lib/browser/page-review-judge.d.ts +64 -0
  277. package/dist/lib/browser/page-review-judge.d.ts.map +1 -0
  278. package/dist/lib/browser/page-review-judge.js +270 -0
  279. package/dist/lib/browser/page-review-pack.d.ts +613 -0
  280. package/dist/lib/browser/page-review-pack.d.ts.map +1 -0
  281. package/dist/lib/browser/page-review-pack.js +1751 -0
  282. package/dist/lib/browser/qa-run-contracts.d.ts +377 -0
  283. package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -0
  284. package/dist/lib/browser/qa-run-contracts.js +361 -0
  285. package/dist/lib/browser/qa-run.d.ts +141 -0
  286. package/dist/lib/browser/qa-run.d.ts.map +1 -0
  287. package/dist/lib/browser/qa-run.js +1283 -0
  288. package/dist/lib/browser/request-diagnostics.d.ts +13 -0
  289. package/dist/lib/browser/request-diagnostics.d.ts.map +1 -0
  290. package/dist/lib/browser/request-diagnostics.js +18 -0
  291. package/dist/lib/browser/tiling.d.ts +19 -0
  292. package/dist/lib/browser/tiling.d.ts.map +1 -1
  293. package/dist/lib/browser/tiling.js +28 -0
  294. package/dist/lib/cookies/client.d.ts +9 -0
  295. package/dist/lib/cookies/client.d.ts.map +1 -1
  296. package/dist/lib/cookies/client.js +197 -44
  297. package/dist/lib/cookies/extra.d.ts +18 -0
  298. package/dist/lib/cookies/extra.d.ts.map +1 -0
  299. package/dist/lib/cookies/extra.js +14 -0
  300. package/dist/lib/cookies/index.d.ts +2 -1
  301. package/dist/lib/cookies/index.d.ts.map +1 -1
  302. package/dist/lib/cookies/index.js +2 -1
  303. package/dist/lib/coord-root-id.d.ts +9 -0
  304. package/dist/lib/coord-root-id.d.ts.map +1 -0
  305. package/dist/lib/coord-root-id.js +17 -0
  306. package/dist/lib/durable-job.d.ts +124 -0
  307. package/dist/lib/durable-job.d.ts.map +1 -0
  308. package/dist/lib/durable-job.js +296 -0
  309. package/dist/lib/http/client.d.ts +7 -1
  310. package/dist/lib/http/client.d.ts.map +1 -1
  311. package/dist/lib/http/client.js +2 -0
  312. package/dist/lib/instructions/apply.d.ts +3 -1
  313. package/dist/lib/instructions/apply.d.ts.map +1 -1
  314. package/dist/lib/instructions/apply.js +74 -3
  315. package/dist/lib/instructions/templates.d.ts.map +1 -1
  316. package/dist/lib/instructions/templates.js +11 -2
  317. package/package.json +19 -2
  318. package/src/commander.ts +75 -1
  319. package/src/commands/admission.ts +699 -0
  320. package/src/commands/agents.ts +189 -50
  321. package/src/commands/artifacts.ts +132 -18
  322. package/src/commands/browse-ai.ts +10 -5
  323. package/src/commands/browse.ts +496 -20
  324. package/src/commands/diagnostics.ts +271 -0
  325. package/src/commands/fetch.ts +1 -0
  326. package/src/commands/files.ts +102 -2
  327. package/src/commands/governor.ts +8 -0
  328. package/src/commands/ledger-v3.ts +82 -0
  329. package/src/commands/qa-record.ts +682 -0
  330. package/src/commands/qa-run.ts +503 -0
  331. package/src/commands/qa-status.ts +608 -0
  332. package/src/commands/qa-verify.ts +238 -0
  333. package/src/commands/resources.ts +38 -0
  334. package/src/commands/review-pack.ts +1281 -0
  335. package/src/commands/supervisor.ts +141 -0
  336. package/src/commands/web.ts +19 -0
  337. package/src/commands/workflow.ts +8 -0
  338. package/src/core/agents/cli.ts +7 -3
  339. package/src/core/agents/health.ts +142 -0
  340. package/src/core/agents/mailbox.ts +373 -0
  341. package/src/core/agents/qa-signal.ts +261 -0
  342. package/src/core/agents/reconcile-coordination-v3.ts +77 -0
  343. package/src/core/agents/render/prompt-context.ts +42 -12
  344. package/src/core/agents/render/session-context.ts +37 -3
  345. package/src/core/agents/rules/commit-conflict.ts +58 -1
  346. package/src/core/agents/rules/stop-hook.ts +6 -12
  347. package/src/core/agents/session-finalizer-v3.ts +4 -1
  348. package/src/core/agents/session-name-display.ts +78 -7
  349. package/src/core/agents/state/heartbeat-reader.ts +7 -0
  350. package/src/core/agents/state/heartbeat-writer.ts +23 -0
  351. package/src/core/agents/state/live-coordination-view.ts +1 -0
  352. package/src/core/agents/state/live-coordination-writer.ts +5 -0
  353. package/src/core/artifacts/constants.ts +1 -1
  354. package/src/core/artifacts/index.ts +565 -30
  355. package/src/core/config.ts +134 -2
  356. package/src/core/diagnostics/advice.ts +147 -0
  357. package/src/core/diagnostics/bundle.ts +1250 -0
  358. package/src/core/diagnostics/comparison.ts +565 -0
  359. package/src/core/diagnostics/contract.ts +311 -0
  360. package/src/core/diagnostics/identity.ts +11 -0
  361. package/src/core/diagnostics/index.ts +7 -0
  362. package/src/core/diagnostics/replay.ts +314 -0
  363. package/src/core/diagnostics/sanitize.ts +97 -0
  364. package/src/core/events/legacy-storage/compression.ts +130 -0
  365. package/src/core/events/legacy-storage/index.ts +1 -0
  366. package/src/core/events/v3/archive-retention.ts +251 -0
  367. package/src/core/events/v3/bootstrap.ts +10 -0
  368. package/src/core/events/v3/capabilities.ts +2 -0
  369. package/src/core/events/v3/coordination-view.ts +100 -11
  370. package/src/core/events/v3/index.ts +9 -0
  371. package/src/core/events/v3/live-routing.ts +1 -0
  372. package/src/core/events/v3/producers/hook-base.ts +14 -2
  373. package/src/core/events/v3/producers/intake.ts +10 -2
  374. package/src/core/events/v3/producers/recorder.ts +420 -17
  375. package/src/core/hooks/adapter/output.ts +12 -1
  376. package/src/core/hooks/cli.ts +332 -247
  377. package/src/core/hooks/health.ts +146 -0
  378. package/src/core/hooks/resolve/transcript.ts +10 -3
  379. package/src/core/hooks/session-name-presence.ts +6 -1
  380. package/src/core/qa-artifacts.ts +126 -0
  381. package/src/core/resources/contract.ts +105 -0
  382. package/src/core/resources/index.ts +5 -0
  383. package/src/core/resources/sampler.ts +590 -0
  384. package/src/core/resources/service-status.ts +62 -0
  385. package/src/core/resources/service.ts +337 -0
  386. package/src/core/resources/storage.ts +44 -0
  387. package/src/core/storage/atomic-json.ts +15 -0
  388. package/src/core/storage/builtins.ts +62 -6
  389. package/src/core/storage/logger.ts +2 -0
  390. package/src/core/storage/query.ts +58 -0
  391. package/src/core/supervisor/activity.ts +193 -0
  392. package/src/core/supervisor/contract.ts +312 -0
  393. package/src/core/supervisor/explanations.ts +104 -0
  394. package/src/core/supervisor/findings.ts +788 -0
  395. package/src/core/supervisor/history.ts +61 -0
  396. package/src/core/supervisor/hook-health-alerts.ts +108 -0
  397. package/src/core/supervisor/hook-health-storage.ts +25 -0
  398. package/src/core/supervisor/hook-health.ts +301 -0
  399. package/src/core/supervisor/hooks.ts +35 -0
  400. package/src/core/supervisor/index.ts +14 -0
  401. package/src/core/supervisor/log-feed.ts +131 -0
  402. package/src/core/supervisor/service.ts +511 -0
  403. package/src/core/supervisor/services.ts +203 -0
  404. package/src/core/supervisor/status.ts +59 -0
  405. package/src/core/supervisor/storage.ts +126 -0
  406. package/src/core/supervisor/timeline.ts +133 -0
  407. package/src/core/workflow/admission.ts +215 -0
  408. package/src/core/workflow/engine.ts +93 -1
  409. package/src/core/workflow/index.ts +10 -0
  410. package/src/core/workflow/proof.ts +54 -1
  411. package/src/core/workflow/run-state.ts +13 -1
  412. package/src/core/workflow/types.ts +39 -1
  413. package/src/lib/admission.ts +347 -0
  414. package/src/lib/agent-browser/client.ts +2 -10
  415. package/src/lib/browser/capture-fidelity.ts +98 -0
  416. package/src/lib/browser/client.ts +212 -10
  417. package/src/lib/browser/critique.ts +62 -7
  418. package/src/lib/browser/index.ts +65 -0
  419. package/src/lib/browser/page-review-judge.ts +360 -0
  420. package/src/lib/browser/page-review-pack.ts +2384 -0
  421. package/src/lib/browser/qa-run-contracts.ts +743 -0
  422. package/src/lib/browser/qa-run.ts +1462 -0
  423. package/src/lib/browser/request-diagnostics.ts +27 -0
  424. package/src/lib/browser/tiling.ts +32 -0
  425. package/src/lib/cookies/client.ts +228 -42
  426. package/src/lib/cookies/extra.ts +28 -0
  427. package/src/lib/cookies/index.ts +2 -0
  428. package/src/lib/coord-root-id.ts +23 -0
  429. package/src/lib/durable-job.ts +407 -0
  430. package/src/lib/http/client.ts +13 -1
  431. package/src/lib/instructions/apply.ts +81 -2
  432. package/src/lib/instructions/templates.ts +11 -2
@@ -0,0 +1,503 @@
1
+ // `qa-run <target>`: run the whole page-QA matrix (planner, deterministic
2
+ // gates, interactions, critique, snapshot) in one command. The agent's loop
3
+ // collapses to: build the job, run this, read page-qa-result.json.
4
+
5
+ import { execFileSync, spawn } from "node:child_process";
6
+ import { randomUUID } from "node:crypto";
7
+ import { closeSync, mkdirSync, openSync, readFileSync, writeFileSync } from "node:fs";
8
+ import { join, resolve } from "node:path";
9
+ import { type Command, Option } from "commander";
10
+ import type { EmitContext, HarneryProgramContext } from "../commander.ts";
11
+ import { recordQaSignal } from "../core/agents/qa-signal.ts";
12
+ import { artifactsRoot } from "../core/artifacts/index.ts";
13
+ import { resolveBinName, reviewPackAutoCleanEnabled } from "../core/config.ts";
14
+ import { createManagedQaOutParent, resolveQaRepoRoot } from "../core/qa-artifacts.ts";
15
+ import { acquireAdmission, admissionBaseDir, admissionStatus } from "../lib/admission.ts";
16
+ import {
17
+ deleteExpiredPacks,
18
+ PAGE_REVIEW_DEFAULT_RETENTION_MINUTES,
19
+ } from "../lib/browser/page-review-pack.ts";
20
+ import {
21
+ QA_RUN_JOB_FILENAME,
22
+ QA_RUN_RESULT_FILENAME,
23
+ QA_RUN_STATUS_FILENAME,
24
+ type QaRunMatrixOptions,
25
+ runQaMatrix,
26
+ } from "../lib/browser/qa-run.ts";
27
+ import {
28
+ QA_RUN_JOB_SCHEMA_VERSION,
29
+ QA_RUN_STATUS_SCHEMA_VERSION,
30
+ type QaRunJob,
31
+ type QaRunStatusDocument,
32
+ validateQaRunJob,
33
+ } from "../lib/browser/qa-run-contracts.ts";
34
+ import { coordEnv } from "../lib/env.ts";
35
+
36
+ /** Machine-wide admission resource that qa-run queues on by default. */
37
+ export const QA_ADMISSION_RESOURCE = "browser-qa";
38
+
39
+ /** Default concurrent browser-QA runs per machine. */
40
+ export const QA_ADMISSION_DEFAULT_CAPACITY = 2;
41
+
42
+ interface QaRunOpts {
43
+ job?: string;
44
+ mode: string;
45
+ concurrency?: string;
46
+ pool?: string;
47
+ allowMetered?: boolean;
48
+ retain?: string;
49
+ outDir?: string;
50
+ json?: boolean;
51
+ detach?: boolean;
52
+ /** Commander --no-queue: true by default, false when the flag is passed. */
53
+ queue: boolean;
54
+ queueTimeout?: string;
55
+ queueCapacity?: string;
56
+ runId?: string;
57
+ }
58
+
59
+ export function registerQaRunCommand(
60
+ program: Command,
61
+ emit: EmitContext,
62
+ context?: HarneryProgramContext,
63
+ ): void {
64
+ program
65
+ .command("qa-run <target>")
66
+ .description(
67
+ "Run the whole page-QA matrix in one command: QA planner, deterministic " +
68
+ "gates per viewport/theme/state through a bounded process pool, serial " +
69
+ "interaction assertions, capture of every context into a page review pack " +
70
+ "(browsers closed), one in-process pool of vision calls over the pack, and the " +
71
+ "QA snapshot. Writes page-qa-result.json with a fail-closed verdict.",
72
+ )
73
+ .option(
74
+ "--job <file>",
75
+ "QA job document (JSON). Validated before any browser starts — secret-bearing " +
76
+ "fields are refused, and the job may widen but never narrow the planner's coverage. " +
77
+ "Absent: a minimal implicit job for <target> is used.",
78
+ )
79
+ .option(
80
+ "--mode <mode>",
81
+ "signoff persists a QA snapshot on a passing run; review never does.",
82
+ "signoff",
83
+ )
84
+ .option(
85
+ "--concurrency <n>",
86
+ "Concurrent deterministic gates and pack captures (1-8; default 2). Interactions " +
87
+ "always run serially; the judge pool is policy.critique_pool / --pool.",
88
+ )
89
+ .option(
90
+ "--pool <n>",
91
+ "Vision calls in flight during the judge stage, across every context (1-16; default: " +
92
+ "the provider's own concurrency). Sets policy.critique_pool.",
93
+ )
94
+ .option(
95
+ "--allow-metered",
96
+ "Permit the critique provider's metered-API fallback. Default: subscription-backed " +
97
+ "headless harnesses only — exhaustion becomes an incomplete blocker, never a metered call.",
98
+ )
99
+ .option(
100
+ "--retain <minutes>",
101
+ `Minutes the run's page review pack lives after the judge finishes before the whole ` +
102
+ `pack is deleted (1-43200; default ${PAGE_REVIEW_DEFAULT_RETENTION_MINUTES}). Sets ` +
103
+ "policy.review_pack_retention_minutes. The result document keeps every finding inline.",
104
+ )
105
+ .option(
106
+ "--out-dir <dir>",
107
+ "PARENT output directory (default: a managed .harnery/artifacts workspace). Every " +
108
+ "invocation writes into its own run-<run_id>/ beneath it and updates the parent's " +
109
+ "latest.json pointer — prior runs are never overwritten and never pass as current.",
110
+ )
111
+ .option("--json", "Print the full QaRunResult JSON to stdout.")
112
+ .option(
113
+ "--detach",
114
+ "Launch the run as a detached background process whose authoritative state " +
115
+ "lives on disk (job.json, run-status.json, runner.log, the result document). " +
116
+ "The command prints the run directory and returns immediately; a client " +
117
+ "disconnect no longer touches the job. Reconnect with qa-status <run-dir> --wait.",
118
+ )
119
+ .option(
120
+ "--no-queue",
121
+ "Skip machine-wide admission control. Default: the run waits for one of the " +
122
+ "browser-qa slots so simultaneous heavy runs take turns instead of thrashing " +
123
+ "the host; the wait is recorded as wall_time_ms.queue, never in total.",
124
+ )
125
+ .option(
126
+ "--queue-timeout <minutes>",
127
+ "Maximum admission wait before the run finalizes incomplete with an " +
128
+ '"admission" blocker (default 20).',
129
+ )
130
+ .option(
131
+ "--queue-capacity <n>",
132
+ "Concurrent browser-qa runs this machine should allow (1-8; default " +
133
+ "HARNERY_QA_ADMISSION_CAPACITY or 2). Advisory — the smallest capacity among " +
134
+ "concurrent waiters effectively governs.",
135
+ )
136
+ .addOption(
137
+ new Option(
138
+ "--run-id <uuid>",
139
+ "Internal: pre-minted run ID (detach child plumbing).",
140
+ ).hideHelp(),
141
+ )
142
+ .addHelpText(
143
+ "after",
144
+ "\nExit codes: 0 verdict passed · 1 usage or job-validation error · " +
145
+ "2 verdict failed · 4 verdict incomplete.",
146
+ )
147
+ .action(async (target: string, opts: QaRunOpts, command: Command) => {
148
+ if (opts.mode !== "signoff" && opts.mode !== "review") {
149
+ emit.error({
150
+ code: "qa_run_invalid_mode",
151
+ message: '--mode must be "signoff" or "review"',
152
+ });
153
+ process.exitCode = 1;
154
+ return;
155
+ }
156
+ const modeExplicit = command.getOptionValueSource("mode") === "cli";
157
+
158
+ let jobDocument: unknown;
159
+ if (opts.job) {
160
+ let rawText: string;
161
+ try {
162
+ rawText = readFileSync(opts.job, "utf8");
163
+ } catch (err: unknown) {
164
+ emit.error({
165
+ code: "qa_run_job_unreadable",
166
+ message: `cannot read --job file ${opts.job}: ${err instanceof Error ? err.message : String(err)}`,
167
+ });
168
+ process.exitCode = 1;
169
+ return;
170
+ }
171
+ let parsed: unknown;
172
+ try {
173
+ parsed = JSON.parse(rawText);
174
+ } catch (err: unknown) {
175
+ emit.error({
176
+ code: "qa_run_job_invalid_json",
177
+ message: `--job file ${opts.job} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`,
178
+ });
179
+ process.exitCode = 1;
180
+ return;
181
+ }
182
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
183
+ const raw = parsed as Record<string, unknown>;
184
+ // The CLI target argument is authoritative; a job file may omit
185
+ // target and mode. An explicit --mode overrides the job's mode.
186
+ jobDocument = {
187
+ ...raw,
188
+ target,
189
+ ...(raw.mode === undefined || modeExplicit ? { mode: opts.mode } : {}),
190
+ };
191
+ } else {
192
+ jobDocument = parsed;
193
+ }
194
+ } else {
195
+ jobDocument = { schema_version: QA_RUN_JOB_SCHEMA_VERSION, target, mode: opts.mode };
196
+ }
197
+
198
+ // All validation errors print at once, before any browser starts.
199
+ const validation = validateQaRunJob(jobDocument);
200
+ if (!validation.ok) {
201
+ for (const message of validation.errors) emit.log(`job: ${message}`, "error");
202
+ emit.error({
203
+ code: "qa_run_invalid_job",
204
+ message: `job validation failed with ${validation.errors.length} error${validation.errors.length === 1 ? "" : "s"}`,
205
+ });
206
+ process.exitCode = 1;
207
+ return;
208
+ }
209
+
210
+ const policy = { ...validation.job.policy };
211
+ if (opts.concurrency !== undefined) {
212
+ const n = Number.parseInt(opts.concurrency, 10);
213
+ if (!Number.isInteger(n) || n < 1 || n > 8) {
214
+ emit.error({
215
+ code: "qa_run_invalid_concurrency",
216
+ message: "--concurrency must be an integer between 1 and 8",
217
+ });
218
+ process.exitCode = 1;
219
+ return;
220
+ }
221
+ policy.command_concurrency = n;
222
+ }
223
+ if (opts.pool !== undefined) {
224
+ const n = Number.parseInt(opts.pool, 10);
225
+ if (!Number.isInteger(n) || n < 1 || n > 16) {
226
+ emit.error({
227
+ code: "qa_run_invalid_pool",
228
+ message: "--pool must be an integer between 1 and 16",
229
+ });
230
+ process.exitCode = 1;
231
+ return;
232
+ }
233
+ policy.critique_pool = n;
234
+ }
235
+ if (opts.allowMetered) policy.allow_metered_critique = true;
236
+ if (opts.retain !== undefined) {
237
+ const n = Number.parseInt(opts.retain, 10);
238
+ if (!Number.isInteger(n) || n < 1 || n > 43_200) {
239
+ emit.error({
240
+ code: "qa_run_invalid_retain",
241
+ message: "--retain must be an integer between 1 and 43200 (minutes)",
242
+ });
243
+ process.exitCode = 1;
244
+ return;
245
+ }
246
+ policy.review_pack_retention_minutes = n;
247
+ }
248
+ const job: QaRunJob = { ...validation.job, policy };
249
+
250
+ const repoRoot = resolveQaRepoRoot(context);
251
+ // Expired packs in the store go before this run adds one; opt-in via
252
+ // review_pack.auto_clean. Only managed, expired packs are deleted.
253
+ if (reviewPackAutoCleanEnabled(repoRoot)) {
254
+ try {
255
+ const swept = deleteExpiredPacks({ roots: [artifactsRoot(repoRoot)], dryRun: false });
256
+ if (swept.deleted.length > 0) {
257
+ emit.log(
258
+ `removed ${swept.deleted.length} expired page review pack${swept.deleted.length === 1 ? "" : "s"}`,
259
+ "info",
260
+ );
261
+ }
262
+ } catch (err: unknown) {
263
+ emit.log(
264
+ `expired pack sweep skipped: ${err instanceof Error ? err.message : String(err)}`,
265
+ "warn",
266
+ );
267
+ }
268
+ }
269
+
270
+ let outParent: string;
271
+ try {
272
+ outParent =
273
+ opts.outDir !== undefined
274
+ ? resolve(opts.outDir)
275
+ : createManagedQaOutParent(repoRoot, "qa-run");
276
+ } catch (err: unknown) {
277
+ emit.error({
278
+ code: "qa_run_output_unavailable",
279
+ message: `cannot create managed QA output: ${err instanceof Error ? err.message : String(err)}`,
280
+ });
281
+ process.exitCode = 1;
282
+ return;
283
+ }
284
+ const cliScript = process.argv[1];
285
+ if (!cliScript) {
286
+ emit.error({
287
+ code: "qa_run_no_cli_script",
288
+ message: "cannot resolve the host CLI script path for child browse invocations",
289
+ });
290
+ process.exitCode = 1;
291
+ return;
292
+ }
293
+ // Children run the same host CLI, so they inherit the host's browse
294
+ // wiring (critique provider, cookie jar, profiles) unchanged.
295
+ const browseArgv = [process.execPath, cliScript, "browse"];
296
+
297
+ // ----------------------------------------------------- queue settings
298
+ let queueCapacity = QA_ADMISSION_DEFAULT_CAPACITY;
299
+ const capacityEnv = coordEnv("QA_ADMISSION_CAPACITY");
300
+ if (capacityEnv !== undefined) {
301
+ const n = Number.parseInt(capacityEnv, 10);
302
+ if (Number.isInteger(n) && n >= 1 && n <= 8) queueCapacity = n;
303
+ }
304
+ if (opts.queueCapacity !== undefined) {
305
+ const n = Number.parseInt(opts.queueCapacity, 10);
306
+ if (!Number.isInteger(n) || n < 1 || n > 8) {
307
+ emit.error({
308
+ code: "qa_run_invalid_queue_capacity",
309
+ message: "--queue-capacity must be an integer between 1 and 8",
310
+ });
311
+ process.exitCode = 1;
312
+ return;
313
+ }
314
+ queueCapacity = n;
315
+ }
316
+ let queueTimeoutMs = 20 * 60_000;
317
+ if (opts.queueTimeout !== undefined) {
318
+ const n = Number.parseInt(opts.queueTimeout, 10);
319
+ if (!Number.isInteger(n) || n < 1 || n > 240) {
320
+ emit.error({
321
+ code: "qa_run_invalid_queue_timeout",
322
+ message: "--queue-timeout must be an integer between 1 and 240 (minutes)",
323
+ });
324
+ process.exitCode = 1;
325
+ return;
326
+ }
327
+ queueTimeoutMs = n * 60_000;
328
+ }
329
+
330
+ // ------------------------------------------------------------- detach
331
+ if (opts.detach) {
332
+ const runId = randomUUID();
333
+ const runDir = join(outParent, `run-${runId}`);
334
+ mkdirSync(runDir, { recursive: true });
335
+ writeFileSync(join(runDir, QA_RUN_JOB_FILENAME), `${JSON.stringify(job, null, 2)}\n`);
336
+ const logPath = join(runDir, "runner.log");
337
+ const logFd = openSync(logPath, "a");
338
+ // The child is this same command minus --detach plus the pre-minted
339
+ // run ID, detached from the terminal with its output on disk: a
340
+ // client disconnect kills nothing and loses nothing.
341
+ const childArgv = [
342
+ cliScript,
343
+ "qa-run",
344
+ target,
345
+ ...(opts.job ? ["--job", resolve(opts.job)] : []),
346
+ "--mode",
347
+ job.mode,
348
+ ...(opts.concurrency !== undefined ? ["--concurrency", opts.concurrency] : []),
349
+ ...(opts.pool !== undefined ? ["--pool", opts.pool] : []),
350
+ ...(opts.allowMetered ? ["--allow-metered"] : []),
351
+ ...(opts.retain !== undefined ? ["--retain", opts.retain] : []),
352
+ "--out-dir",
353
+ outParent,
354
+ "--run-id",
355
+ runId,
356
+ ...(opts.queue === false ? ["--no-queue"] : []),
357
+ ...(opts.queueTimeout !== undefined ? ["--queue-timeout", opts.queueTimeout] : []),
358
+ ...(opts.queueCapacity !== undefined ? ["--queue-capacity", opts.queueCapacity] : []),
359
+ ];
360
+ const child = spawn(process.execPath, childArgv, {
361
+ detached: true,
362
+ stdio: ["ignore", logFd, logFd],
363
+ });
364
+ child.unref();
365
+ closeSync(logFd);
366
+ const launching: QaRunStatusDocument = {
367
+ schema_version: QA_RUN_STATUS_SCHEMA_VERSION,
368
+ run_id: runId,
369
+ pid: child.pid ?? 0,
370
+ state: "launching",
371
+ stage: null,
372
+ started_at: new Date().toISOString(),
373
+ updated_at: new Date().toISOString(),
374
+ };
375
+ writeFileSync(
376
+ join(runDir, QA_RUN_STATUS_FILENAME),
377
+ `${JSON.stringify(launching, null, 2)}\n`,
378
+ );
379
+ const binName = resolveBinName();
380
+ emit.log(`detached run ${runId} (pid ${child.pid ?? "unknown"})`, "info");
381
+ emit.log(`run dir: ${runDir}`, "info");
382
+ emit.log(`log: ${logPath}`, "info");
383
+ emit.log(`reconnect: ${binName} qa-status ${runDir} --wait`, "info");
384
+ if (opts.json) {
385
+ emit.data({
386
+ detached: true,
387
+ run_id: runId,
388
+ pid: child.pid ?? null,
389
+ run_dir: runDir,
390
+ log: logPath,
391
+ });
392
+ }
393
+ return;
394
+ }
395
+
396
+ // ---------------------------------------------------------- admission
397
+ let admission: QaRunMatrixOptions["admission"];
398
+ if (opts.queue !== false) {
399
+ const dir = admissionBaseDir();
400
+ admission = {
401
+ resource: QA_ADMISSION_RESOURCE,
402
+ acquire: async (onWait) => {
403
+ let lastMessage = "";
404
+ const handle = await acquireAdmission(
405
+ { dir, resource: QA_ADMISSION_RESOURCE, capacity: queueCapacity },
406
+ {
407
+ label: `qa-run ${target}`,
408
+ timeoutMs: queueTimeoutMs,
409
+ onWait: (info) => {
410
+ const holders = info.holders.map((holder) => holder.label).join(", ") || "none";
411
+ const message =
412
+ `queued for a ${QA_ADMISSION_RESOURCE} slot: position ${info.position}, ` +
413
+ `capacity ${queueCapacity}, holder(s): ${holders}`;
414
+ if (message !== lastMessage) {
415
+ lastMessage = message;
416
+ onWait(message);
417
+ }
418
+ },
419
+ },
420
+ );
421
+ return handle.release;
422
+ },
423
+ holders: () =>
424
+ admissionStatus({ dir, resource: QA_ADMISSION_RESOURCE }).holders.map((holder) => ({
425
+ label: holder.label,
426
+ pid: holder.pid,
427
+ })),
428
+ };
429
+ }
430
+
431
+ // One git probe for the identity block. Failure is not an error: a
432
+ // target outside any repository legitimately records "unknown".
433
+ let revisionProbe: { tested_revision?: string; worktree_dirty?: boolean } | undefined;
434
+ if (job.tested_revision === undefined) {
435
+ try {
436
+ const head = execFileSync("git", ["rev-parse", "HEAD"], {
437
+ encoding: "utf8",
438
+ stdio: ["ignore", "pipe", "ignore"],
439
+ }).trim();
440
+ const porcelain = execFileSync("git", ["status", "--porcelain"], {
441
+ encoding: "utf8",
442
+ stdio: ["ignore", "pipe", "ignore"],
443
+ });
444
+ revisionProbe = { tested_revision: head, worktree_dirty: porcelain.trim().length > 0 };
445
+ } catch {
446
+ revisionProbe = undefined;
447
+ }
448
+ }
449
+
450
+ const binName = resolveBinName();
451
+ const result = await runQaMatrix({
452
+ job,
453
+ outParent,
454
+ browseArgv,
455
+ ...(opts.runId !== undefined ? { runId: opts.runId } : {}),
456
+ ...(revisionProbe ? { revisionProbe } : {}),
457
+ ...(admission ? { admission } : {}),
458
+ // The judge runs in this process: the host's provider is loaded here,
459
+ // after the headless-only policy has been applied to the environment.
460
+ ...(context?.critiqueProvider ? { critiqueProvider: context.critiqueProvider } : {}),
461
+ ...(context?.critiqueProviderLoader
462
+ ? { critiqueProviderLoader: context.critiqueProviderLoader }
463
+ : {}),
464
+ reviewPackJudgeCommand: (packDir) => `${binName} review-pack judge ${packDir}`,
465
+ // A pack in the managed store expires and is deleted; one under an
466
+ // explicit --out-dir is the caller's and is never swept automatically.
467
+ reviewPackManaged: opts.outDir === undefined,
468
+ onLog: (message) => emit.log(message, "info"),
469
+ });
470
+
471
+ // Publish the verdict for `agents status`, so an operator reading a
472
+ // session sees the runner clock instead of inferring QA time from
473
+ // session age. Best-effort by contract: never throws.
474
+ recordQaSignal(result);
475
+
476
+ if (opts.json) emit.data(result);
477
+ const resultPath = join(result.run.out_dir, QA_RUN_RESULT_FILENAME);
478
+ for (const blocker of result.blockers) {
479
+ emit.log(
480
+ `blocker [${blocker.stage}${blocker.context_id ? ` ${blocker.context_id}` : ""}]: ${blocker.reason}`,
481
+ "warn",
482
+ );
483
+ }
484
+ if (result.review_pack) {
485
+ emit.log(
486
+ `review pack: ${result.review_pack.review}` +
487
+ (result.review_pack.expires_at
488
+ ? ` (deleted after ${result.review_pack.expires_at})`
489
+ : ""),
490
+ "info",
491
+ );
492
+ }
493
+ emit.log(
494
+ `verdict: ${result.verdict} — run ${result.run.run_id}, ` +
495
+ `${result.contexts.length} context${result.contexts.length === 1 ? "" : "s"}, ` +
496
+ `${result.commands.length} command${result.commands.length === 1 ? "" : "s"}, ` +
497
+ `${result.blockers.length} blocker${result.blockers.length === 1 ? "" : "s"}; result: ${resultPath}`,
498
+ result.verdict === "passed" ? "info" : "warn",
499
+ );
500
+ if (result.verdict === "failed") process.exitCode = 2;
501
+ else if (result.verdict === "incomplete") process.exitCode = 4;
502
+ });
503
+ }