@telora/daemon 0.22.104 → 0.22.131

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 (478) hide show
  1. package/build-info.json +4 -3
  2. package/dist/completion/commit-verdict-release.d.ts +49 -0
  3. package/dist/completion/commit-verdict-release.d.ts.map +1 -0
  4. package/dist/completion/commit-verdict-release.js +240 -0
  5. package/dist/completion/commit-verdict-release.js.map +1 -0
  6. package/dist/completion/completion-phase-registry.d.ts +10 -4
  7. package/dist/completion/completion-phase-registry.d.ts.map +1 -1
  8. package/dist/completion/completion-phase-registry.js +19 -7
  9. package/dist/completion/completion-phase-registry.js.map +1 -1
  10. package/dist/completion/detector.d.ts.map +1 -1
  11. package/dist/completion/detector.js +1 -0
  12. package/dist/completion/detector.js.map +1 -1
  13. package/dist/completion/event-entry-phases.d.ts +6 -3
  14. package/dist/completion/event-entry-phases.d.ts.map +1 -1
  15. package/dist/completion/event-entry-phases.js +135 -76
  16. package/dist/completion/event-entry-phases.js.map +1 -1
  17. package/dist/completion/event-phases.d.ts +24 -3
  18. package/dist/completion/event-phases.d.ts.map +1 -1
  19. package/dist/completion/event-phases.js +9 -9
  20. package/dist/completion/event-phases.js.map +1 -1
  21. package/dist/completion/event.d.ts +8 -0
  22. package/dist/completion/event.d.ts.map +1 -1
  23. package/dist/completion/event.js +47 -21
  24. package/dist/completion/event.js.map +1 -1
  25. package/dist/completion/exit-classification.d.ts.map +1 -1
  26. package/dist/completion/exit-classification.js +1 -0
  27. package/dist/completion/exit-classification.js.map +1 -1
  28. package/dist/completion/merge-phase.d.ts +21 -9
  29. package/dist/completion/merge-phase.d.ts.map +1 -1
  30. package/dist/completion/merge-phase.js +35 -10
  31. package/dist/completion/merge-phase.js.map +1 -1
  32. package/dist/completion/review-auto-approval-record.d.ts +19 -0
  33. package/dist/completion/review-auto-approval-record.d.ts.map +1 -0
  34. package/dist/completion/review-auto-approval-record.js +102 -0
  35. package/dist/completion/review-auto-approval-record.js.map +1 -0
  36. package/dist/completion/review-cycle-cap.d.ts +62 -0
  37. package/dist/completion/review-cycle-cap.d.ts.map +1 -0
  38. package/dist/completion/review-cycle-cap.js +180 -0
  39. package/dist/completion/review-cycle-cap.js.map +1 -0
  40. package/dist/completion/review-exit-deps.d.ts +17 -2
  41. package/dist/completion/review-exit-deps.d.ts.map +1 -1
  42. package/dist/completion/review-exit-deps.js +19 -2
  43. package/dist/completion/review-exit-deps.js.map +1 -1
  44. package/dist/completion/review-exit-escalations.d.ts +45 -23
  45. package/dist/completion/review-exit-escalations.d.ts.map +1 -1
  46. package/dist/completion/review-exit-escalations.js +15 -74
  47. package/dist/completion/review-exit-escalations.js.map +1 -1
  48. package/dist/completion/review-exit-evidence.d.ts +9 -0
  49. package/dist/completion/review-exit-evidence.d.ts.map +1 -1
  50. package/dist/completion/review-exit-evidence.js +4 -1
  51. package/dist/completion/review-exit-evidence.js.map +1 -1
  52. package/dist/completion/review-exit-foreign-findings.d.ts +151 -0
  53. package/dist/completion/review-exit-foreign-findings.d.ts.map +1 -0
  54. package/dist/completion/review-exit-foreign-findings.js +474 -0
  55. package/dist/completion/review-exit-foreign-findings.js.map +1 -0
  56. package/dist/completion/review-exit-phase.d.ts.map +1 -1
  57. package/dist/completion/review-exit-phase.js +71 -64
  58. package/dist/completion/review-exit-phase.js.map +1 -1
  59. package/dist/completion/review-exit-progress.d.ts +20 -0
  60. package/dist/completion/review-exit-progress.d.ts.map +1 -1
  61. package/dist/completion/review-exit-progress.js +28 -19
  62. package/dist/completion/review-exit-progress.js.map +1 -1
  63. package/dist/completion/review-exit-rehoming.d.ts +5 -0
  64. package/dist/completion/review-exit-rehoming.d.ts.map +1 -1
  65. package/dist/completion/review-exit-rehoming.js.map +1 -1
  66. package/dist/completion/review-exit-verdict-gate.d.ts +202 -0
  67. package/dist/completion/review-exit-verdict-gate.d.ts.map +1 -0
  68. package/dist/completion/review-exit-verdict-gate.js +228 -0
  69. package/dist/completion/review-exit-verdict-gate.js.map +1 -0
  70. package/dist/completion/review-next-step.d.ts +62 -0
  71. package/dist/completion/review-next-step.d.ts.map +1 -0
  72. package/dist/completion/review-next-step.js +63 -0
  73. package/dist/completion/review-next-step.js.map +1 -0
  74. package/dist/completion/session-hold-sweep-deps.d.ts +17 -0
  75. package/dist/completion/session-hold-sweep-deps.d.ts.map +1 -0
  76. package/dist/completion/session-hold-sweep-deps.js +89 -0
  77. package/dist/completion/session-hold-sweep-deps.js.map +1 -0
  78. package/dist/completion/session-hold.d.ts +180 -0
  79. package/dist/completion/session-hold.d.ts.map +1 -0
  80. package/dist/completion/session-hold.js +238 -0
  81. package/dist/completion/session-hold.js.map +1 -0
  82. package/dist/completion/state-cascade.d.ts +19 -0
  83. package/dist/completion/state-cascade.d.ts.map +1 -1
  84. package/dist/completion/state-cascade.js +85 -31
  85. package/dist/completion/state-cascade.js.map +1 -1
  86. package/dist/completion/team-lifecycle.d.ts +35 -2
  87. package/dist/completion/team-lifecycle.d.ts.map +1 -1
  88. package/dist/completion/team-lifecycle.js +165 -94
  89. package/dist/completion/team-lifecycle.js.map +1 -1
  90. package/dist/completion/team-phase.d.ts +27 -15
  91. package/dist/completion/team-phase.d.ts.map +1 -1
  92. package/dist/completion/team-phase.js +34 -15
  93. package/dist/completion/team-phase.js.map +1 -1
  94. package/dist/delivery/commit-verdict-hold.d.ts +55 -0
  95. package/dist/delivery/commit-verdict-hold.d.ts.map +1 -0
  96. package/dist/delivery/commit-verdict-hold.js +118 -0
  97. package/dist/delivery/commit-verdict-hold.js.map +1 -0
  98. package/dist/directive/directive-dispatch.d.ts.map +1 -1
  99. package/dist/directive/directive-dispatch.js +10 -3
  100. package/dist/directive/directive-dispatch.js.map +1 -1
  101. package/dist/directive/directive-executor.d.ts.map +1 -1
  102. package/dist/directive/directive-executor.js +1 -0
  103. package/dist/directive/directive-executor.js.map +1 -1
  104. package/dist/directive/directive-queue.d.ts.map +1 -1
  105. package/dist/directive/directive-queue.js +6 -1
  106. package/dist/directive/directive-queue.js.map +1 -1
  107. package/dist/directive/phase-sync.d.ts +29 -2
  108. package/dist/directive/phase-sync.d.ts.map +1 -1
  109. package/dist/directive/phase-sync.js +30 -6
  110. package/dist/directive/phase-sync.js.map +1 -1
  111. package/dist/drift/artifact-ref-shape.d.ts +34 -0
  112. package/dist/drift/artifact-ref-shape.d.ts.map +1 -0
  113. package/dist/drift/artifact-ref-shape.js +94 -0
  114. package/dist/drift/artifact-ref-shape.js.map +1 -0
  115. package/dist/drift/drift-eval-loop.d.ts +7 -0
  116. package/dist/drift/drift-eval-loop.d.ts.map +1 -1
  117. package/dist/drift/drift-eval-loop.js +34 -5
  118. package/dist/drift/drift-eval-loop.js.map +1 -1
  119. package/dist/drift/drift-evaluator.d.ts.map +1 -1
  120. package/dist/drift/drift-evaluator.js +8 -3
  121. package/dist/drift/drift-evaluator.js.map +1 -1
  122. package/dist/focus/awaiting-slot.d.ts +34 -0
  123. package/dist/focus/awaiting-slot.d.ts.map +1 -0
  124. package/dist/focus/awaiting-slot.js +26 -0
  125. package/dist/focus/awaiting-slot.js.map +1 -0
  126. package/dist/focus/focus-lifecycle.js +2 -2
  127. package/dist/focus/focus-lifecycle.js.map +1 -1
  128. package/dist/focus/focus-phase.d.ts.map +1 -1
  129. package/dist/focus/focus-phase.js +3 -1
  130. package/dist/focus/focus-phase.js.map +1 -1
  131. package/dist/focus/focus-spawn-decision.d.ts +62 -0
  132. package/dist/focus/focus-spawn-decision.d.ts.map +1 -0
  133. package/dist/focus/focus-spawn-decision.js +41 -0
  134. package/dist/focus/focus-spawn-decision.js.map +1 -0
  135. package/dist/focus/focus-team-state.d.ts.map +1 -1
  136. package/dist/focus/focus-team-state.js +1 -13
  137. package/dist/focus/focus-team-state.js.map +1 -1
  138. package/dist/focus/listener-spawn.d.ts +16 -55
  139. package/dist/focus/listener-spawn.d.ts.map +1 -1
  140. package/dist/focus/listener-spawn.js +102 -64
  141. package/dist/focus/listener-spawn.js.map +1 -1
  142. package/dist/focus/listener-state.d.ts.map +1 -1
  143. package/dist/focus/listener-state.js +4 -1
  144. package/dist/focus/listener-state.js.map +1 -1
  145. package/dist/focus/listener.d.ts +41 -2
  146. package/dist/focus/listener.d.ts.map +1 -1
  147. package/dist/focus/listener.js +135 -83
  148. package/dist/focus/listener.js.map +1 -1
  149. package/dist/focus/pending-spawn-pass-deps.d.ts +69 -0
  150. package/dist/focus/pending-spawn-pass-deps.d.ts.map +1 -0
  151. package/dist/focus/pending-spawn-pass-deps.js +34 -0
  152. package/dist/focus/pending-spawn-pass-deps.js.map +1 -0
  153. package/dist/focus/pending-spawn-review-next-step.d.ts +83 -0
  154. package/dist/focus/pending-spawn-review-next-step.d.ts.map +1 -0
  155. package/dist/focus/pending-spawn-review-next-step.js +325 -0
  156. package/dist/focus/pending-spawn-review-next-step.js.map +1 -0
  157. package/dist/focus/review-cycle-cap-hold.d.ts +132 -0
  158. package/dist/focus/review-cycle-cap-hold.d.ts.map +1 -0
  159. package/dist/focus/review-cycle-cap-hold.js +178 -0
  160. package/dist/focus/review-cycle-cap-hold.js.map +1 -0
  161. package/dist/focus/team-actionable-work.js +2 -2
  162. package/dist/focus/verify-open-issues.d.ts +22 -0
  163. package/dist/focus/verify-open-issues.d.ts.map +1 -1
  164. package/dist/focus/verify-open-issues.js +118 -57
  165. package/dist/focus/verify-open-issues.js.map +1 -1
  166. package/dist/focus/verify-routing-passes.d.ts +32 -0
  167. package/dist/focus/verify-routing-passes.d.ts.map +1 -0
  168. package/dist/focus/verify-routing-passes.js +18 -0
  169. package/dist/focus/verify-routing-passes.js.map +1 -0
  170. package/dist/git/index.d.ts.map +1 -1
  171. package/dist/git/index.js +9 -5
  172. package/dist/git/index.js.map +1 -1
  173. package/dist/merge/focus-merge.d.ts +16 -2
  174. package/dist/merge/focus-merge.d.ts.map +1 -1
  175. package/dist/merge/focus-merge.js +53 -30
  176. package/dist/merge/focus-merge.js.map +1 -1
  177. package/dist/merge/merge-back-loop.d.ts +5 -0
  178. package/dist/merge/merge-back-loop.d.ts.map +1 -1
  179. package/dist/merge/merge-back-loop.js +17 -8
  180. package/dist/merge/merge-back-loop.js.map +1 -1
  181. package/dist/merge/merge-gate-coverage.d.ts +94 -0
  182. package/dist/merge/merge-gate-coverage.d.ts.map +1 -0
  183. package/dist/merge/merge-gate-coverage.js +217 -0
  184. package/dist/merge/merge-gate-coverage.js.map +1 -0
  185. package/dist/prompt/focus-prompt-builder.d.ts.map +1 -1
  186. package/dist/prompt/focus-prompt-builder.js +6 -0
  187. package/dist/prompt/focus-prompt-builder.js.map +1 -1
  188. package/dist/prompt/prompt-listing.d.ts.map +1 -1
  189. package/dist/prompt/prompt-listing.js +8 -0
  190. package/dist/prompt/prompt-listing.js.map +1 -1
  191. package/dist/prompt/team-prompt-base.d.ts.map +1 -1
  192. package/dist/prompt/team-prompt-base.js +5 -1
  193. package/dist/prompt/team-prompt-base.js.map +1 -1
  194. package/dist/prompt-sections/execution-sections.d.ts.map +1 -1
  195. package/dist/prompt-sections/execution-sections.js +14 -39
  196. package/dist/prompt-sections/execution-sections.js.map +1 -1
  197. package/dist/prompt-sections/gate-ownership.d.ts +36 -0
  198. package/dist/prompt-sections/gate-ownership.d.ts.map +1 -0
  199. package/dist/prompt-sections/gate-ownership.js +68 -0
  200. package/dist/prompt-sections/gate-ownership.js.map +1 -0
  201. package/dist/prompt-sections/gate-verdict-section.d.ts +58 -0
  202. package/dist/prompt-sections/gate-verdict-section.d.ts.map +1 -0
  203. package/dist/prompt-sections/gate-verdict-section.js +88 -0
  204. package/dist/prompt-sections/gate-verdict-section.js.map +1 -0
  205. package/dist/prompt-sections/persona-sections.d.ts +10 -0
  206. package/dist/prompt-sections/persona-sections.d.ts.map +1 -1
  207. package/dist/prompt-sections/persona-sections.js +35 -11
  208. package/dist/prompt-sections/persona-sections.js.map +1 -1
  209. package/dist/prompt-sections/shared.js +1 -1
  210. package/dist/prompt-sections/shared.js.map +1 -1
  211. package/dist/queries/agent-resolvable-promotion.d.ts +6 -3
  212. package/dist/queries/agent-resolvable-promotion.d.ts.map +1 -1
  213. package/dist/queries/agent-resolvable-promotion.js +20 -9
  214. package/dist/queries/agent-resolvable-promotion.js.map +1 -1
  215. package/dist/queries/deliveries.d.ts +46 -4
  216. package/dist/queries/deliveries.d.ts.map +1 -1
  217. package/dist/queries/deliveries.js +69 -16
  218. package/dist/queries/deliveries.js.map +1 -1
  219. package/dist/queries/delivery-gate-state.d.ts +151 -1
  220. package/dist/queries/delivery-gate-state.d.ts.map +1 -1
  221. package/dist/queries/delivery-gate-state.js +95 -14
  222. package/dist/queries/delivery-gate-state.js.map +1 -1
  223. package/dist/queries/delivery-write-discipline.d.ts +65 -0
  224. package/dist/queries/delivery-write-discipline.d.ts.map +1 -0
  225. package/dist/queries/delivery-write-discipline.js +101 -0
  226. package/dist/queries/delivery-write-discipline.js.map +1 -0
  227. package/dist/queries/escalation-consumption.d.ts +11 -0
  228. package/dist/queries/escalation-consumption.d.ts.map +1 -1
  229. package/dist/queries/escalation-consumption.js +22 -0
  230. package/dist/queries/escalation-consumption.js.map +1 -1
  231. package/dist/queries/escalation-spool.d.ts +75 -0
  232. package/dist/queries/escalation-spool.d.ts.map +1 -0
  233. package/dist/queries/escalation-spool.js +232 -0
  234. package/dist/queries/escalation-spool.js.map +1 -0
  235. package/dist/queries/escalation-suppression.d.ts.map +1 -1
  236. package/dist/queries/escalation-suppression.js +2 -0
  237. package/dist/queries/escalation-suppression.js.map +1 -1
  238. package/dist/queries/escalations.js +1 -1
  239. package/dist/queries/filing-observation.d.ts.map +1 -1
  240. package/dist/queries/filing-observation.js +2 -0
  241. package/dist/queries/filing-observation.js.map +1 -1
  242. package/dist/queries/focus-discovery.d.ts +4 -4
  243. package/dist/queries/focus-discovery.d.ts.map +1 -1
  244. package/dist/queries/focus-discovery.js +1 -0
  245. package/dist/queries/focus-discovery.js.map +1 -1
  246. package/dist/queries/focus-review-approval.d.ts +84 -0
  247. package/dist/queries/focus-review-approval.d.ts.map +1 -0
  248. package/dist/queries/focus-review-approval.js +158 -0
  249. package/dist/queries/focus-review-approval.js.map +1 -0
  250. package/dist/queries/focuses.d.ts +6 -5
  251. package/dist/queries/focuses.d.ts.map +1 -1
  252. package/dist/queries/focuses.js +9 -5
  253. package/dist/queries/focuses.js.map +1 -1
  254. package/dist/queries/incident-correlation.d.ts +5 -4
  255. package/dist/queries/incident-correlation.d.ts.map +1 -1
  256. package/dist/queries/incident-correlation.js +11 -5
  257. package/dist/queries/incident-correlation.js.map +1 -1
  258. package/dist/queries/issues.d.ts.map +1 -1
  259. package/dist/queries/issues.js +2 -1
  260. package/dist/queries/issues.js.map +1 -1
  261. package/dist/queries/loop-refusal-observation.d.ts +64 -0
  262. package/dist/queries/loop-refusal-observation.d.ts.map +1 -0
  263. package/dist/queries/loop-refusal-observation.js +137 -0
  264. package/dist/queries/loop-refusal-observation.js.map +1 -0
  265. package/dist/queries/schemas.d.ts +9 -0
  266. package/dist/queries/schemas.d.ts.map +1 -1
  267. package/dist/queries/schemas.js +11 -3
  268. package/dist/queries/schemas.js.map +1 -1
  269. package/dist/queries/shared.js +1 -1
  270. package/dist/queries/verification.d.ts.map +1 -1
  271. package/dist/queries/verification.js +1 -15
  272. package/dist/queries/verification.js.map +1 -1
  273. package/dist/queries/wire-contract.generated.d.ts +3 -0
  274. package/dist/queries/wire-contract.generated.d.ts.map +1 -1
  275. package/dist/queries/wire-contract.generated.js +3 -0
  276. package/dist/queries/wire-contract.generated.js.map +1 -1
  277. package/dist/resolvers/assembly-engine.d.ts.map +1 -1
  278. package/dist/resolvers/assembly-engine.js +3 -1
  279. package/dist/resolvers/assembly-engine.js.map +1 -1
  280. package/dist/resolvers/git-diff-against-base.d.ts +5 -2
  281. package/dist/resolvers/git-diff-against-base.d.ts.map +1 -1
  282. package/dist/resolvers/git-diff-against-base.js +121 -39
  283. package/dist/resolvers/git-diff-against-base.js.map +1 -1
  284. package/dist/resolvers/shared/git-diff.d.ts +2 -0
  285. package/dist/resolvers/shared/git-diff.d.ts.map +1 -1
  286. package/dist/resolvers/shared/git-diff.js +5 -1
  287. package/dist/resolvers/shared/git-diff.js.map +1 -1
  288. package/dist/resolvers/shared/review-window-commits.d.ts +96 -0
  289. package/dist/resolvers/shared/review-window-commits.d.ts.map +1 -0
  290. package/dist/resolvers/shared/review-window-commits.js +262 -0
  291. package/dist/resolvers/shared/review-window-commits.js.map +1 -0
  292. package/dist/session/session-lineage.d.ts.map +1 -1
  293. package/dist/session/session-lineage.js +4 -1
  294. package/dist/session/session-lineage.js.map +1 -1
  295. package/dist/shell/fail-stop.d.ts +18 -0
  296. package/dist/shell/fail-stop.d.ts.map +1 -0
  297. package/dist/shell/fail-stop.js +53 -0
  298. package/dist/shell/fail-stop.js.map +1 -0
  299. package/dist/shell/graceful-shutdown.d.ts +48 -0
  300. package/dist/shell/graceful-shutdown.d.ts.map +1 -0
  301. package/dist/shell/graceful-shutdown.js +152 -0
  302. package/dist/shell/graceful-shutdown.js.map +1 -0
  303. package/dist/shell/heartbeat.d.ts.map +1 -1
  304. package/dist/shell/heartbeat.js +5 -4
  305. package/dist/shell/heartbeat.js.map +1 -1
  306. package/dist/shell/log.d.ts.map +1 -1
  307. package/dist/shell/log.js +4 -1
  308. package/dist/shell/log.js.map +1 -1
  309. package/dist/shell/stop-request.d.ts.map +1 -1
  310. package/dist/shell/stop-request.js +2 -1
  311. package/dist/shell/stop-request.js.map +1 -1
  312. package/dist/shell/unified-shell.d.ts.map +1 -1
  313. package/dist/shell/unified-shell.js +41 -114
  314. package/dist/shell/unified-shell.js.map +1 -1
  315. package/dist/spawn/lifecycle.d.ts +12 -0
  316. package/dist/spawn/lifecycle.d.ts.map +1 -1
  317. package/dist/spawn/lifecycle.js +25 -21
  318. package/dist/spawn/lifecycle.js.map +1 -1
  319. package/dist/spawn/prompt-assembly.d.ts +19 -1
  320. package/dist/spawn/prompt-assembly.d.ts.map +1 -1
  321. package/dist/spawn/prompt-assembly.js +70 -21
  322. package/dist/spawn/prompt-assembly.js.map +1 -1
  323. package/dist/spawn/review-hold-park.d.ts.map +1 -1
  324. package/dist/spawn/review-hold-park.js +18 -8
  325. package/dist/spawn/review-hold-park.js.map +1 -1
  326. package/dist/spawn/spawn-cooldown.d.ts.map +1 -1
  327. package/dist/spawn/spawn-cooldown.js +4 -0
  328. package/dist/spawn/spawn-cooldown.js.map +1 -1
  329. package/dist/spawn/spawn-decision.d.ts.map +1 -1
  330. package/dist/spawn/spawn-decision.js +2 -1
  331. package/dist/spawn/spawn-decision.js.map +1 -1
  332. package/dist/spawn/worktree-session.d.ts +6 -0
  333. package/dist/spawn/worktree-session.d.ts.map +1 -1
  334. package/dist/spawn/worktree-session.js +15 -2
  335. package/dist/spawn/worktree-session.js.map +1 -1
  336. package/dist/testing/fixtures/index.d.ts +10 -1
  337. package/dist/testing/fixtures/index.d.ts.map +1 -1
  338. package/dist/testing/fixtures/index.js +59 -1
  339. package/dist/testing/fixtures/index.js.map +1 -1
  340. package/dist/testing/fixtures/pending-spawn-world.d.ts +34 -0
  341. package/dist/testing/fixtures/pending-spawn-world.d.ts.map +1 -0
  342. package/dist/testing/fixtures/pending-spawn-world.js +92 -0
  343. package/dist/testing/fixtures/pending-spawn-world.js.map +1 -0
  344. package/dist/types/index.js +1 -1
  345. package/dist/verify/commit-gate-configured.d.ts +86 -0
  346. package/dist/verify/commit-gate-configured.d.ts.map +1 -0
  347. package/dist/verify/commit-gate-configured.js +234 -0
  348. package/dist/verify/commit-gate-configured.js.map +1 -0
  349. package/dist/verify/commit-verdict-record.d.ts +98 -0
  350. package/dist/verify/commit-verdict-record.d.ts.map +1 -0
  351. package/dist/verify/commit-verdict-record.js +297 -0
  352. package/dist/verify/commit-verdict-record.js.map +1 -0
  353. package/dist/verify/explicit-gate-outcome.d.ts +161 -0
  354. package/dist/verify/explicit-gate-outcome.d.ts.map +1 -0
  355. package/dist/verify/explicit-gate-outcome.js +215 -0
  356. package/dist/verify/explicit-gate-outcome.js.map +1 -0
  357. package/dist/verify/explicit-rearm.d.ts +27 -0
  358. package/dist/verify/explicit-rearm.d.ts.map +1 -0
  359. package/dist/verify/explicit-rearm.js +161 -0
  360. package/dist/verify/explicit-rearm.js.map +1 -0
  361. package/dist/verify/explicit-run-ledger.d.ts +26 -0
  362. package/dist/verify/explicit-run-ledger.d.ts.map +1 -0
  363. package/dist/verify/explicit-run-ledger.js +93 -0
  364. package/dist/verify/explicit-run-ledger.js.map +1 -0
  365. package/dist/verify/failure-signature.d.ts.map +1 -1
  366. package/dist/verify/failure-signature.js +5 -1
  367. package/dist/verify/failure-signature.js.map +1 -1
  368. package/dist/verify/gate-run-registry.d.ts +105 -0
  369. package/dist/verify/gate-run-registry.d.ts.map +1 -0
  370. package/dist/verify/gate-run-registry.js +111 -0
  371. package/dist/verify/gate-run-registry.js.map +1 -0
  372. package/dist/verify/gate-verdict-source.d.ts +68 -0
  373. package/dist/verify/gate-verdict-source.d.ts.map +1 -0
  374. package/dist/verify/gate-verdict-source.js +143 -0
  375. package/dist/verify/gate-verdict-source.js.map +1 -0
  376. package/dist/verify/judged-commit-gate.d.ts +11 -0
  377. package/dist/verify/judged-commit-gate.d.ts.map +1 -0
  378. package/dist/verify/judged-commit-gate.js +48 -0
  379. package/dist/verify/judged-commit-gate.js.map +1 -0
  380. package/dist/verify/rework-judgment.d.ts +58 -0
  381. package/dist/verify/rework-judgment.d.ts.map +1 -0
  382. package/dist/verify/rework-judgment.js +54 -0
  383. package/dist/verify/rework-judgment.js.map +1 -0
  384. package/dist/verify/verification-attribution.d.ts +105 -0
  385. package/dist/verify/verification-attribution.d.ts.map +1 -0
  386. package/dist/verify/verification-attribution.js +322 -0
  387. package/dist/verify/verification-attribution.js.map +1 -0
  388. package/dist/verify/verification-baseline-run.d.ts +123 -0
  389. package/dist/verify/verification-baseline-run.d.ts.map +1 -0
  390. package/dist/verify/verification-baseline-run.js +386 -0
  391. package/dist/verify/verification-baseline-run.js.map +1 -0
  392. package/dist/verify/verification-baseline.d.ts +75 -33
  393. package/dist/verify/verification-baseline.d.ts.map +1 -1
  394. package/dist/verify/verification-baseline.js +92 -105
  395. package/dist/verify/verification-baseline.js.map +1 -1
  396. package/dist/verify/verification-checkout.d.ts +13 -0
  397. package/dist/verify/verification-checkout.d.ts.map +1 -1
  398. package/dist/verify/verification-checkout.js +39 -2
  399. package/dist/verify/verification-checkout.js.map +1 -1
  400. package/dist/verify/verification-commit-sharing.d.ts +84 -0
  401. package/dist/verify/verification-commit-sharing.d.ts.map +1 -0
  402. package/dist/verify/verification-commit-sharing.js +416 -0
  403. package/dist/verify/verification-commit-sharing.js.map +1 -0
  404. package/dist/verify/verification-config.d.ts.map +1 -1
  405. package/dist/verify/verification-config.js +12 -2
  406. package/dist/verify/verification-config.js.map +1 -1
  407. package/dist/verify/verification-default-on.d.ts +27 -11
  408. package/dist/verify/verification-default-on.d.ts.map +1 -1
  409. package/dist/verify/verification-default-on.js +155 -29
  410. package/dist/verify/verification-default-on.js.map +1 -1
  411. package/dist/verify/verification-deps-default.d.ts.map +1 -1
  412. package/dist/verify/verification-deps-default.js +49 -42
  413. package/dist/verify/verification-deps-default.js.map +1 -1
  414. package/dist/verify/verification-deps.d.ts +69 -4
  415. package/dist/verify/verification-deps.d.ts.map +1 -1
  416. package/dist/verify/verification-deterministic.d.ts +15 -2
  417. package/dist/verify/verification-deterministic.d.ts.map +1 -1
  418. package/dist/verify/verification-deterministic.js +12 -3
  419. package/dist/verify/verification-deterministic.js.map +1 -1
  420. package/dist/verify/verification-diagnostics.d.ts +16 -0
  421. package/dist/verify/verification-diagnostics.d.ts.map +1 -0
  422. package/dist/verify/verification-diagnostics.js +219 -0
  423. package/dist/verify/verification-diagnostics.js.map +1 -0
  424. package/dist/verify/verification-engine.d.ts +12 -8
  425. package/dist/verify/verification-engine.d.ts.map +1 -1
  426. package/dist/verify/verification-engine.js +110 -92
  427. package/dist/verify/verification-engine.js.map +1 -1
  428. package/dist/verify/verification-evidence-unavailable-feedback.d.ts +2 -1
  429. package/dist/verify/verification-evidence-unavailable-feedback.d.ts.map +1 -1
  430. package/dist/verify/verification-evidence-unavailable-feedback.js +13 -4
  431. package/dist/verify/verification-evidence-unavailable-feedback.js.map +1 -1
  432. package/dist/verify/verification-feedback.d.ts +21 -34
  433. package/dist/verify/verification-feedback.d.ts.map +1 -1
  434. package/dist/verify/verification-feedback.js +37 -88
  435. package/dist/verify/verification-feedback.js.map +1 -1
  436. package/dist/verify/verification-gate-stages.d.ts +110 -0
  437. package/dist/verify/verification-gate-stages.d.ts.map +1 -0
  438. package/dist/verify/verification-gate-stages.js +179 -0
  439. package/dist/verify/verification-gate-stages.js.map +1 -0
  440. package/dist/verify/verification-history-reset.d.ts +61 -0
  441. package/dist/verify/verification-history-reset.d.ts.map +1 -0
  442. package/dist/verify/verification-history-reset.js +90 -0
  443. package/dist/verify/verification-history-reset.js.map +1 -0
  444. package/dist/verify/verification-manifest.d.ts.map +1 -1
  445. package/dist/verify/verification-manifest.js +2 -1
  446. package/dist/verify/verification-manifest.js.map +1 -1
  447. package/dist/verify/verification-rework-messages.d.ts +19 -0
  448. package/dist/verify/verification-rework-messages.d.ts.map +1 -0
  449. package/dist/verify/verification-rework-messages.js +52 -0
  450. package/dist/verify/verification-rework-messages.js.map +1 -0
  451. package/dist/worktree/install-inputs.d.ts +89 -0
  452. package/dist/worktree/install-inputs.d.ts.map +1 -0
  453. package/dist/worktree/install-inputs.js +625 -0
  454. package/dist/worktree/install-inputs.js.map +1 -0
  455. package/dist/worktree/install-script-effects.d.ts +30 -0
  456. package/dist/worktree/install-script-effects.d.ts.map +1 -0
  457. package/dist/worktree/install-script-effects.js +524 -0
  458. package/dist/worktree/install-script-effects.js.map +1 -0
  459. package/dist/worktree/install-script-tokens.d.ts +57 -0
  460. package/dist/worktree/install-script-tokens.d.ts.map +1 -0
  461. package/dist/worktree/install-script-tokens.js +299 -0
  462. package/dist/worktree/install-script-tokens.js.map +1 -0
  463. package/dist/worktree/provision.d.ts +27 -4
  464. package/dist/worktree/provision.d.ts.map +1 -1
  465. package/dist/worktree/provision.js +46 -7
  466. package/dist/worktree/provision.js.map +1 -1
  467. package/dist/worktree/safety.d.ts +11 -0
  468. package/dist/worktree/safety.d.ts.map +1 -1
  469. package/dist/worktree/safety.js +20 -3
  470. package/dist/worktree/safety.js.map +1 -1
  471. package/dist/worktree/verify-interlock.d.ts.map +1 -1
  472. package/dist/worktree/verify-interlock.js +3 -1
  473. package/dist/worktree/verify-interlock.js.map +1 -1
  474. package/dist/worktree/worktree-package-provisioning.d.ts +75 -0
  475. package/dist/worktree/worktree-package-provisioning.d.ts.map +1 -0
  476. package/dist/worktree/worktree-package-provisioning.js +362 -0
  477. package/dist/worktree/worktree-package-provisioning.js.map +1 -0
  478. package/package.json +1 -1
@@ -0,0 +1,234 @@
1
+ // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
+ // Pinned by: packages/daemon/src/completion/review-exit-verdict-gate.test.ts,
3
+ // packages/daemon/src/focus/listener-product-poll.test.ts,
4
+ // packages/daemon/src/integration/delivery-gate-write-interleaving.test.ts,
5
+ // packages/daemon/src/integration/explicit-gate-identity-unreadable.test.ts,
6
+ // packages/daemon/src/integration/explicit-gate-outcome-restart.test.ts,
7
+ // packages/daemon/src/integration/explicit-verdict-invalidation-restart.test.ts,
8
+ // packages/daemon/src/integration/explicit-verdict-reuse.test.ts,
9
+ // packages/daemon/src/integration/focus-commit-verdict-scenario.test.ts,
10
+ // packages/daemon/src/integration/review-rework-resume-verdict.test.ts,
11
+ // packages/daemon/src/integration/verification-rework-resume-verdict.test.ts,
12
+ // packages/daemon/src/spawn/prompt-assembly-resume-verdict.test.ts,
13
+ // packages/daemon/src/verify/commit-gate-configured.test.ts,
14
+ // packages/daemon/src/verify/verification-commit-sharing.test.ts
15
+ // PINNED-BY-END
16
+ /**
17
+ * Whether a deterministic gate is configured for a verify delivery -- whether the
18
+ * verification tick runs a gate whose verdict the review exit can wait on, and
19
+ * WHICH gate that is -- plus the production gate seams every verify routing
20
+ * decision reads.
21
+ *
22
+ * The review exit holds a verify delivery out of done until a passing verdict
23
+ * exists for the commit it judges (completion/review-exit-verdict-gate.ts). That
24
+ * hold is only safe where a verdict will actually be rendered -- holding a
25
+ * delivery no gate will ever judge strands it in verify -- so this predicate
26
+ * mirrors the tick's own selection (runVerificationTick ->
27
+ * resolveProductVerificationScopes -> collectDefaultOnVerifications) instead of
28
+ * restating it:
29
+ * - the verification loop runs (TELORA_VERIFICATION_LOOP is not '0');
30
+ * - the focus is not read-only and the delivery is anchored to an injection;
31
+ * - the delivery is an explicit-method row with a method that renders verdicts,
32
+ * OR its product resolves a command, or -- unless the operator declined -- the
33
+ * telora.verify.json its judged commit ships declares one (or is malformed,
34
+ * which the dispatch still runs and fails loudly).
35
+ *
36
+ * An explicit-method delivery is gated by its own run, and is known as one from
37
+ * the DURABLE delivery row (its verification_method, on the focus delivery read),
38
+ * not from the pending-verification queue: that queue drops a row once its
39
+ * outcome is terminal, and an explicit pass must not then read as a default-on
40
+ * delivery. Only a row from an edge that does not send the column yet (undefined,
41
+ * not null), or an unreadable row, falls back to the queue. Where neither names a
42
+ * method, a verdict an explicit run recorded (verify/explicit-gate-outcome.ts: in
43
+ * process, or on the gate_state the subject carries) still reads "configured", so
44
+ * a restarted daemon never takes that verdict for no gate at all. The exception
45
+ * is the behavioral method, a scaffold that always returns pending: no verdict is
46
+ * ever rendered for it, so waiting on one would strand the delivery -- not
47
+ * configured.
48
+ *
49
+ * Where an explicit run writes no per-commit verdict (an in-place run has no
50
+ * judged sha; an ai_inspection writes none), the outcome it records IS the
51
+ * verdict, from two sources read in order (readDeliveryGateOutcome):
52
+ * (a) this process's own record (verify/gate-run-registry.ts);
53
+ * (b) else the record on the delivery's gate_state
54
+ * (verificationHistory.explicitOutcome), which carries failures, no-SHA
55
+ * outcomes and the commit the run judged, and is removed before a
56
+ * replacement run starts -- so it never outlives the run that supersedes it.
57
+ * The row's own verification_outcome is NOT a verdict source: the edge stores a
58
+ * pass with no judged commit, so a pass rendered for commit A would read as a
59
+ * pass for every later commit. Where neither (a) nor (b) knows the run, the
60
+ * explicit re-arm scan (verify/explicit-rearm.ts) selects the row again, so the
61
+ * gate renders a verdict bound to the judged commit.
62
+ *
63
+ * The gate is part of the answer (resolveCommitGate). A per-commit verdict is
64
+ * recorded under the gate its run APPLIED (verify/commit-verdict-record.ts), and
65
+ * one commit can carry verdicts of several gates: a sibling's default-on pass says
66
+ * nothing about a delivery whose own explicit command never ran, and a sibling's
67
+ * failure must not hold it. Routing reads a verdict only under the delivery's own
68
+ * gate -- its explicit row's command + timeout, or, for a default-on delivery, the
69
+ * gate its run applies at the judged commit (verify/judged-commit-gate.ts: a
70
+ * branch manifest that overrides the repoPath gate is the gate that runs), or the
71
+ * scan's gate where no focus worktree exists and the run is in place. No gate (no
72
+ * command, a judged commit nobody could read or whose manifest is malformed, or a
73
+ * delivery gated only by its recorded explicit verdict) matches no per-commit
74
+ * record. Every own-gate source is read, and a failure from any wins
75
+ * (completion/review-exit-verdict-gate.ts).
76
+ *
77
+ * An explicit run's recorded verdict is read the same way: only under the gate its
78
+ * run applied (explicitGateKey: the row's method + config). The edge lets an
79
+ * operator change a row's method or config without resetting its outcome, so a
80
+ * verdict rendered under the old gate governs nothing, and a row that names no
81
+ * method takes no explicit verdict at all. A row an older edge sends without the
82
+ * columns, which the queue does not list, takes a recorded verdict of any gate, as
83
+ * before those columns existed. But a row that cannot be read at all, or that a
84
+ * successful read of the focus's deliveries does not contain, which the queue does
85
+ * not list, has an identity nobody knows -- it may name a changed gate,
86
+ * or be explicit where the product also has a default-on gate -- so it is gated by
87
+ * NO gate: configured, with no per-commit gate and no explicit gate. It holds until
88
+ * the row reads again, and never borrows the default-on gate's verdict or one an
89
+ * arbitrary explicit gate rendered.
90
+ *
91
+ * Deliberately NOT mirrored: the tick's re-run guards (already ran this
92
+ * verify-entry; failed on the unchanged HEAD). They decide whether to run AGAIN,
93
+ * not whether a gate is configured, and the verdict is read from the durable
94
+ * per-commit record either way.
95
+ *
96
+ * Direction of error: an answer git could not give (the judged commit's manifest
97
+ * is unreadable) and an unreadable explicit-method list read as "configured" --
98
+ * hold, fail closed -- because the release pass re-asks every poll and releases
99
+ * the moment this reads "not configured". No daemon config or no such product (no
100
+ * running daemon context) reads "not configured": nothing would run a gate there.
101
+ *
102
+ * @module verify/commit-gate-configured
103
+ */
104
+ import { loadEnvConfig } from '@telora/daemon-core';
105
+ import { config as liveDaemonConfig } from '../focus/listener-state.js';
106
+ import { findProduct } from '../shell/config.js';
107
+ import { resolveDefaultVerification } from './verification-config.js';
108
+ import { buildJudgedCommitManifestReader, resolveProductVerificationScopes, } from './verification-default-on.js';
109
+ import { judgedCommitGate } from './judged-commit-gate.js';
110
+ import { getPendingVerifications } from '../queries/verification.js';
111
+ import { getFocusDeliveries } from '../queries/focuses.js';
112
+ import { getFocusWorktree } from '../focus/focus-worktree-state.js';
113
+ import { resolveHeadSha } from './verification-baseline.js';
114
+ import { commitVerdictGateOf, explicitGateKeyOf, readCommitVerdict, } from './commit-verdict-record.js';
115
+ import { hasPendingGateRun } from './gate-run-registry.js';
116
+ import { hasRecordedExplicitGateOutcome, readDeliveryGateOutcome } from './explicit-gate-outcome.js';
117
+ const defaultReadJudgedCommitManifest = buildJudgedCommitManifestReader();
118
+ const NOT_CONFIGURED = { configured: false, gate: null };
119
+ /** The commit a focus's deliveries are judged on: its registered worktree's HEAD, or null when unreadable. */
120
+ export function resolveFocusJudgedCommit(focusId) {
121
+ const worktree = getFocusWorktree(focusId);
122
+ return worktree ? resolveHeadSha(worktree.worktreePath) : null;
123
+ }
124
+ function configRecord(value) {
125
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
126
+ }
127
+ /**
128
+ * The delivery's explicit verification identity: from the durable row, or -- when
129
+ * the row does not carry the columns or cannot be read -- from the
130
+ * pending-verification queue. See the module header.
131
+ */
132
+ async function readExplicitIdentity(subject, deps) {
133
+ // Until a read shows the row itself, its identity is unknown: a read that throws, or one that omits the row.
134
+ let unlisted = { kind: 'unknown' };
135
+ try {
136
+ const rows = await (deps.getFocusDeliveries ?? getFocusDeliveries)(subject.focusId);
137
+ const row = rows.find((d) => d.id === subject.deliveryId);
138
+ if (row && row.verificationMethod !== undefined) {
139
+ return row.verificationMethod
140
+ ? { kind: 'explicit', identity: { method: row.verificationMethod, config: configRecord(row.verificationConfig), outcome: row.verificationOutcome ?? null } }
141
+ : { kind: 'none' };
142
+ }
143
+ // A present row without the columns is an older edge's; an absent one stays unknown.
144
+ if (row)
145
+ unlisted = { kind: 'unsent' };
146
+ }
147
+ catch {
148
+ // Unreadable row: the pending queue below may still name its identity.
149
+ }
150
+ try {
151
+ const pending = await (deps.getPendingVerifications ?? getPendingVerifications)(subject.productId);
152
+ const row = pending.find((p) => p.deliveryId === subject.deliveryId);
153
+ return row
154
+ ? { kind: 'explicit', identity: { method: row.verificationMethod ?? '', config: row.verificationConfig ?? null, outcome: row.verificationOutcome ?? null } }
155
+ : unlisted;
156
+ }
157
+ catch {
158
+ // Unreadable: the tick skips the product on this same failure and retries.
159
+ return unlisted;
160
+ }
161
+ }
162
+ /** A delivery whose identity nobody could read: held, and governed by no gate's verdict (see the module header). */
163
+ const UNKNOWN_IDENTITY = { configured: true, gate: null, explicitGateKey: null };
164
+ /** See the module header: whether a gate is configured for the delivery, and which gate governs its verdict. */
165
+ export async function resolveCommitGate(subject, deps = {}) {
166
+ const env = deps.env ?? process.env;
167
+ if (!loadEnvConfig(env).TELORA_VERIFICATION_LOOP)
168
+ return NOT_CONFIGURED;
169
+ if (subject.focusReadOnly || !subject.injectionId)
170
+ return NOT_CONFIGURED;
171
+ const config = (deps.getConfig ?? (() => liveDaemonConfig))();
172
+ const product = config ? findProduct(config, subject.productId) : undefined;
173
+ if (!config || !product)
174
+ return NOT_CONFIGURED;
175
+ const read = await readExplicitIdentity(subject, deps);
176
+ if (read.kind === 'explicit') {
177
+ const explicit = read.identity;
178
+ if (explicit.method === 'behavioral')
179
+ return NOT_CONFIGURED;
180
+ return {
181
+ configured: true,
182
+ gate: commitVerdictGateOf({ verificationConfig: explicit.config }),
183
+ explicitGateKey: explicitGateKeyOf(explicit.method, explicit.config),
184
+ };
185
+ }
186
+ if (read.kind === 'unknown')
187
+ return UNKNOWN_IDENTITY;
188
+ const defaultOn = resolveDefaultOnGate(subject, deps, env, config, product);
189
+ // The row names no method: no explicit verdict governs it, one recorded before its method was cleared included.
190
+ if (read.kind === 'none')
191
+ return { ...defaultOn, explicitGateKey: null };
192
+ if (defaultOn.configured || !hasRecordedExplicitGateOutcome(subject.deliveryId, subject.gateState))
193
+ return defaultOn;
194
+ // No method named anywhere, but its explicit run recorded a verdict: gated by that run, with no per-commit gate.
195
+ return { configured: true, gate: null };
196
+ }
197
+ /** The default-on gate the verification scan arms for the delivery (see the module header), or not configured. */
198
+ function resolveDefaultOnGate(subject, deps, env, config, product) {
199
+ const resolve = deps.resolveDefaultVerification
200
+ ?? ((c, readManifest) => resolveDefaultVerification(c, env, readManifest));
201
+ const [scope] = resolveProductVerificationScopes({ ...config, products: [product] }, resolve);
202
+ const scanResolved = scope?.resolved ?? scope?.judgedCommitOnly;
203
+ if (!scope || !scanResolved)
204
+ return NOT_CONFIGURED;
205
+ if (!scanResolved.enabled && scope.productConfig.defaultVerification?.declined === true)
206
+ return NOT_CONFIGURED;
207
+ const read = (deps.readJudgedCommitManifest ?? defaultReadJudgedCommitManifest)(subject.focusId);
208
+ if (read === null) {
209
+ // No focus worktree: an armed candidate runs in place on the scan's own config.
210
+ return scanResolved.enabled
211
+ ? { configured: true, gate: { command: scanResolved.command, timeoutMs: scanResolved.timeoutMs } }
212
+ : NOT_CONFIGURED;
213
+ }
214
+ if ('unreadable' in read)
215
+ return { configured: true, gate: null };
216
+ if (!scanResolved.enabled && read.manifest === undefined && read.malformed === undefined)
217
+ return NOT_CONFIGURED;
218
+ // The run re-resolves its gate from the judged commit and records under what it applied: read under that same gate.
219
+ const source = { defaultVerification: scope.productConfig.defaultVerification, repoPath: scope.productConfig.repoPath };
220
+ return { configured: true, gate: judgedCommitGate(source, read, env) };
221
+ }
222
+ /** Whether a gate is configured for the delivery (see the module header). */
223
+ export async function isCommitGateConfigured(subject, deps = {}) {
224
+ return (await resolveCommitGate(subject, deps)).configured;
225
+ }
226
+ /** The production gate seams (see the module header). */
227
+ export const commitGateSeams = {
228
+ resolveCommitGate: (subject) => resolveCommitGate(subject),
229
+ resolveJudgedCommit: resolveFocusJudgedCommit,
230
+ readCommitVerdict: (productId, focusId, sha, gate) => (gate ? readCommitVerdict(productId, focusId, sha, { gate }) : null),
231
+ readDeliveryGateOutcome,
232
+ hasPendingGateRun,
233
+ };
234
+ //# sourceMappingURL=commit-gate-configured.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-gate-configured.js","sourceRoot":"","sources":["../../src/verify/commit-gate-configured.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAC9E,+EAA+E;AAC/E,2EAA2E;AAC3E,mFAAmF;AACnF,oEAAoE;AACpE,2EAA2E;AAC3E,0EAA0E;AAC1E,gFAAgF;AAChF,sEAAsE;AACtE,+DAA+D;AAC/D,mEAAmE;AACnE,gBAAgB;AAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAoC,MAAM,0BAA0B,CAAC;AAExG,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GAEjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE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AC,iBAAiB,CAAC,OAAO,CAAC;IAC1D,mBAAmB,EAAE,wBAAwB;IAC7C,iBAAiB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1H,uBAAuB;IACvB,iBAAiB;CAClB,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { type StrategyResult } from './verification-deterministic.js';
2
+ import type { PendingVerification } from '../queries/verification.js';
3
+ /** The gate a verdict was rendered under: the command + timeout the run applied. */
4
+ export interface CommitVerdictGate {
5
+ command: string;
6
+ timeoutMs: number;
7
+ }
8
+ /** A recorded deterministic verdict for one focus commit. */
9
+ export interface CommitVerdict {
10
+ productId: string;
11
+ focusId: string;
12
+ /** The judged commit (StrategyResult.verifiedSha). */
13
+ sha: string;
14
+ outcome: 'passed' | 'failed';
15
+ /** The gate the run applied -- the reuse key. */
16
+ gate: CommitVerdictGate;
17
+ exitCode: number | null;
18
+ /** The delivery whose dispatch ran the gate (provenance only; the verdict is the commit's). */
19
+ judgedDeliveryId: string;
20
+ recordedAt: string;
21
+ rationale?: string;
22
+ failedStage?: string;
23
+ preExistingStages?: string[];
24
+ newFailures?: string[];
25
+ preExisting?: string[];
26
+ logPath?: string;
27
+ stdoutTail?: string;
28
+ stderrTail?: string;
29
+ appliedConfig?: StrategyResult['appliedConfig'];
30
+ }
31
+ /** Who a verdict is being built for. */
32
+ export interface CommitVerdictSubject {
33
+ productId: string;
34
+ focusId: string;
35
+ deliveryId: string;
36
+ gate: CommitVerdictGate;
37
+ }
38
+ /**
39
+ * The record file for a (product, focus, sha, gate); without a gate, the gate-less
40
+ * file records were written to before they were keyed by gate. `dir` defaults to
41
+ * the global state dir. Exported for tests.
42
+ */
43
+ export declare function commitVerdictPath(productId: string, focusId: string, sha: string, dir?: string, gate?: CommitVerdictGate): string;
44
+ /**
45
+ * The recorded verdict for a focus commit, or null on a miss, an unreadable or
46
+ * malformed file, or a record for another commit. With `gate`: only a verdict
47
+ * rendered under that gate. Without: the newest verdict recorded for the commit
48
+ * under any gate.
49
+ */
50
+ export declare function readCommitVerdict(productId: string, focusId: string, sha: string, opts?: {
51
+ gate?: CommitVerdictGate;
52
+ dir?: string;
53
+ }): CommitVerdict | null;
54
+ /** Write a verdict atomically. Best-effort: returns false (and logs) when the write failed. */
55
+ export declare function writeCommitVerdict(verdict: CommitVerdict, dir?: string): boolean;
56
+ /**
57
+ * Build the verdict a finished deterministic run renders for its commit, or null
58
+ * when the run rendered none (see the module header). `instrumentFault` is true
59
+ * when attribution routed the run to instrument-fault re-work. Pure.
60
+ */
61
+ export declare function buildCommitVerdict(subject: CommitVerdictSubject, result: StrategyResult, instrumentFault: boolean, now?: Date): CommitVerdict | null;
62
+ /** The recorder a verification is wired with (VerificationDeps.recordCommitVerdict). */
63
+ export type CommitVerdictRecorder = (verdict: CommitVerdict) => void;
64
+ /** The reader a verification is wired with (VerificationDeps.readCommitVerdict): the verdict for a commit under a gate, or null. */
65
+ export type CommitVerdictReader = (productId: string, focusId: string, sha: string, gate: CommitVerdictGate) => CommitVerdict | null;
66
+ /**
67
+ * The gate a verification carries: the command + timeout on its config -- a
68
+ * missing or non-positive timeout is the strategy default, exactly as a run
69
+ * applies it -- or null when it carries no command. It keys an explicit row's
70
+ * verdict, and a default-on candidate's only where that candidate runs in place;
71
+ * a default-on run from a checkout of the judged commit is keyed by the gate it
72
+ * applies there (verify/judged-commit-gate.ts).
73
+ */
74
+ export declare function commitVerdictGateOf(v: Pick<PendingVerification, 'verificationConfig'>): CommitVerdictGate | null;
75
+ /**
76
+ * The identity of the gate an EXPLICIT-METHOD row renders its verdict under: its
77
+ * method and what that method applies -- a deterministic row's command +
78
+ * normalized timeout (commitVerdictGateOf), any other method's whole config.
79
+ * Hashed, so it rides on gate_state; key order in the config does not change it.
80
+ * Two rows that apply the same gate share a key; a changed method, command,
81
+ * timeout or inspection config does not (verify/explicit-gate-outcome.ts). Pure.
82
+ */
83
+ export declare function explicitGateKeyOf(method: string, config: Record<string, unknown> | null): string;
84
+ /**
85
+ * Record the verdict a deterministic run rendered for its commit, keyed by the
86
+ * gate the run APPLIED (result.appliedConfig -- for a default-on candidate,
87
+ * re-resolved from the checkout it ran), else by the gate the verification
88
+ * carries. A no-op without a recorder, without a product + focus to key it by, or
89
+ * when the run rendered no verdict.
90
+ */
91
+ export declare function recordCommitVerdictFor(v: Pick<PendingVerification, 'productId' | 'focusId' | 'deliveryId' | 'verificationConfig'>, result: StrategyResult, instrumentFault: boolean, record: CommitVerdictRecorder | undefined): void;
92
+ /**
93
+ * The StrategyResult a delivery judged on an already-judged commit takes instead
94
+ * of running the gate: the recorded outcome with its attribution, never a
95
+ * timeout or unavailable flag (a record is only ever written for a real verdict).
96
+ */
97
+ export declare function strategyResultFromVerdict(verdict: CommitVerdict): StrategyResult;
98
+ //# sourceMappingURL=commit-verdict-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-verdict-record.d.ts","sourceRoot":"","sources":["../../src/verify/commit-verdict-record.ts"],"names":[],"mappings":"AAyDA,OAAO,EAAmC,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACvG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKtE,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,iDAAiD;IACjD,IAAI,EAAE,iBAAiB,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kB,CAChC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,cAAc,EACtB,eAAe,EAAE,OAAO,EACxB,GAAG,GAAE,IAAiB,GACrB,aAAa,GAAG,IAAI,CAiBtB;AAiBD,wFAAwF;AACxF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;AAErE,oIAAoI;AACpI,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,KAAK,aAAa,GAAG,IAAI,CAAC;AAErI;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,GAAG,iBAAiB,GAAG,IAAI,CAKhH;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,MAAM,CAGhG;AAYD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,oBAAoB,CAAC,EAC3F,MAAM,EAAE,cAAc,EACtB,eAAe,EAAE,OAAO,EACxB,MAAM,EAAE,qBAAqB,GAAG,SAAS,GACxC,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAiBhF"}
@@ -0,0 +1,297 @@
1
+ // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
+ // Pinned by: packages/daemon/src/completion/mid-flight-merge-gate.test.ts,
3
+ // packages/daemon/src/completion/review-exit-verdict-gate.test.ts,
4
+ // packages/daemon/src/completion/teardown-merge-gate.test.ts,
5
+ // packages/daemon/src/focus/listener-product-poll.test.ts,
6
+ // packages/daemon/src/integration/delivery-gate-write-interleaving.test.ts,
7
+ // packages/daemon/src/integration/explicit-gate-identity-unreadable.test.ts,
8
+ // packages/daemon/src/integration/explicit-gate-outcome-restart.test.ts,
9
+ // packages/daemon/src/integration/explicit-verdict-departure-during-removal.test.ts,
10
+ // packages/daemon/src/integration/explicit-verdict-invalidation-restart.test.ts,
11
+ // packages/daemon/src/integration/explicit-verdict-reuse.test.ts,
12
+ // packages/daemon/src/integration/focus-commit-verdict-scenario.test.ts,
13
+ // packages/daemon/src/integration/review-rework-resume-verdict.test.ts,
14
+ // packages/daemon/src/integration/verification-rework-resume-verdict.test.ts,
15
+ // packages/daemon/src/merge/resolved-conflict-merge-gate.test.ts,
16
+ // packages/daemon/src/spawn/prompt-assembly-resume-verdict.test.ts,
17
+ // packages/daemon/src/verify/commit-gate-configured.test.ts,
18
+ // packages/daemon/src/verify/commit-verdict-record.test.ts,
19
+ // packages/daemon/src/verify/gate-verdict-source.test.ts,
20
+ // packages/daemon/src/verify/verification-commit-sharing.test.ts
21
+ // PINNED-BY-END
22
+ /**
23
+ * The deterministic gate verdict for a focus commit, recorded durably.
24
+ *
25
+ * Every delivery on a focus is judged on the same focus-branch HEAD, and a gate
26
+ * on an unchanged tree renders the same verdict -- so the verdict belongs to the
27
+ * COMMIT, not to whichever delivery's dispatch happened to run it. Before this
28
+ * record only a failed sha was durable (per delivery, gate_state
29
+ * verificationHistory.failedAtSha) and a pass was merely the absence of one, so a
30
+ * sibling delivery, a status round trip, or a daemon restart at an already-judged
31
+ * commit paid for the whole gate again.
32
+ *
33
+ * One file per (product, focus, sha, gate) under the global state dir, written
34
+ * atomically (temp + rename) so a reader never sees a torn record. A verdict
35
+ * under one command or timeout says nothing about another, and one commit can
36
+ * carry verdicts of several gates (a sibling's explicit command beside the
37
+ * default-on gate), so no gate's record overwrites another's. A reader that names
38
+ * a gate gets only that gate's verdict -- what every routing decision does; one
39
+ * that names none (the team-facing verdict summary) gets the newest recorded for
40
+ * the commit. A record written before files were keyed by gate is still read, and
41
+ * still only for the gate it carries.
42
+ *
43
+ * What is NOT a verdict, and so is never written: a run killed by its timeout,
44
+ * a run that could not get a checkout (or whose installs moved mid-run), a run
45
+ * whose config was unresolvable (nothing ran), a run the attribution routed to
46
+ * instrument-fault re-work (the gate could not attribute it), and any run with no
47
+ * judged commit. Those leave the commit unjudged, so the next tick asks again.
48
+ *
49
+ * @module commit-verdict-record
50
+ */
51
+ import { createHash } from 'node:crypto';
52
+ import { mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
53
+ import { basename, resolve } from 'node:path';
54
+ import { resolveGlobalStateDir } from '../shell/daemon-process.js';
55
+ import { judgedFailedSha } from '../queries/delivery-gate-state.js';
56
+ import { DEFAULT_VERIFICATION_TIMEOUT_MS } from './verification-deterministic.js';
57
+ import { createLogger } from '../shell/log.js';
58
+ const log = createLogger({ module: 'verification' });
59
+ function verdictDir() {
60
+ return resolve(resolveGlobalStateDir(), 'verification-verdicts');
61
+ }
62
+ /**
63
+ * The record file for a (product, focus, sha, gate); without a gate, the gate-less
64
+ * file records were written to before they were keyed by gate. `dir` defaults to
65
+ * the global state dir. Exported for tests.
66
+ */
67
+ export function commitVerdictPath(productId, focusId, sha, dir = verdictDir(), gate) {
68
+ const base = `${productId}-${focusId}-${sha}`;
69
+ return resolve(dir, `${gate ? `${base}-${gateKey(gate)}` : base}.json`.replace(/[^a-zA-Z0-9._-]/g, '_'));
70
+ }
71
+ /** A gate's key in a record file name: its command + timeout, hashed. */
72
+ function gateKey(gate) {
73
+ return createHash('sha256').update(JSON.stringify([gate.command, gate.timeoutMs])).digest('hex').slice(0, 12);
74
+ }
75
+ const SHA_RE = /^[0-9a-f]{7,64}$/i;
76
+ function isStringArray(value) {
77
+ return Array.isArray(value) && value.every((s) => typeof s === 'string');
78
+ }
79
+ function optionalString(value) {
80
+ return typeof value === 'string' ? value : undefined;
81
+ }
82
+ /** Validate a parsed record; null when it is not a well-formed verdict. */
83
+ function parseVerdict(raw) {
84
+ if (typeof raw !== 'object' || raw === null)
85
+ return null;
86
+ const r = raw;
87
+ const gate = r.gate;
88
+ if (typeof r.productId !== 'string' || typeof r.focusId !== 'string' || typeof r.judgedDeliveryId !== 'string')
89
+ return null;
90
+ if (typeof r.sha !== 'string' || !SHA_RE.test(r.sha))
91
+ return null;
92
+ if (r.outcome !== 'passed' && r.outcome !== 'failed')
93
+ return null;
94
+ if (typeof gate?.command !== 'string' || typeof gate.timeoutMs !== 'number')
95
+ return null;
96
+ if (typeof r.recordedAt !== 'string')
97
+ return null;
98
+ const rationale = optionalString(r.rationale);
99
+ const failedStage = optionalString(r.failedStage);
100
+ return {
101
+ productId: r.productId,
102
+ focusId: r.focusId,
103
+ sha: r.sha,
104
+ outcome: r.outcome,
105
+ gate: { command: gate.command, timeoutMs: gate.timeoutMs },
106
+ exitCode: typeof r.exitCode === 'number' ? r.exitCode : null,
107
+ judgedDeliveryId: r.judgedDeliveryId,
108
+ recordedAt: r.recordedAt,
109
+ ...(rationale !== undefined ? { rationale } : {}),
110
+ ...(failedStage !== undefined ? { failedStage } : {}),
111
+ ...(isStringArray(r.preExistingStages) ? { preExistingStages: r.preExistingStages } : {}),
112
+ ...(isStringArray(r.newFailures) ? { newFailures: r.newFailures } : {}),
113
+ ...(isStringArray(r.preExisting) ? { preExisting: r.preExisting } : {}),
114
+ ...(typeof r.logPath === 'string' ? { logPath: r.logPath } : {}),
115
+ ...(typeof r.stdoutTail === 'string' ? { stdoutTail: r.stdoutTail } : {}),
116
+ ...(typeof r.stderrTail === 'string' ? { stderrTail: r.stderrTail } : {}),
117
+ ...(typeof r.appliedConfig === 'object' && r.appliedConfig !== null
118
+ ? { appliedConfig: r.appliedConfig }
119
+ : {}),
120
+ };
121
+ }
122
+ /**
123
+ * The recorded verdict for a focus commit, or null on a miss, an unreadable or
124
+ * malformed file, or a record for another commit. With `gate`: only a verdict
125
+ * rendered under that gate. Without: the newest verdict recorded for the commit
126
+ * under any gate.
127
+ */
128
+ export function readCommitVerdict(productId, focusId, sha, opts = {}) {
129
+ const dir = opts.dir ?? verdictDir();
130
+ const gateless = commitVerdictPath(productId, focusId, sha, dir);
131
+ const paths = opts.gate
132
+ ? [commitVerdictPath(productId, focusId, sha, dir, opts.gate), gateless]
133
+ : [gateless, ...gateKeyedPaths(gateless, dir)];
134
+ let newest = null;
135
+ for (const path of paths) {
136
+ const parsed = readVerdictFile(path);
137
+ if (!parsed || parsed.productId !== productId || parsed.focusId !== focusId || parsed.sha !== sha)
138
+ continue;
139
+ if (opts.gate && (parsed.gate.command !== opts.gate.command || parsed.gate.timeoutMs !== opts.gate.timeoutMs))
140
+ continue;
141
+ if (opts.gate)
142
+ return parsed;
143
+ if (newest === null || parsed.recordedAt > newest.recordedAt)
144
+ newest = parsed;
145
+ }
146
+ return newest;
147
+ }
148
+ /** A parsed record file, or null when it is missing, unreadable, or malformed. */
149
+ function readVerdictFile(path) {
150
+ try {
151
+ return parseVerdict(JSON.parse(readFileSync(path, 'utf8')));
152
+ }
153
+ catch {
154
+ return null;
155
+ }
156
+ }
157
+ /** Every gate-keyed record file of the commit whose gate-less record file is `gateless`. */
158
+ function gateKeyedPaths(gateless, dir) {
159
+ const prefix = `${basename(gateless, '.json')}-`;
160
+ try {
161
+ return readdirSync(dir).filter((name) => name.startsWith(prefix) && name.endsWith('.json')).map((name) => resolve(dir, name));
162
+ }
163
+ catch {
164
+ return [];
165
+ }
166
+ }
167
+ /** Write a verdict atomically. Best-effort: returns false (and logs) when the write failed. */
168
+ export function writeCommitVerdict(verdict, dir = verdictDir()) {
169
+ const path = commitVerdictPath(verdict.productId, verdict.focusId, verdict.sha, dir, verdict.gate);
170
+ const tmp = `${path}.${process.pid}.tmp`;
171
+ try {
172
+ mkdirSync(dir, { recursive: true });
173
+ writeFileSync(tmp, JSON.stringify(verdict, null, 2), { mode: 0o600 });
174
+ renameSync(tmp, path);
175
+ return true;
176
+ }
177
+ catch (err) {
178
+ log.warn(`[verification] failed to record the verdict for ${verdict.focusId}@${verdict.sha.slice(0, 8)}:`, err.message);
179
+ return false;
180
+ }
181
+ }
182
+ /**
183
+ * Build the verdict a finished deterministic run renders for its commit, or null
184
+ * when the run rendered none (see the module header). `instrumentFault` is true
185
+ * when attribution routed the run to instrument-fault re-work. Pure.
186
+ */
187
+ export function buildCommitVerdict(subject, result, instrumentFault, now = new Date()) {
188
+ if (instrumentFault || result.timedOut || result.checkoutUnavailable || result.configUnresolved)
189
+ return null;
190
+ const sha = result.outcome === 'failed'
191
+ ? judgedFailedSha(result)
192
+ : result.outcome === 'passed' && result.verifiedSha && SHA_RE.test(result.verifiedSha) ? result.verifiedSha : null;
193
+ if (!sha || (result.outcome !== 'passed' && result.outcome !== 'failed'))
194
+ return null;
195
+ return {
196
+ productId: subject.productId,
197
+ focusId: subject.focusId,
198
+ sha,
199
+ outcome: result.outcome,
200
+ gate: { command: subject.gate.command, timeoutMs: subject.gate.timeoutMs },
201
+ exitCode: typeof result.exitCode === 'number' ? result.exitCode : null,
202
+ judgedDeliveryId: subject.deliveryId,
203
+ recordedAt: now.toISOString(),
204
+ ...pickCarried(result),
205
+ };
206
+ }
207
+ /** The result fields a verdict carries forward to the deliveries that reuse it. */
208
+ function pickCarried(result) {
209
+ return {
210
+ ...(result.rationale !== undefined ? { rationale: result.rationale } : {}),
211
+ ...(result.failedStage !== undefined ? { failedStage: result.failedStage } : {}),
212
+ ...(result.preExistingStages ? { preExistingStages: result.preExistingStages } : {}),
213
+ ...(result.newFailures ? { newFailures: result.newFailures } : {}),
214
+ ...(result.preExisting ? { preExisting: result.preExisting } : {}),
215
+ ...(result.logPath !== undefined ? { logPath: result.logPath } : {}),
216
+ ...(result.stdoutTail !== undefined ? { stdoutTail: result.stdoutTail } : {}),
217
+ ...(result.stderrTail !== undefined ? { stderrTail: result.stderrTail } : {}),
218
+ ...(result.appliedConfig ? { appliedConfig: result.appliedConfig } : {}),
219
+ };
220
+ }
221
+ /**
222
+ * The gate a verification carries: the command + timeout on its config -- a
223
+ * missing or non-positive timeout is the strategy default, exactly as a run
224
+ * applies it -- or null when it carries no command. It keys an explicit row's
225
+ * verdict, and a default-on candidate's only where that candidate runs in place;
226
+ * a default-on run from a checkout of the judged commit is keyed by the gate it
227
+ * applies there (verify/judged-commit-gate.ts).
228
+ */
229
+ export function commitVerdictGateOf(v) {
230
+ const cfg = v.verificationConfig ?? {};
231
+ if (typeof cfg.command !== 'string')
232
+ return null;
233
+ const timeoutMs = typeof cfg.timeoutMs === 'number' && cfg.timeoutMs > 0 ? cfg.timeoutMs : DEFAULT_VERIFICATION_TIMEOUT_MS;
234
+ return { command: cfg.command, timeoutMs };
235
+ }
236
+ /**
237
+ * The identity of the gate an EXPLICIT-METHOD row renders its verdict under: its
238
+ * method and what that method applies -- a deterministic row's command +
239
+ * normalized timeout (commitVerdictGateOf), any other method's whole config.
240
+ * Hashed, so it rides on gate_state; key order in the config does not change it.
241
+ * Two rows that apply the same gate share a key; a changed method, command,
242
+ * timeout or inspection config does not (verify/explicit-gate-outcome.ts). Pure.
243
+ */
244
+ export function explicitGateKeyOf(method, config) {
245
+ const applied = method === 'deterministic' ? commitVerdictGateOf({ verificationConfig: config }) : config;
246
+ return createHash('sha256').update(canonicalJson([method, applied])).digest('hex').slice(0, 16);
247
+ }
248
+ /** JSON with every object's keys sorted, so equal values serialize equally. Pure. */
249
+ function canonicalJson(value) {
250
+ if (Array.isArray(value))
251
+ return `[${value.map(canonicalJson).join(',')}]`;
252
+ if (typeof value === 'object' && value !== null) {
253
+ const record = value;
254
+ return `{${Object.keys(record).sort().map((k) => `${JSON.stringify(k)}:${canonicalJson(record[k])}`).join(',')}}`;
255
+ }
256
+ return JSON.stringify(value) ?? 'null';
257
+ }
258
+ /**
259
+ * Record the verdict a deterministic run rendered for its commit, keyed by the
260
+ * gate the run APPLIED (result.appliedConfig -- for a default-on candidate,
261
+ * re-resolved from the checkout it ran), else by the gate the verification
262
+ * carries. A no-op without a recorder, without a product + focus to key it by, or
263
+ * when the run rendered no verdict.
264
+ */
265
+ export function recordCommitVerdictFor(v, result, instrumentFault, record) {
266
+ const applied = result.appliedConfig;
267
+ const gate = applied ? { command: applied.command, timeoutMs: applied.timeoutMs } : commitVerdictGateOf(v);
268
+ if (!record || !v.productId || !v.focusId || !gate)
269
+ return;
270
+ const verdict = buildCommitVerdict({ productId: v.productId, focusId: v.focusId, deliveryId: v.deliveryId, gate }, result, instrumentFault);
271
+ if (verdict)
272
+ record(verdict);
273
+ }
274
+ /**
275
+ * The StrategyResult a delivery judged on an already-judged commit takes instead
276
+ * of running the gate: the recorded outcome with its attribution, never a
277
+ * timeout or unavailable flag (a record is only ever written for a real verdict).
278
+ */
279
+ export function strategyResultFromVerdict(verdict) {
280
+ const { rationale, failedStage, preExistingStages, newFailures, preExisting, logPath, stdoutTail, stderrTail, appliedConfig } = verdict;
281
+ return {
282
+ outcome: verdict.outcome,
283
+ exitCode: verdict.exitCode,
284
+ verifiedSha: verdict.sha,
285
+ rationale: `reused the verdict recorded for ${verdict.sha.slice(0, 8)} at ${verdict.recordedAt}`
286
+ + (rationale ? `: ${rationale}` : ''),
287
+ ...(failedStage !== undefined ? { failedStage } : {}),
288
+ ...(preExistingStages ? { preExistingStages } : {}),
289
+ ...(newFailures ? { newFailures } : {}),
290
+ ...(preExisting ? { preExisting } : {}),
291
+ ...(logPath !== undefined ? { logPath } : {}),
292
+ ...(stdoutTail !== undefined ? { stdoutTail } : {}),
293
+ ...(stderrTail !== undefined ? { stderrTail } : {}),
294
+ ...(appliedConfig ? { appliedConfig } : {}),
295
+ };
296
+ }
297
+ //# sourceMappingURL=commit-verdict-record.js.map