@straiffi/archon 1.11.16 → 1.12.1

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 (415) hide show
  1. package/dist/client/assets/{ActivityView-TwJeVDII.js → ActivityView-Dj5S7hsh.js} +1 -1
  2. package/dist/client/assets/{GitHubActionsDialog-Umiz7hRS.js → GitHubActionsDialog-CjpWWV6K.js} +1 -1
  3. package/dist/client/assets/{VerificationDialog-BVaLckVH.js → VerificationDialog-D_oqWNfs.js} +1 -1
  4. package/dist/client/assets/{architectureDiagram-3BPJPVTR-DG6n6a9N.js → architectureDiagram-3BPJPVTR-SMvI8bbP.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-GPEHLZMM-fpqlAUZA.js → blockDiagram-GPEHLZMM-ZoCUF2FT.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-AAUBKEIU-DD-BA8Fj.js → c4Diagram-AAUBKEIU-dgNmWpLf.js} +1 -1
  7. package/dist/client/assets/channel-oCTaDXrp.js +1 -0
  8. package/dist/client/assets/{chunk-2J33WTMH-BcwQlxYR.js → chunk-2J33WTMH-CfhiOnjw.js} +1 -1
  9. package/dist/client/assets/{chunk-3OPIFGDE-DCbOiRKI.js → chunk-3OPIFGDE-BN_9kQF6.js} +1 -1
  10. package/dist/client/assets/{chunk-5ZQYHXKU-BAgSocEO.js → chunk-5ZQYHXKU-U81zmCSe.js} +1 -1
  11. package/dist/client/assets/{chunk-727SXJPM-0NBz7Bl7.js → chunk-727SXJPM-BeygXkSV.js} +1 -1
  12. package/dist/client/assets/{chunk-AQP2D5EJ-BgLpjpch.js → chunk-AQP2D5EJ-BN7FrZhb.js} +1 -1
  13. package/dist/client/assets/{chunk-CSCIHK7Q-CFV8R2WL.js → chunk-CSCIHK7Q-JwX4jFl0.js} +1 -1
  14. package/dist/client/assets/{chunk-KSCS5N6A-B-5OABYB.js → chunk-KSCS5N6A-GGzKW1v9.js} +1 -1
  15. package/dist/client/assets/{chunk-L5ZTLDWV-BEakyLfX.js → chunk-L5ZTLDWV-CN21SkwK.js} +1 -1
  16. package/dist/client/assets/{chunk-LZXEDZCA-k1JqO5jl.js → chunk-LZXEDZCA-DX98kY3h.js} +2 -2
  17. package/dist/client/assets/{chunk-ND2GUHAM-CAvkgbq4.js → chunk-ND2GUHAM-CzEOJ-Ni.js} +1 -1
  18. package/dist/client/assets/{chunk-NZK2D7GU-B1XxeNv6.js → chunk-NZK2D7GU-DeluonWj.js} +1 -1
  19. package/dist/client/assets/{chunk-O5CBEL6O-xsxGQlBc.js → chunk-O5CBEL6O-BiatHJIP.js} +1 -1
  20. package/dist/client/assets/{chunk-WU5MYG2G-D2RTcS5J.js → chunk-WU5MYG2G-BeoGHTyj.js} +1 -1
  21. package/dist/client/assets/classDiagram-4FO5ZUOK-BzINsgMy.js +1 -0
  22. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CrFLNlm2.js +1 -0
  23. package/dist/client/assets/{dagre-BM42HDAG-DQRkT0rW.js → dagre-BM42HDAG-CutiEWal.js} +1 -1
  24. package/dist/client/assets/{diagram-2AECGRRQ-DLxnmFG_.js → diagram-2AECGRRQ-UYVuKu8m.js} +1 -1
  25. package/dist/client/assets/{diagram-5GNKFQAL-Cu1nMouP.js → diagram-5GNKFQAL-DqKJvB4t.js} +1 -1
  26. package/dist/client/assets/{diagram-KO2AKTUF-BCpHrNi4.js → diagram-KO2AKTUF-BPJ-O_cA.js} +1 -1
  27. package/dist/client/assets/{diagram-LMA3HP47-CIM0-geo.js → diagram-LMA3HP47-DP0IbYEI.js} +1 -1
  28. package/dist/client/assets/{diagram-OG6HWLK6-DV8jDGdy.js → diagram-OG6HWLK6-DXDldxGm.js} +1 -1
  29. package/dist/client/assets/{erDiagram-TEJ5UH35-C-5Pkrkl.js → erDiagram-TEJ5UH35-B_hXGp5n.js} +1 -1
  30. package/dist/client/assets/{flowDiagram-I6XJVG4X-CDPh9OIS.js → flowDiagram-I6XJVG4X-lNtRu-n8.js} +1 -1
  31. package/dist/client/assets/{ganttDiagram-6RSMTGT7-jncsu8xZ.js → ganttDiagram-6RSMTGT7-Dbs1eqy1.js} +1 -1
  32. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-DGWMJkfX.js → gitGraphDiagram-PVQCEYII-BYan1HCB.js} +1 -1
  33. package/dist/client/assets/index-D5MLN5-T.js +309 -0
  34. package/dist/client/assets/index-DTsS9gs9.css +2 -0
  35. package/dist/client/assets/{infoDiagram-5YYISTIA-B4xDH_w0.js → infoDiagram-5YYISTIA-B4Uv2tAZ.js} +1 -1
  36. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-DVdd9VXs.js → ishikawaDiagram-YF4QCWOH-BElfMHQ3.js} +1 -1
  37. package/dist/client/assets/{journeyDiagram-JHISSGLW-nOtumTZv.js → journeyDiagram-JHISSGLW-BRsketd3.js} +1 -1
  38. package/dist/client/assets/{kanban-definition-UN3LZRKU-DDOXGouj.js → kanban-definition-UN3LZRKU-BMYQCPCr.js} +1 -1
  39. package/dist/client/assets/{line-Bv23U4ui.js → line-CNEJr2Z3.js} +1 -1
  40. package/dist/client/assets/{mermaid-parser.core-G9FbMuHU.js → mermaid-parser.core-Dv5rG7Vi.js} +1 -1
  41. package/dist/client/assets/{mermaid.core-B3CWAqqw.js → mermaid.core-DBp6qUb9.js} +3 -3
  42. package/dist/client/assets/{mindmap-definition-RKZ34NQL-DjSz56M7.js → mindmap-definition-RKZ34NQL-DCaupruQ.js} +1 -1
  43. package/dist/client/assets/{pieDiagram-4H26LBE5-DSWgdOVl.js → pieDiagram-4H26LBE5-YxafCwoc.js} +1 -1
  44. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-DEupU1aE.js → quadrantDiagram-W4KKPZXB-_VLdUz-t.js} +1 -1
  45. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BhBfAL0L.js → requirementDiagram-4Y6WPE33-CcpFQQIl.js} +1 -1
  46. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-CbjG9Vw2.js → sankeyDiagram-5OEKKPKP-DCEdLibD.js} +1 -1
  47. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-1Q4xZQSJ.js → sequenceDiagram-3UESZ5HK-Ca6Jew9U.js} +1 -1
  48. package/dist/client/assets/{stateDiagram-AJRCARHV-OtJd_YEY.js → stateDiagram-AJRCARHV-cUqpPg9W.js} +1 -1
  49. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-Cs0MscGk.js +1 -0
  50. package/dist/client/assets/{timeline-definition-PNZ67QCA-CABkNCpN.js → timeline-definition-PNZ67QCA-XplBZjeM.js} +1 -1
  51. package/dist/client/assets/{vennDiagram-CIIHVFJN-BC2gbfhD.js → vennDiagram-CIIHVFJN-_M7dDKLt.js} +1 -1
  52. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-Bkh5qr4Q.js → wardleyDiagram-YWT4CUSO-Bx5YN1ZC.js} +1 -1
  53. package/dist/client/assets/{xychartDiagram-2RQKCTM6-BWDBD0AE.js → xychartDiagram-2RQKCTM6-DYnhlTba.js} +1 -1
  54. package/dist/client/index.html +2 -2
  55. package/dist/server/db.js +32 -14
  56. package/dist/server/db.js.map +1 -1
  57. package/dist/server/epicRoutes.js +305 -0
  58. package/dist/server/epicRoutes.js.map +1 -0
  59. package/dist/server/index.js +186 -60
  60. package/dist/server/index.js.map +1 -1
  61. package/dist/server/lib/agent.js +198 -77
  62. package/dist/server/lib/agent.js.map +1 -1
  63. package/dist/server/lib/agentRuns.js +64 -31
  64. package/dist/server/lib/agentRuns.js.map +1 -1
  65. package/dist/server/lib/attachments.js +10 -0
  66. package/dist/server/lib/attachments.js.map +1 -1
  67. package/dist/server/lib/automationBuildContinuation.js +14 -2
  68. package/dist/server/lib/automationBuildContinuation.js.map +1 -1
  69. package/dist/server/lib/automationCheckEvidence.js +118 -0
  70. package/dist/server/lib/automationCheckEvidence.js.map +1 -0
  71. package/dist/server/lib/automationCheckGate.js +60 -162
  72. package/dist/server/lib/automationCheckGate.js.map +1 -1
  73. package/dist/server/lib/automationProcessInterruption.js +52 -0
  74. package/dist/server/lib/automationProcessInterruption.js.map +1 -0
  75. package/dist/server/lib/automationProgression.js +2 -0
  76. package/dist/server/lib/automationProgression.js.map +1 -1
  77. package/dist/server/lib/automationProgressionPurpose.js +27 -0
  78. package/dist/server/lib/automationProgressionPurpose.js.map +1 -0
  79. package/dist/server/lib/automationReconciliation.js +46 -17
  80. package/dist/server/lib/automationReconciliation.js.map +1 -1
  81. package/dist/server/lib/buildCheckpointSuccessor.js +49 -0
  82. package/dist/server/lib/buildCheckpointSuccessor.js.map +1 -0
  83. package/dist/server/lib/buildCompletionContinuation.js +214 -19
  84. package/dist/server/lib/buildCompletionContinuation.js.map +1 -1
  85. package/dist/server/lib/buildCompletionEvidence.js +62 -0
  86. package/dist/server/lib/buildCompletionEvidence.js.map +1 -0
  87. package/dist/server/lib/buildCompletionEvidenceReader.js +38 -0
  88. package/dist/server/lib/buildCompletionEvidenceReader.js.map +1 -0
  89. package/dist/server/lib/buildExecutionAdmission.js +25 -4
  90. package/dist/server/lib/buildExecutionAdmission.js.map +1 -1
  91. package/dist/server/lib/buildExecutionLineage.js +50 -0
  92. package/dist/server/lib/buildExecutionLineage.js.map +1 -0
  93. package/dist/server/lib/buildFlow.js +13 -0
  94. package/dist/server/lib/buildFlow.js.map +1 -1
  95. package/dist/server/lib/buildSequenceCheckpointOwnership.js +34 -0
  96. package/dist/server/lib/buildSequenceCheckpointOwnership.js.map +1 -0
  97. package/dist/server/lib/buildSequences.js +18 -1
  98. package/dist/server/lib/buildSequences.js.map +1 -1
  99. package/dist/server/lib/buildTicketCheckpointEligibility.js +6 -0
  100. package/dist/server/lib/buildTicketCheckpointEligibility.js.map +1 -0
  101. package/dist/server/lib/buildTicketCommit.js +87 -8
  102. package/dist/server/lib/buildTicketCommit.js.map +1 -1
  103. package/dist/server/lib/bundleBuildRecovery.js +18 -4
  104. package/dist/server/lib/bundleBuildRecovery.js.map +1 -1
  105. package/dist/server/lib/bundleDeletion.js +11 -0
  106. package/dist/server/lib/bundleDeletion.js.map +1 -1
  107. package/dist/server/lib/chatOperations.js +7 -0
  108. package/dist/server/lib/chatOperations.js.map +1 -1
  109. package/dist/server/lib/chatTurnPurpose.js +15 -0
  110. package/dist/server/lib/chatTurnPurpose.js.map +1 -0
  111. package/dist/server/lib/checkAttemptAdmission.js +27 -0
  112. package/dist/server/lib/checkAttemptAdmission.js.map +1 -0
  113. package/dist/server/lib/checkAutoFix.js +46 -14
  114. package/dist/server/lib/checkAutoFix.js.map +1 -1
  115. package/dist/server/lib/checkAutoFixStepPolicy.js +32 -0
  116. package/dist/server/lib/checkAutoFixStepPolicy.js.map +1 -0
  117. package/dist/server/lib/checkRepair.js +31 -14
  118. package/dist/server/lib/checkRepair.js.map +1 -1
  119. package/dist/server/lib/checkRepairStepPolicy.js +23 -0
  120. package/dist/server/lib/checkRepairStepPolicy.js.map +1 -0
  121. package/dist/server/lib/checkRunner.js +57 -32
  122. package/dist/server/lib/checkRunner.js.map +1 -1
  123. package/dist/server/lib/conversationResume.js +22 -0
  124. package/dist/server/lib/conversationResume.js.map +1 -1
  125. package/dist/server/lib/epicAdmission.js +173 -0
  126. package/dist/server/lib/epicAdmission.js.map +1 -0
  127. package/dist/server/lib/epicAttemptBuildRecovery.js +200 -0
  128. package/dist/server/lib/epicAttemptBuildRecovery.js.map +1 -0
  129. package/dist/server/lib/epicAttemptReconciliation.js +254 -0
  130. package/dist/server/lib/epicAttemptReconciliation.js.map +1 -0
  131. package/dist/server/lib/epicAttemptRecoverySchema.js +16 -0
  132. package/dist/server/lib/epicAttemptRecoverySchema.js.map +1 -0
  133. package/dist/server/lib/epicAttemptRecoveryStore.js +8 -0
  134. package/dist/server/lib/epicAttemptRecoveryStore.js.map +1 -0
  135. package/dist/server/lib/epicAutomation.js +104 -0
  136. package/dist/server/lib/epicAutomation.js.map +1 -0
  137. package/dist/server/lib/epicBuildCheckpoint.js +141 -0
  138. package/dist/server/lib/epicBuildCheckpoint.js.map +1 -0
  139. package/dist/server/lib/epicBuildDispatchInitiation.js +17 -0
  140. package/dist/server/lib/epicBuildDispatchInitiation.js.map +1 -0
  141. package/dist/server/lib/epicCheckpointAdmission.js +10 -0
  142. package/dist/server/lib/epicCheckpointAdmission.js.map +1 -0
  143. package/dist/server/lib/epicCheckpointAdmissionError.js +7 -0
  144. package/dist/server/lib/epicCheckpointAdmissionError.js.map +1 -0
  145. package/dist/server/lib/epicCheckpointAutomationIntegration.js +168 -0
  146. package/dist/server/lib/epicCheckpointAutomationIntegration.js.map +1 -0
  147. package/dist/server/lib/epicCheckpointContinuationSchema.js +93 -0
  148. package/dist/server/lib/epicCheckpointContinuationSchema.js.map +1 -0
  149. package/dist/server/lib/epicCheckpointContinuations.js +219 -0
  150. package/dist/server/lib/epicCheckpointContinuations.js.map +1 -0
  151. package/dist/server/lib/epicCheckpointTicketIntegration.js +69 -0
  152. package/dist/server/lib/epicCheckpointTicketIntegration.js.map +1 -0
  153. package/dist/server/lib/epicCommandRequests.js +30 -0
  154. package/dist/server/lib/epicCommandRequests.js.map +1 -0
  155. package/dist/server/lib/epicConversationStore.js +88 -0
  156. package/dist/server/lib/epicConversationStore.js.map +1 -0
  157. package/dist/server/lib/epicDeletedTargets.js +36 -0
  158. package/dist/server/lib/epicDeletedTargets.js.map +1 -0
  159. package/dist/server/lib/epicDeletion.js +101 -0
  160. package/dist/server/lib/epicDeletion.js.map +1 -0
  161. package/dist/server/lib/epicDeletionOperations.js +31 -0
  162. package/dist/server/lib/epicDeletionOperations.js.map +1 -0
  163. package/dist/server/lib/epicDeletionRuntime.js +63 -0
  164. package/dist/server/lib/epicDeletionRuntime.js.map +1 -0
  165. package/dist/server/lib/epicExecutionLineage.js +70 -0
  166. package/dist/server/lib/epicExecutionLineage.js.map +1 -0
  167. package/dist/server/lib/epicExecutionPlanOwnership.js +15 -0
  168. package/dist/server/lib/epicExecutionPlanOwnership.js.map +1 -0
  169. package/dist/server/lib/epicExecutionPlans.js +150 -0
  170. package/dist/server/lib/epicExecutionPlans.js.map +1 -0
  171. package/dist/server/lib/epicExecutionRecovery.js +651 -0
  172. package/dist/server/lib/epicExecutionRecovery.js.map +1 -0
  173. package/dist/server/lib/epicExport.js +186 -0
  174. package/dist/server/lib/epicExport.js.map +1 -0
  175. package/dist/server/lib/epicFollowUpDeferral.js +16 -0
  176. package/dist/server/lib/epicFollowUpDeferral.js.map +1 -0
  177. package/dist/server/lib/epicMaterialization.js +468 -0
  178. package/dist/server/lib/epicMaterialization.js.map +1 -0
  179. package/dist/server/lib/epicMessages.js +21 -0
  180. package/dist/server/lib/epicMessages.js.map +1 -0
  181. package/dist/server/lib/epicNumberSchema.js +56 -0
  182. package/dist/server/lib/epicNumberSchema.js.map +1 -0
  183. package/dist/server/lib/epicOperations.js +431 -0
  184. package/dist/server/lib/epicOperations.js.map +1 -0
  185. package/dist/server/lib/epicOrchestration.js +569 -0
  186. package/dist/server/lib/epicOrchestration.js.map +1 -0
  187. package/dist/server/lib/epicOwnedRuns.js +13 -0
  188. package/dist/server/lib/epicOwnedRuns.js.map +1 -0
  189. package/dist/server/lib/epicPackageInventory.js +49 -0
  190. package/dist/server/lib/epicPackageInventory.js.map +1 -0
  191. package/dist/server/lib/epicPlanArtifacts.js +85 -0
  192. package/dist/server/lib/epicPlanArtifacts.js.map +1 -0
  193. package/dist/server/lib/epicPlanDocuments.js +82 -0
  194. package/dist/server/lib/epicPlanDocuments.js.map +1 -0
  195. package/dist/server/lib/epicPlanningOperations.js +118 -0
  196. package/dist/server/lib/epicPlanningOperations.js.map +1 -0
  197. package/dist/server/lib/epicPlanningRestartRecovery.js +101 -0
  198. package/dist/server/lib/epicPlanningRestartRecovery.js.map +1 -0
  199. package/dist/server/lib/epicPlanningStartupRecovery.js +28 -0
  200. package/dist/server/lib/epicPlanningStartupRecovery.js.map +1 -0
  201. package/dist/server/lib/epicPlanningStore.js +157 -0
  202. package/dist/server/lib/epicPlanningStore.js.map +1 -0
  203. package/dist/server/lib/epicPlanningWorkspace.js +297 -0
  204. package/dist/server/lib/epicPlanningWorkspace.js.map +1 -0
  205. package/dist/server/lib/epicPostMergeEvidence.js +83 -0
  206. package/dist/server/lib/epicPostMergeEvidence.js.map +1 -0
  207. package/dist/server/lib/epicProposals.js +127 -0
  208. package/dist/server/lib/epicProposals.js.map +1 -0
  209. package/dist/server/lib/epicPullRequestExternalOwnership.js +192 -0
  210. package/dist/server/lib/epicPullRequestExternalOwnership.js.map +1 -0
  211. package/dist/server/lib/epicPullRequestObservation.js +95 -0
  212. package/dist/server/lib/epicPullRequestObservation.js.map +1 -0
  213. package/dist/server/lib/epicPullRequestOwnership.js +224 -0
  214. package/dist/server/lib/epicPullRequestOwnership.js.map +1 -0
  215. package/dist/server/lib/epicPullRequestRecovery.js +66 -0
  216. package/dist/server/lib/epicPullRequestRecovery.js.map +1 -0
  217. package/dist/server/lib/epicPullRequestTracking.js +353 -0
  218. package/dist/server/lib/epicPullRequestTracking.js.map +1 -0
  219. package/dist/server/lib/epicReconciliation.js +308 -0
  220. package/dist/server/lib/epicReconciliation.js.map +1 -0
  221. package/dist/server/lib/epicRecovery.js +71 -0
  222. package/dist/server/lib/epicRecovery.js.map +1 -0
  223. package/dist/server/lib/epicReferenceNotifications.js +29 -0
  224. package/dist/server/lib/epicReferenceNotifications.js.map +1 -0
  225. package/dist/server/lib/epicReferences.js +29 -0
  226. package/dist/server/lib/epicReferences.js.map +1 -0
  227. package/dist/server/lib/epicRepositoryIdentity.js +5 -0
  228. package/dist/server/lib/epicRepositoryIdentity.js.map +1 -0
  229. package/dist/server/lib/epicRevisionGuards.js +80 -0
  230. package/dist/server/lib/epicRevisionGuards.js.map +1 -0
  231. package/dist/server/lib/epicRoadmapValidation.js +99 -0
  232. package/dist/server/lib/epicRoadmapValidation.js.map +1 -0
  233. package/dist/server/lib/epicSchema.js +449 -0
  234. package/dist/server/lib/epicSchema.js.map +1 -0
  235. package/dist/server/lib/epicStepCheckApplicability.js +19 -0
  236. package/dist/server/lib/epicStepCheckApplicability.js.map +1 -0
  237. package/dist/server/lib/epicTargetChecks.js +59 -0
  238. package/dist/server/lib/epicTargetChecks.js.map +1 -0
  239. package/dist/server/lib/epicTargetObservation.js +28 -0
  240. package/dist/server/lib/epicTargetObservation.js.map +1 -0
  241. package/dist/server/lib/epics.js +840 -0
  242. package/dist/server/lib/epics.js.map +1 -0
  243. package/dist/server/lib/executionInterruption.js +20 -0
  244. package/dist/server/lib/executionInterruption.js.map +1 -0
  245. package/dist/server/lib/executionReconciliation.js +24 -5
  246. package/dist/server/lib/executionReconciliation.js.map +1 -1
  247. package/dist/server/lib/executionRetry.js +11 -1
  248. package/dist/server/lib/executionRetry.js.map +1 -1
  249. package/dist/server/lib/executionRetryContext.js +3 -2
  250. package/dist/server/lib/executionRetryContext.js.map +1 -1
  251. package/dist/server/lib/executionRunAuthority.js +4 -0
  252. package/dist/server/lib/executionRunAuthority.js.map +1 -1
  253. package/dist/server/lib/executionRunLinkMigration.js +37 -0
  254. package/dist/server/lib/executionRunLinkMigration.js.map +1 -0
  255. package/dist/server/lib/executionRunNotifications.js +104 -0
  256. package/dist/server/lib/executionRunNotifications.js.map +1 -0
  257. package/dist/server/lib/executionRuns.js +35 -20
  258. package/dist/server/lib/executionRuns.js.map +1 -1
  259. package/dist/server/lib/executionTimelineScope.js +30 -0
  260. package/dist/server/lib/executionTimelineScope.js.map +1 -0
  261. package/dist/server/lib/executionWorkloads.js +1 -1
  262. package/dist/server/lib/executionWorkloads.js.map +1 -1
  263. package/dist/server/lib/externalSource.js +18 -0
  264. package/dist/server/lib/externalSource.js.map +1 -1
  265. package/dist/server/lib/genericToolCall.js +7 -4
  266. package/dist/server/lib/genericToolCall.js.map +1 -1
  267. package/dist/server/lib/git.js +19 -2
  268. package/dist/server/lib/git.js.map +1 -1
  269. package/dist/server/lib/gitBranchTracking.js +26 -0
  270. package/dist/server/lib/gitBranchTracking.js.map +1 -0
  271. package/dist/server/lib/gitRebaseState.js +38 -0
  272. package/dist/server/lib/gitRebaseState.js.map +1 -0
  273. package/dist/server/lib/httpError.js +3 -1
  274. package/dist/server/lib/httpError.js.map +1 -1
  275. package/dist/server/lib/i18n/checkRepairPolicy.js +13 -0
  276. package/dist/server/lib/i18n/checkRepairPolicy.js.map +1 -0
  277. package/dist/server/lib/i18n/epicExecution.js +131 -0
  278. package/dist/server/lib/i18n/epicExecution.js.map +1 -0
  279. package/dist/server/lib/i18n/epicPlanning.js +83 -0
  280. package/dist/server/lib/i18n/epicPlanning.js.map +1 -0
  281. package/dist/server/lib/i18n/epicProposals.js +18 -0
  282. package/dist/server/lib/i18n/epicProposals.js.map +1 -0
  283. package/dist/server/lib/i18n/resources.js +14 -0
  284. package/dist/server/lib/i18n/resources.js.map +1 -1
  285. package/dist/server/lib/i18n/specPlanning.js +85 -0
  286. package/dist/server/lib/i18n/specPlanning.js.map +1 -0
  287. package/dist/server/lib/integrations/github.js +50 -11
  288. package/dist/server/lib/integrations/github.js.map +1 -1
  289. package/dist/server/lib/jsonControlChars.js +41 -0
  290. package/dist/server/lib/jsonControlChars.js.map +1 -0
  291. package/dist/server/lib/lightweightPrompt.js +20 -4
  292. package/dist/server/lib/lightweightPrompt.js.map +1 -1
  293. package/dist/server/lib/mobileAccess.js +12 -20
  294. package/dist/server/lib/mobileAccess.js.map +1 -1
  295. package/dist/server/lib/opencodeActivity.js +58 -0
  296. package/dist/server/lib/opencodeActivity.js.map +1 -0
  297. package/dist/server/lib/opencodeApprovalContext.js +2 -2
  298. package/dist/server/lib/opencodeApprovalContext.js.map +1 -1
  299. package/dist/server/lib/opencodeApprovalRoutes.js +1 -1
  300. package/dist/server/lib/opencodeApprovalRoutes.js.map +1 -1
  301. package/dist/server/lib/opencodeApprovalSchema.js +13 -1
  302. package/dist/server/lib/opencodeApprovalSchema.js.map +1 -1
  303. package/dist/server/lib/opencodeApprovalTransport.js +83 -44
  304. package/dist/server/lib/opencodeApprovalTransport.js.map +1 -1
  305. package/dist/server/lib/opencodeDescendantPermissions.js +52 -0
  306. package/dist/server/lib/opencodeDescendantPermissions.js.map +1 -0
  307. package/dist/server/lib/opencodeGuestTrustedPaths.js +44 -0
  308. package/dist/server/lib/opencodeGuestTrustedPaths.js.map +1 -0
  309. package/dist/server/lib/opencodeRunRouting.js +56 -0
  310. package/dist/server/lib/opencodeRunRouting.js.map +1 -0
  311. package/dist/server/lib/opencodeShellActivity.js +30 -0
  312. package/dist/server/lib/opencodeShellActivity.js.map +1 -0
  313. package/dist/server/lib/opencodeStream.js +3 -2
  314. package/dist/server/lib/opencodeStream.js.map +1 -1
  315. package/dist/server/lib/opencodeSubagentActivity.js +19 -0
  316. package/dist/server/lib/opencodeSubagentActivity.js.map +1 -0
  317. package/dist/server/lib/opencodeToolApprovals.js +1 -1
  318. package/dist/server/lib/opencodeToolApprovals.js.map +1 -1
  319. package/dist/server/lib/planModeQuestions.js +1 -1
  320. package/dist/server/lib/planModeQuestions.js.map +1 -1
  321. package/dist/server/lib/postBuildCheckRuns.js +81 -12
  322. package/dist/server/lib/postBuildCheckRuns.js.map +1 -1
  323. package/dist/server/lib/postBuildChecks.js +22 -1
  324. package/dist/server/lib/postBuildChecks.js.map +1 -1
  325. package/dist/server/lib/projectMemorySelections.js +4 -0
  326. package/dist/server/lib/projectMemorySelections.js.map +1 -1
  327. package/dist/server/lib/requiredCheckPolicy.js +12 -2
  328. package/dist/server/lib/requiredCheckPolicy.js.map +1 -1
  329. package/dist/server/lib/rootCheckGateEvidence.js +116 -0
  330. package/dist/server/lib/rootCheckGateEvidence.js.map +1 -0
  331. package/dist/server/lib/specAgentRuntime.js +37 -0
  332. package/dist/server/lib/specAgentRuntime.js.map +1 -0
  333. package/dist/server/lib/specArtifact.js +13 -54
  334. package/dist/server/lib/specArtifact.js.map +1 -1
  335. package/dist/server/lib/specDraft.js +2 -0
  336. package/dist/server/lib/specDraft.js.map +1 -1
  337. package/dist/server/lib/specEpicPlanFormatting.js +38 -0
  338. package/dist/server/lib/specEpicPlanFormatting.js.map +1 -0
  339. package/dist/server/lib/specExport.js +17 -7
  340. package/dist/server/lib/specExport.js.map +1 -1
  341. package/dist/server/lib/specMessages.js +9 -2
  342. package/dist/server/lib/specMessages.js.map +1 -1
  343. package/dist/server/lib/specOperations.js +76 -2
  344. package/dist/server/lib/specOperations.js.map +1 -1
  345. package/dist/server/lib/specPlanningArtifactAuthority.js +10 -0
  346. package/dist/server/lib/specPlanningArtifactAuthority.js.map +1 -0
  347. package/dist/server/lib/specPlanningReferences.js +147 -0
  348. package/dist/server/lib/specPlanningReferences.js.map +1 -0
  349. package/dist/server/lib/specPlanningSchema.js +39 -0
  350. package/dist/server/lib/specPlanningSchema.js.map +1 -0
  351. package/dist/server/lib/specPlanningTargets.js +53 -0
  352. package/dist/server/lib/specPlanningTargets.js.map +1 -0
  353. package/dist/server/lib/specReviewContext.js +31 -9
  354. package/dist/server/lib/specReviewContext.js.map +1 -1
  355. package/dist/server/lib/specReviewDraft.js +7 -2
  356. package/dist/server/lib/specReviewDraft.js.map +1 -1
  357. package/dist/server/lib/specReviewOperations.js +2 -0
  358. package/dist/server/lib/specReviewOperations.js.map +1 -1
  359. package/dist/server/lib/specReviewValidation.js +19 -0
  360. package/dist/server/lib/specReviewValidation.js.map +1 -1
  361. package/dist/server/lib/specTicketMaterialization.js +2 -0
  362. package/dist/server/lib/specTicketMaterialization.js.map +1 -1
  363. package/dist/server/lib/specs.js +116 -47
  364. package/dist/server/lib/specs.js.map +1 -1
  365. package/dist/server/lib/ticketAutomationCommit.js +95 -22
  366. package/dist/server/lib/ticketAutomationCommit.js.map +1 -1
  367. package/dist/server/lib/ticketPostBuildCheckRerun.js +124 -0
  368. package/dist/server/lib/ticketPostBuildCheckRerun.js.map +1 -0
  369. package/dist/server/lib/ticketRunOperations.js +4 -3
  370. package/dist/server/lib/ticketRunOperations.js.map +1 -1
  371. package/dist/server/lib/tickets.js +26 -5
  372. package/dist/server/lib/tickets.js.map +1 -1
  373. package/dist/server/lib/transcriptRuns.js +105 -3
  374. package/dist/server/lib/transcriptRuns.js.map +1 -1
  375. package/dist/server/lib/types.js +5 -1
  376. package/dist/server/lib/types.js.map +1 -1
  377. package/dist/server/workers/build.js +85 -43
  378. package/dist/server/workers/build.js.map +1 -1
  379. package/dist/server/workers/buildStatus.js +27 -0
  380. package/dist/server/workers/buildStatus.js.map +1 -0
  381. package/dist/server/workers/epicArtifactContract.js +156 -0
  382. package/dist/server/workers/epicArtifactContract.js.map +1 -0
  383. package/dist/server/workers/epicAssessmentResponse.js +27 -0
  384. package/dist/server/workers/epicAssessmentResponse.js.map +1 -0
  385. package/dist/server/workers/epicConversation.js +477 -0
  386. package/dist/server/workers/epicConversation.js.map +1 -0
  387. package/dist/server/workers/epicPlanning.js +661 -0
  388. package/dist/server/workers/epicPlanning.js.map +1 -0
  389. package/dist/server/workers/epicSpecArtifactContract.js +21 -0
  390. package/dist/server/workers/epicSpecArtifactContract.js.map +1 -0
  391. package/dist/server/workers/followUp.js +96 -37
  392. package/dist/server/workers/followUp.js.map +1 -1
  393. package/dist/server/workers/plan.js +15 -9
  394. package/dist/server/workers/plan.js.map +1 -1
  395. package/dist/server/workers/postBuildCheckRecovery.js +156 -0
  396. package/dist/server/workers/postBuildCheckRecovery.js.map +1 -0
  397. package/dist/server/workers/specEpicArtifact.js +4 -0
  398. package/dist/server/workers/specEpicArtifact.js.map +1 -0
  399. package/dist/server/workers/specSession.js +68 -28
  400. package/dist/server/workers/specSession.js.map +1 -1
  401. package/dist/shared/epicPlan.js +336 -0
  402. package/dist/shared/epicPlan.js.map +1 -0
  403. package/dist/shared/epics.js +115 -0
  404. package/dist/shared/epics.js.map +1 -0
  405. package/dist/shared/specPlanning.js +2 -0
  406. package/dist/shared/specPlanning.js.map +1 -0
  407. package/dist/shared/transcriptRuns.js +2 -0
  408. package/dist/shared/transcriptRuns.js.map +1 -0
  409. package/package.json +1 -1
  410. package/dist/client/assets/channel-BvWs2-ry.js +0 -1
  411. package/dist/client/assets/classDiagram-4FO5ZUOK-CXujfiH2.js +0 -1
  412. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-BpQoPe_W.js +0 -1
  413. package/dist/client/assets/index-C1ZNfkTu.css +0 -2
  414. package/dist/client/assets/index-C8n_tSJG.js +0 -293
  415. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-Bkxwy8iL.js +0 -1
@@ -0,0 +1,651 @@
1
+ import db from '../db.js';
2
+ import { resolveBuildCheckpointSuccessor } from './buildCheckpointSuccessor.js';
3
+ import { getEpic } from './epics.js';
4
+ import { getExecutionRun, listExecutionRunLinks, appendLifecycleEvent } from './executionRuns.js';
5
+ import { getEpicCheckpointContinuation } from './epicCheckpointContinuations.js';
6
+ import { assertEpicCheckpointPlanOwnership } from './epicCheckpointContinuations.js';
7
+ import { assertEpicBuildAdmission } from './epicAdmission.js';
8
+ import { resolveBuildTicketCommitCheckpointLineage } from './buildTicketCommit.js';
9
+ import { recoverProjectEpicCheckpoints } from './epicRecovery.js';
10
+ import { getTicket, resolveTicketWorkerKey } from './tickets.js';
11
+ import { getEffectiveProject } from './projects.js';
12
+ import { getBundleAutomationState } from './ticketAutomation.js';
13
+ import { enqueue, isRunning } from './queue.js';
14
+ import { isLatestTicketBuildSource, finalizePostBuildCheckTicket, markPostBuildCheckFinalizationComplete, beginBlockedPostBuildCheckRecovery, hasActivePostBuildCheck, markPostBuildCheckAdmission } from './postBuildCheckRuns.js';
15
+ import { getCheckBatchDetails } from './checkRuns.js';
16
+ import { normalizeProjectMemorySuggestions } from './projectMemorySuggestions.js';
17
+ import { validateWorkflowContext } from './types.js';
18
+ import { completeAutomationProgression, interruptAutomationProgression, resolveProgressionForChild, runAutomationProgression, waitAutomationProgression } from './automationProgression.js';
19
+ import { getActiveAutomationChild } from './activeAutomationChild.js';
20
+ import { listEpicOwnedRuns } from './epicOwnedRuns.js';
21
+ import { getActiveReviewRepairIteration, getReviewRepairIterationByVerification } from './reviewRepairIterations.js';
22
+ import { epicExecutionMessage } from './i18n/epicExecution.js';
23
+ const recoveringSources = new Set();
24
+ const busy = new Map();
25
+ const ownRecovery = (projectId, epicId) => {
26
+ const key = JSON.stringify([projectId, epicId]);
27
+ busy.set(key, (busy.get(key) ?? 0) + 1);
28
+ return () => {
29
+ const remaining = busy.get(key) - 1;
30
+ if (remaining) {
31
+ busy.set(key, remaining);
32
+ }
33
+ else {
34
+ busy.delete(key);
35
+ }
36
+ };
37
+ };
38
+ /** Includes queued recovery callbacks, asynchronous admission and stop operations. */
39
+ export const isEpicExecutionRecoveryBusy = (projectId, epicId) => busy.has(JSON.stringify([projectId, epicId]));
40
+ const eligible = (projectId, epicId) => {
41
+ const epic = getEpic(epicId, projectId);
42
+ const project = db.prepare('SELECT deletion_started_at FROM projects WHERE id = ?').get(projectId);
43
+ return Boolean(epic && project && !project.deletion_started_at && epic.execution_intent === 'running'
44
+ && !epic.blockers.length && !['completed', 'cancelled', 'failed'].includes(epic.phase));
45
+ };
46
+ const independentlyPaused = (projectId, bundleId) => {
47
+ const state = bundleId ? getBundleAutomationState(projectId, bundleId) : null;
48
+ return state?.automation_pause_reason_code === 'manual_transition' || state?.automation_paused_code === 'open_questions';
49
+ };
50
+ const latestTicketBuild = (projectId, ticketId) => db.prepare(`SELECT run.id FROM execution_runs run
51
+ JOIN execution_run_links link ON link.execution_run_id = run.id AND link.project_id = run.project_id
52
+ WHERE run.project_id = ? AND link.entity_type = 'ticket' AND link.entity_id = ? AND link.relationship = 'primary'
53
+ AND run.kind IN ('build', 'build_follow_up') ORDER BY run.rowid DESC LIMIT 1`)
54
+ .get(projectId, ticketId);
55
+ const recoveredWorkflowContext = (source) => validateWorkflowContext(Object.fromEntries(Object.entries(source.metadata ?? {}).filter((entry) => typeof entry[1] === 'string')));
56
+ const deferInterruptedRecovery = (projectId, epicId, source, reason, io) => {
57
+ if (!db.prepare(`SELECT 1 FROM lifecycle_events WHERE project_id = ? AND execution_run_id = ?
58
+ AND event_type = 'epic_execution_recovery_deferred' AND json_extract(metadata_json, '$.reason') = ?`)
59
+ .get(projectId, source.id, reason)) {
60
+ appendLifecycleEvent({ projectId, runId: source.id, eventType: 'epic_execution_recovery_deferred',
61
+ message: reason, metadata: { epic_id: epicId, reason } }, io);
62
+ }
63
+ };
64
+ const resumeInterruptedBuild = async (projectId, epicId, source, io) => {
65
+ const ticketId = listExecutionRunLinks(projectId, source.id).find(link => link.entity_type === 'ticket' && link.relationship === 'primary')?.entity_id;
66
+ const ticket = ticketId ? getTicket(ticketId) : null;
67
+ const key = ticket ? resolveTicketWorkerKey(ticket, 'build') : null;
68
+ const state = ticket?.worktree_bundle_id ? getBundleAutomationState(projectId, ticket.worktree_bundle_id) : null;
69
+ const neverStarted = source.started_at === null && source.kind === 'build';
70
+ const recoverableTicket = (candidate) => neverStarted
71
+ ? candidate.state === 'build' && candidate.agent_status !== 'stopped'
72
+ : ['build', 'review'].includes(candidate.state) && ['error', 'running'].includes(candidate.agent_status ?? '');
73
+ if (!ticket || ticket.project_id !== projectId || !key || !['build', 'review'].includes(ticket.state)
74
+ || !recoverableTicket(ticket) || independentlyPaused(projectId, ticket.worktree_bundle_id)
75
+ || (state?.automation_pause_reason_code && state.automation_pause_reason_code !== 'server_restart')
76
+ || latestTicketBuild(projectId, ticket.id)?.id !== source.id) {
77
+ return { dispatched: 0, busy: 0 };
78
+ }
79
+ if (!ticket.session_id && !neverStarted) {
80
+ deferInterruptedRecovery(projectId, epicId, source, epicExecutionMessage('recoveryBuildSessionMissing'), io);
81
+ return { dispatched: 0, busy: 0 };
82
+ }
83
+ const recoveryKey = `${projectId}:${source.id}`;
84
+ if (isRunning(key) || recoveringSources.has(recoveryKey)) {
85
+ return { dispatched: 0, busy: 1 };
86
+ }
87
+ recoveringSources.add(recoveryKey);
88
+ try {
89
+ const buildWorker = await import('../workers/build.js');
90
+ const { getBuildSequenceIdForTicket } = await import('./buildSequences.js');
91
+ if (!eligible(projectId, epicId)) {
92
+ return { dispatched: 0, busy: 0 };
93
+ }
94
+ // Failed startup sequence ownership can be restored only from its exact
95
+ // accepted activation; never adopt another sequence or revive completed items.
96
+ const retained = db.prepare(`SELECT sequence.id, sequence.status, item.status AS item_status FROM build_sequences sequence
97
+ JOIN build_sequence_tickets item ON item.build_sequence_id = sequence.id
98
+ WHERE sequence.project_id = ? AND sequence.worktree_bundle_id = ? AND item.ticket_id = ?
99
+ AND item.activation_execution_run_id = ? AND sequence.status IN ('active', 'failed')`)
100
+ .get(projectId, ticket.worktree_bundle_id, ticket.id, source.id);
101
+ const sequenceId = retained?.id ?? getBuildSequenceIdForTicket(ticket.id);
102
+ if (!retained && ticket.worktree_bundle_id) {
103
+ const activeItem = sequenceId ? db.prepare(`SELECT status, activation_execution_run_id FROM build_sequence_tickets
104
+ WHERE build_sequence_id = ? AND ticket_id = ?`).get(sequenceId, ticket.id) : undefined;
105
+ if (activeItem?.status !== 'active' || (activeItem.activation_execution_run_id
106
+ && !listEpicOwnedRuns(projectId, epicId).some(run => run.id === activeItem.activation_execution_run_id))) {
107
+ return { dispatched: 0, busy: 0 };
108
+ }
109
+ }
110
+ if (retained && ((retained.status === 'active' && retained.item_status !== 'active')
111
+ || (retained.status === 'failed' && retained.item_status !== 'failed'))) {
112
+ return { dispatched: 0, busy: 0 };
113
+ }
114
+ const schedule = neverStarted ? buildWorker.startBuild : buildWorker.resumeBuild;
115
+ const scheduling = schedule(ticket, io, {
116
+ sequenceId, initiation: { initiator: 'automation', causalParentRunId: source.id, workflowContext: recoveredWorkflowContext(source) },
117
+ accept: () => {
118
+ const live = getTicket(ticket.id);
119
+ const pause = live?.worktree_bundle_id ? getBundleAutomationState(projectId, live.worktree_bundle_id) : null;
120
+ const liveSource = getExecutionRun(projectId, source.id);
121
+ if (!eligible(projectId, epicId) || !live || live.project_id !== projectId || (!neverStarted && !live.session_id)
122
+ || independentlyPaused(projectId, live.worktree_bundle_id)
123
+ || !recoverableTicket(live)
124
+ || (pause?.automation_pause_reason_code && pause.automation_pause_reason_code !== 'server_restart')
125
+ || latestTicketBuild(projectId, ticket.id)?.id !== source.id
126
+ || liveSource?.status !== 'interrupted' || liveSource.failure?.code !== 'server_restarted'
127
+ || (neverStarted && liveSource.started_at !== null)
128
+ || !listEpicOwnedRuns(projectId, epicId).some(run => run.id === source.id)) {
129
+ throw new Error(epicExecutionMessage('recoveryBuildUnavailable'));
130
+ }
131
+ if (retained) {
132
+ const owned = db.prepare(`SELECT sequence.status, item.status AS item_status, item.activation_execution_run_id
133
+ FROM build_sequences sequence JOIN build_sequence_tickets item ON item.build_sequence_id = sequence.id
134
+ WHERE sequence.id = ? AND sequence.project_id = ? AND sequence.worktree_bundle_id = ? AND item.ticket_id = ?`)
135
+ .get(retained.id, projectId, live.worktree_bundle_id, live.id);
136
+ if (owned?.status !== retained.status || owned.item_status !== retained.item_status || owned.activation_execution_run_id !== source.id) {
137
+ throw new Error(epicExecutionMessage('recoveryBuildSequenceOwnershipChanged'));
138
+ }
139
+ }
140
+ else if (live.worktree_bundle_id) {
141
+ const owned = db.prepare(`SELECT sequence.status, item.status AS item_status, item.activation_execution_run_id
142
+ FROM build_sequences sequence JOIN build_sequence_tickets item ON item.build_sequence_id = sequence.id
143
+ WHERE sequence.id = ? AND sequence.project_id = ? AND sequence.worktree_bundle_id = ? AND item.ticket_id = ?`)
144
+ .get(sequenceId, projectId, live.worktree_bundle_id, live.id);
145
+ if (owned?.status !== 'active' || owned.item_status !== 'active' || (owned.activation_execution_run_id
146
+ && !listEpicOwnedRuns(projectId, epicId).some(run => run.id === owned.activation_execution_run_id))) {
147
+ throw new Error(epicExecutionMessage('recoveryBuildSequenceOwnershipChanged'));
148
+ }
149
+ }
150
+ let compensate;
151
+ if (retained?.status === 'failed') {
152
+ if (retained.item_status !== 'failed' || db.prepare(`SELECT 1 FROM build_sequences WHERE project_id = ?
153
+ AND worktree_bundle_id = ? AND status = 'active' AND id <> ?`).get(projectId, live.worktree_bundle_id, retained.id)) {
154
+ throw new Error(epicExecutionMessage('recoveryBuildSequenceManual'));
155
+ }
156
+ const sequence = db.prepare('SELECT updated_at FROM build_sequences WHERE id = ?').get(retained.id);
157
+ const items = db.prepare(`SELECT ticket_id, status, finished_at FROM build_sequence_tickets WHERE build_sequence_id = ?
158
+ AND (ticket_id = ? OR (status = 'cancelled' AND activation_execution_run_id IS NULL
159
+ AND finished_at = (SELECT finished_at FROM build_sequence_tickets WHERE build_sequence_id = ? AND ticket_id = ?)
160
+ AND position > (SELECT position FROM build_sequence_tickets WHERE build_sequence_id = ? AND ticket_id = ?)))`)
161
+ .all(retained.id, live.id, retained.id, live.id, retained.id, live.id);
162
+ // Only the startup-cancelled tail with the same interruption timestamp
163
+ // is eligible; independently cancelled items retain their authority.
164
+ db.prepare(`UPDATE build_sequence_tickets SET status = 'queued', finished_at = NULL
165
+ WHERE build_sequence_id = ? AND ticket_id IN (${items.filter(item => item.ticket_id !== live.id).map(() => '?').join(', ') || 'NULL'})`)
166
+ .run(retained.id, ...items.filter(item => item.ticket_id !== live.id).map(item => item.ticket_id));
167
+ db.prepare("UPDATE build_sequences SET status = 'active', updated_at = CURRENT_TIMESTAMP WHERE id = ? AND status = 'failed'").run(retained.id);
168
+ db.prepare("UPDATE build_sequence_tickets SET status = 'active', finished_at = NULL WHERE build_sequence_id = ? AND ticket_id = ? AND status = 'failed'").run(retained.id, live.id);
169
+ compensate = () => {
170
+ db.prepare("UPDATE build_sequences SET status = 'failed', updated_at = ? WHERE id = ?").run(sequence.updated_at, retained.id);
171
+ for (const item of items) {
172
+ db.prepare('UPDATE build_sequence_tickets SET status = ?, finished_at = ? WHERE build_sequence_id = ? AND ticket_id = ?')
173
+ .run(item.status, item.finished_at, retained.id, item.ticket_id);
174
+ }
175
+ };
176
+ }
177
+ if (neverStarted && sequenceId) {
178
+ const binding = db.prepare(`SELECT activation_execution_run_id FROM build_sequence_tickets
179
+ WHERE build_sequence_id = ? AND ticket_id = ? AND status = 'active'`)
180
+ .get(sequenceId, live.id);
181
+ if (!binding || (binding.activation_execution_run_id && binding.activation_execution_run_id !== source.id)) {
182
+ throw new Error(epicExecutionMessage('recoveryBuildActivationMismatch'));
183
+ }
184
+ // Fresh admission binds a new run; release only the proven never-started
185
+ // activation inside that same admission transaction, retaining its history.
186
+ const changed = db.prepare(`UPDATE build_sequence_tickets SET activation_execution_run_id = NULL
187
+ WHERE build_sequence_id = ? AND ticket_id = ? AND status = 'active' AND activation_execution_run_id IS ?`)
188
+ .run(sequenceId, live.id, binding.activation_execution_run_id);
189
+ if (changed.changes !== 1) {
190
+ throw new Error(epicExecutionMessage('recoveryBuildActivationChanged'));
191
+ }
192
+ const compensateSequence = compensate;
193
+ compensate = () => {
194
+ db.prepare('UPDATE build_sequence_tickets SET activation_execution_run_id = ? WHERE build_sequence_id = ? AND ticket_id = ?')
195
+ .run(binding.activation_execution_run_id, sequenceId, live.id);
196
+ compensateSequence?.();
197
+ };
198
+ }
199
+ return { ticket: live, sequenceId, compensate };
200
+ },
201
+ });
202
+ if (!scheduling.accepted && scheduling.reason !== 'busy') {
203
+ deferInterruptedRecovery(projectId, epicId, source, epicExecutionMessage('recoveryBuildSchedulingFailed', { error: scheduling.error }), io);
204
+ }
205
+ return { dispatched: scheduling.accepted ? 1 : 0, busy: 0 };
206
+ }
207
+ catch (error) {
208
+ deferInterruptedRecovery(projectId, epicId, source, epicExecutionMessage('recoveryBuildAttentionRequired', {
209
+ error: error instanceof Error ? error.message : String(error),
210
+ }), io);
211
+ return { dispatched: 0, busy: 0 };
212
+ }
213
+ finally {
214
+ recoveringSources.delete(recoveryKey);
215
+ }
216
+ };
217
+ const resumeInterruptedReview = async (projectId, epicId, source, io) => {
218
+ const ticketId = listExecutionRunLinks(projectId, source.id).find(link => link.entity_type === 'ticket' && link.relationship === 'primary')?.entity_id;
219
+ const ticket = ticketId ? getTicket(ticketId) : null;
220
+ const latest = () => db.prepare(`SELECT run.id FROM execution_runs run JOIN execution_run_links link
221
+ ON link.execution_run_id = run.id AND link.project_id = run.project_id WHERE run.project_id = ?
222
+ AND link.entity_type = 'ticket' AND link.entity_id = ? AND link.relationship = 'primary'
223
+ AND run.kind IN ('review', 'build', 'build_follow_up') ORDER BY run.rowid DESC LIMIT 1`).get(projectId, ticketId);
224
+ if (!ticket || ticket.project_id !== projectId || latest()?.id !== source.id
225
+ || independentlyPaused(projectId, ticket.worktree_bundle_id)) {
226
+ return { dispatched: 0, busy: 0 };
227
+ }
228
+ const key = resolveTicketWorkerKey(ticket, 'review');
229
+ const recoveryKey = `${projectId}:${source.id}`;
230
+ if (key && (isRunning(key) || recoveringSources.has(recoveryKey))) {
231
+ return { dispatched: 0, busy: 1 };
232
+ }
233
+ recoveringSources.add(recoveryKey);
234
+ try {
235
+ const { startReview, resolveReviewContinuation } = await import('../workers/review.js');
236
+ if (!eligible(projectId, epicId)) {
237
+ return { dispatched: 0, busy: 0 };
238
+ }
239
+ const assertRecoverable = () => {
240
+ const live = getTicket(ticket.id);
241
+ const liveSource = getExecutionRun(projectId, source.id);
242
+ const state = live?.worktree_bundle_id ? getBundleAutomationState(projectId, live.worktree_bundle_id) : null;
243
+ if (!eligible(projectId, epicId) || !live || live.project_id !== projectId || live.state !== 'review'
244
+ || live.review_follow_up_active || !['error', 'running'].includes(live.agent_status ?? '')
245
+ || !live.worktree_bundle_id || independentlyPaused(projectId, live.worktree_bundle_id)
246
+ || (state?.automation_pause_reason_code && !['server_restart'].includes(state.automation_pause_reason_code))
247
+ || latest()?.id !== source.id || liveSource?.status !== 'interrupted' || liveSource.failure?.code !== 'server_restarted'
248
+ || !listEpicOwnedRuns(projectId, epicId).some(run => run.id === source.id)) {
249
+ throw new Error(epicExecutionMessage('recoveryReviewContextChanged'));
250
+ }
251
+ const progression = resolveProgressionForChild({ projectId, bundleId: live.worktree_bundle_id, childRunId: source.id });
252
+ if (getActiveAutomationChild(projectId, progression.id)) {
253
+ throw new Error(epicExecutionMessage('recoveryReviewProgressionBusy'));
254
+ }
255
+ // Verification carries gate/workspace evidence and a durable iteration pointer.
256
+ // Generic Review scheduling must not bypass ledger reconciliation or create a second loop.
257
+ if (getReviewRepairIterationByVerification(projectId, source.id) || getActiveReviewRepairIteration(projectId, progression.id)
258
+ || state?.fix_loop_active) {
259
+ throw new Error(epicExecutionMessage('recoveryReviewVerificationReconciliation'));
260
+ }
261
+ return { live, progression };
262
+ };
263
+ const { progression } = assertRecoverable();
264
+ const scheduling = startReview(ticket, io, {
265
+ initiation: { initiator: 'automation', causalParentRunId: progression.id, retrySourceRunId: source.id,
266
+ workflowContext: recoveredWorkflowContext(source) },
267
+ continuation: resolveReviewContinuation(source.id),
268
+ accept: () => {
269
+ const current = assertRecoverable();
270
+ if (current.progression.id !== progression.id) {
271
+ throw new Error(epicExecutionMessage('recoveryReviewProgressionOwnershipChanged'));
272
+ }
273
+ const wasWaiting = current.progression.status === 'waiting';
274
+ if (wasWaiting) {
275
+ runAutomationProgression({ projectId, bundleId: current.live.worktree_bundle_id, progressionRunId: progression.id });
276
+ }
277
+ else if (current.progression.status !== 'running') {
278
+ throw new Error(epicExecutionMessage('recoveryReviewProgressionUnavailable'));
279
+ }
280
+ return { ticket: current.live, compensate: wasWaiting ? () => {
281
+ waitAutomationProgression({ projectId, bundleId: current.live.worktree_bundle_id, progressionRunId: progression.id,
282
+ pauseCode: 'review', pauseReason: epicExecutionMessage('recoveryReviewSchedulingPause'),
283
+ reasonCode: 'server_restart', pausedStageRunId: source.id, broadcaster: io });
284
+ } : undefined };
285
+ },
286
+ });
287
+ if (!scheduling.accepted) {
288
+ if (scheduling.reason !== 'busy') {
289
+ deferInterruptedRecovery(projectId, epicId, source, epicExecutionMessage('recoveryReviewSchedulingFailed', { error: scheduling.error }), io);
290
+ }
291
+ return { dispatched: 0, busy: scheduling.reason === 'busy' ? 1 : 0 };
292
+ }
293
+ return { dispatched: 1, busy: 0 };
294
+ }
295
+ catch (error) {
296
+ deferInterruptedRecovery(projectId, epicId, source, epicExecutionMessage('recoveryReviewAttentionRequired', {
297
+ reason: error instanceof Error ? error.message : String(error),
298
+ }), io);
299
+ return { dispatched: 0, busy: 0 };
300
+ }
301
+ finally {
302
+ recoveringSources.delete(recoveryKey);
303
+ }
304
+ };
305
+ const resolveReceiptSuccessor = (projectId, epicId, checkpoint) => {
306
+ assertEpicCheckpointPlanOwnership(checkpoint);
307
+ return checkpoint.projectId === projectId && checkpoint.epic?.epicId === epicId
308
+ ? resolveBuildCheckpointSuccessor(checkpoint) : { state: 'unavailable' };
309
+ };
310
+ const resumeCompletedBuild = async (projectId, epicId, source, io, releaseOwnerQueue) => {
311
+ if (!eligible(projectId, epicId)) {
312
+ return;
313
+ }
314
+ const ticketId = listExecutionRunLinks(projectId, source.id).find(link => link.entity_type === 'ticket' && link.relationship === 'primary')?.entity_id;
315
+ const ticket = ticketId ? getTicket(ticketId) : null;
316
+ const project = ticket ? getEffectiveProject(ticket) : null;
317
+ if (!ticket || !project || independentlyPaused(projectId, ticket.worktree_bundle_id)
318
+ || !isLatestTicketBuildSource(projectId, source.id, ticket.id)) {
319
+ return;
320
+ }
321
+ const metadata = getExecutionRun(projectId, source.id)?.metadata ?? {};
322
+ const finalization = metadata.post_build_finalization;
323
+ const workflowContext = validateWorkflowContext(Object.fromEntries(Object.entries(metadata).filter((entry) => typeof entry[1] === 'string')));
324
+ const emitUpdatedTickets = (ids) => {
325
+ for (const id of ids) {
326
+ const updated = getTicket(id);
327
+ if (updated) {
328
+ io.emit('ticket:updated', updated);
329
+ }
330
+ }
331
+ };
332
+ if (finalization?.status === 'pending' || finalization?.status === 'blocked') {
333
+ const batchRow = db.prepare(`SELECT details.execution_run_id FROM check_batch_details details JOIN execution_runs run
334
+ ON run.id = details.execution_run_id AND run.project_id = ?
335
+ WHERE details.causal_source_run_id = ? AND details.purpose = 'post_build' ORDER BY run.rowid DESC LIMIT 1`)
336
+ .get(projectId, source.id);
337
+ const batch = batchRow ? getCheckBatchDetails(projectId, batchRow.execution_run_id) : null;
338
+ if (batch && ['queued', 'running', 'waiting'].includes(batch.execution_status)) {
339
+ return;
340
+ }
341
+ const needsChecks = !batch || ['cancelled', 'interrupted'].includes(batch.execution_status);
342
+ if (finalization.status === 'blocked' && !batch && ['failed', 'pending'].includes(finalization.check_admission ?? '')) {
343
+ // Startup finalization may have classified intentionally unadmitted checks
344
+ // as unavailable. Reuse the existing blocked-admission CAS recovery path.
345
+ const recovered = db.transaction(() => {
346
+ if (finalization.check_admission === 'pending') {
347
+ markPostBuildCheckAdmission(projectId, source.id, 'failed');
348
+ }
349
+ return beginBlockedPostBuildCheckRecovery(projectId, ticket.id);
350
+ }).immediate();
351
+ if (!recovered) {
352
+ return;
353
+ }
354
+ }
355
+ const { runPostBuildChecks } = await import('./postBuildChecks.js');
356
+ if (!eligible(projectId, epicId)) {
357
+ return;
358
+ }
359
+ const checks = needsChecks && finalization.check_admission !== 'skipped'
360
+ ? await runPostBuildChecks({ project, sourceRunId: source.id, owner: { kind: 'ticket', ticket },
361
+ emitter: io, onStatusChange: () => emitUpdatedTickets([ticket.id]), releaseOwnerQueue })
362
+ : { batch, error: null };
363
+ if (!eligible(projectId, epicId)) {
364
+ return;
365
+ }
366
+ const finalized = finalizePostBuildCheckTicket({ projectId, sourceRunId: source.id,
367
+ batch: checks?.batch ?? null, error: checks?.error ?? null, getTicket, emitter: io });
368
+ if (!finalized.finalized) {
369
+ return;
370
+ }
371
+ }
372
+ if (!eligible(projectId, epicId)) {
373
+ return;
374
+ }
375
+ const checkpoint = getEpicCheckpointContinuation(projectId, source.id);
376
+ if (checkpoint?.nextStage && (!ticket.worktree_bundle_id || !resolveBuildTicketCommitCheckpointLineage({
377
+ projectId, bundleId: ticket.worktree_bundle_id, progressionRunId: checkpoint.progressionRunId,
378
+ }))) {
379
+ return;
380
+ }
381
+ if (checkpoint?.nextStage && ticket.worktree_bundle_id) {
382
+ const progression = getExecutionRun(projectId, checkpoint.progressionRunId);
383
+ if (progression?.status === 'waiting') {
384
+ runAutomationProgression({ projectId, bundleId: ticket.worktree_bundle_id,
385
+ progressionRunId: checkpoint.progressionRunId, broadcaster: io });
386
+ }
387
+ else if (progression?.status !== 'running'
388
+ || getBundleAutomationState(projectId, ticket.worktree_bundle_id)?.automation_progression_run_id !== checkpoint.progressionRunId
389
+ || getActiveAutomationChild(projectId, checkpoint.progressionRunId)) {
390
+ return;
391
+ }
392
+ }
393
+ const { completeSuccessfulBuildPostFinalization } = await import('./buildCompletionContinuation.js');
394
+ if (!eligible(projectId, epicId)) {
395
+ return;
396
+ }
397
+ let result;
398
+ try {
399
+ result = await completeSuccessfulBuildPostFinalization({ ticket: getTicket(ticket.id) ?? ticket, project,
400
+ parentRunId: source.id, workflowContext, io: io, emitUpdatedTickets,
401
+ memorySuggestions: normalizeProjectMemorySuggestions(finalization?.memory_suggestions), releaseOwnerQueue });
402
+ }
403
+ finally {
404
+ const retained = getEpicCheckpointContinuation(projectId, source.id);
405
+ if (retained?.nextStage && ticket.worktree_bundle_id
406
+ && getExecutionRun(projectId, retained.progressionRunId)?.status === 'running'
407
+ && !getActiveAutomationChild(projectId, retained.progressionRunId)) {
408
+ waitAutomationProgression({ projectId, bundleId: ticket.worktree_bundle_id,
409
+ progressionRunId: retained.progressionRunId, pauseCode: 'commit',
410
+ pauseReason: retained.deferralReason.message, reasonCode: 'reconciliation_failed', pausedStageRunId: null, broadcaster: io });
411
+ }
412
+ }
413
+ if (result.deferred || !eligible(projectId, epicId)) {
414
+ return;
415
+ }
416
+ if (checkpoint && ticket.worktree_bundle_id && getEpicCheckpointContinuation(projectId, source.id)?.nextStage === null
417
+ && ['queued', 'running', 'waiting'].includes(getExecutionRun(projectId, checkpoint.progressionRunId)?.status ?? '')
418
+ && !getActiveAutomationChild(projectId, checkpoint.progressionRunId)) {
419
+ completeAutomationProgression({ projectId, bundleId: ticket.worktree_bundle_id,
420
+ progressionRunId: checkpoint.progressionRunId, broadcaster: io });
421
+ }
422
+ const completedCheckpoint = getEpicCheckpointContinuation(projectId, source.id);
423
+ const advanceReceipt = completedCheckpoint?.completedStages.find(stage => stage.stage === 'advance');
424
+ const receiptSuccessor = completedCheckpoint && advanceReceipt?.stage === 'advance' && advanceReceipt.result.nextTicketId
425
+ ? resolveReceiptSuccessor(projectId, epicId, completedCheckpoint) : null;
426
+ if (receiptSuccessor?.state === 'unavailable') {
427
+ return;
428
+ }
429
+ const next = receiptSuccessor?.state === 'queued' ? receiptSuccessor.ticket : receiptSuccessor ? null : result.nextBuild;
430
+ const sequenceId = receiptSuccessor?.state === 'queued' ? receiptSuccessor.sequenceId : result.nextSequenceId;
431
+ if (result.nextTicketId && !next && receiptSuccessor?.state !== 'accepted') {
432
+ return;
433
+ }
434
+ if (next) {
435
+ releaseOwnerQueue();
436
+ const { startBuild } = await import('../workers/build.js');
437
+ const { prepareTicketForBuild } = await import('./buildFlow.js');
438
+ const { activateQueuedBuildSequenceTicket } = await import('./buildSequences.js');
439
+ const { compensateBuildSequenceTicketActivation } = await import('./buildCompletionContinuation.js');
440
+ const scheduling = startBuild(next, io, { sequenceId,
441
+ initiation: { initiator: 'automation', causalParentRunId: source.id, workflowContext },
442
+ accept: () => {
443
+ if (!eligible(projectId, epicId) || independentlyPaused(projectId, next.worktree_bundle_id)) {
444
+ throw new Error(epicExecutionMessage('recoveryExecutionUnavailable'));
445
+ }
446
+ if (receiptSuccessor && completedCheckpoint) {
447
+ const live = resolveReceiptSuccessor(projectId, epicId, completedCheckpoint);
448
+ if (live.state !== 'queued' || live.ticket.id !== next.id || live.sequenceId !== sequenceId) {
449
+ throw new Error(epicExecutionMessage('recoveryCheckpointSuccessorOwnershipChanged'));
450
+ }
451
+ }
452
+ if (next.worktree_bundle_id) {
453
+ assertEpicBuildAdmission(projectId, next.worktree_bundle_id, { executionRunId: source.id });
454
+ }
455
+ const transition = prepareTicketForBuild(next.id, { ignoredBlockerTicketIds: result.ignoredBlockerTicketIds });
456
+ if (!transition.ok || !sequenceId) {
457
+ throw new Error(transition.ok ? epicExecutionMessage('recoveryBuildSequenceMissing') : transition.error);
458
+ }
459
+ activateQueuedBuildSequenceTicket(sequenceId, transition.ticket.id);
460
+ return { ticket: transition.ticket, sequenceId, compensate: () => compensateBuildSequenceTicketActivation(sequenceId, transition.ticket.id) };
461
+ } });
462
+ if (!scheduling.accepted) {
463
+ return;
464
+ }
465
+ }
466
+ markPostBuildCheckFinalizationComplete(projectId, source.id);
467
+ };
468
+ /** Same worker queue as Build recovery, but the completed Build is never invoked.
469
+ * Check admission/finalization precedes every checkpoint replay. */
470
+ const resumeExecution = async (projectId, epicId, io, options) => {
471
+ const result = { dispatched: 0, busy: 0 };
472
+ if (!eligible(projectId, epicId)) {
473
+ return result;
474
+ }
475
+ recoverProjectEpicCheckpoints(projectId, epicId);
476
+ for (const row of listEpicOwnedRuns(projectId, epicId)) {
477
+ const source = getExecutionRun(projectId, row.id);
478
+ if (source?.status === 'interrupted' && source.failure?.code === 'server_restarted' && source.kind === 'review') {
479
+ const resumed = await resumeInterruptedReview(projectId, epicId, source, io);
480
+ result.dispatched += resumed.dispatched;
481
+ result.busy += resumed.busy;
482
+ continue;
483
+ }
484
+ if (source?.status === 'interrupted' && source.failure?.code === 'server_restarted'
485
+ && ['build', 'build_follow_up'].includes(source.kind)) {
486
+ const resumed = await resumeInterruptedBuild(projectId, epicId, source, io);
487
+ result.dispatched += resumed.dispatched;
488
+ result.busy += resumed.busy;
489
+ continue;
490
+ }
491
+ if (source?.status === 'cancelled' && source.domain_status === 'stopped' && ['build', 'build_follow_up'].includes(source.kind)) {
492
+ if (!options.explicit) {
493
+ continue;
494
+ }
495
+ const ticketId = listExecutionRunLinks(projectId, source.id).find(link => link.entity_type === 'ticket' && link.relationship === 'primary')?.entity_id;
496
+ const ticket = ticketId ? getTicket(ticketId) : null;
497
+ const latest = ticket && db.prepare(`SELECT run.id FROM execution_runs run JOIN execution_run_links link
498
+ ON link.execution_run_id = run.id AND link.project_id = run.project_id WHERE run.project_id = ?
499
+ AND link.entity_type = 'ticket' AND link.entity_id = ? AND link.relationship = 'primary'
500
+ AND run.kind IN ('build', 'build_follow_up') ORDER BY run.rowid DESC LIMIT 1`).get(projectId, ticket.id);
501
+ if (ticket?.agent_status === 'stopped' && latest?.id === source.id && !independentlyPaused(projectId, ticket.worktree_bundle_id)) {
502
+ const { resumeBuildTicketRun } = await import('./ticketRunOperations.js');
503
+ const { getBuildSequenceIdForTicket } = await import('./buildSequences.js');
504
+ if (!eligible(projectId, epicId)) {
505
+ return result;
506
+ }
507
+ const resumed = resumeBuildTicketRun({ ticketId: ticket.id, requestedProjectId: projectId, broadcaster: io,
508
+ sequenceId: getBuildSequenceIdForTicket(ticket.id) });
509
+ if (resumed.ok) {
510
+ result.dispatched += 1;
511
+ }
512
+ }
513
+ continue;
514
+ }
515
+ if (!source || source.status !== 'completed' || !['build', 'build_follow_up'].includes(source.kind)) {
516
+ continue;
517
+ }
518
+ const continuation = getEpicCheckpointContinuation(projectId, source.id);
519
+ const finalization = source.metadata?.post_build_finalization;
520
+ const unadmittedAtRestart = finalization?.status === 'blocked' && finalization.check_admission === 'pending' && continuation
521
+ && !db.prepare("SELECT 1 FROM check_batch_details WHERE causal_source_run_id = ? AND purpose = 'post_build' LIMIT 1").get(source.id);
522
+ if (!options.explicit && ((finalization?.status === 'blocked' && !unadmittedAtRestart) || (continuation
523
+ && ['required_checks', 'approval_required', 'stage_failed', 'precondition_failed', 'workspace_changed'].includes(continuation.deferralReason.code)))) {
524
+ continue;
525
+ }
526
+ const retainedSuccessor = continuation && resolveReceiptSuccessor(projectId, epicId, continuation).state === 'queued';
527
+ if (!continuation?.nextStage && !retainedSuccessor && !['pending', 'blocked', 'finalized'].includes(finalization?.status ?? '')) {
528
+ continue;
529
+ }
530
+ const ticketId = listExecutionRunLinks(projectId, source.id).find(link => link.entity_type === 'ticket' && link.relationship === 'primary')?.entity_id;
531
+ const ticket = ticketId ? getTicket(ticketId) : null;
532
+ const key = ticket ? resolveTicketWorkerKey(ticket, 'build') : null;
533
+ if (!key || !ticket || independentlyPaused(projectId, ticket.worktree_bundle_id)
534
+ || !isLatestTicketBuildSource(projectId, source.id, ticket.id)) {
535
+ continue;
536
+ }
537
+ const automationState = ticket.worktree_bundle_id ? getBundleAutomationState(projectId, ticket.worktree_bundle_id) : null;
538
+ if (!options.explicit && automationState?.automation_pause_reason_code
539
+ && ['stage_failed', 'required_checks_failed', 'side_effect_ambiguous', 'reconciliation_failed', 'configuration_changed']
540
+ .includes(automationState.automation_pause_reason_code)) {
541
+ continue;
542
+ }
543
+ if (continuation?.nextStage && (!ticket.worktree_bundle_id || !resolveBuildTicketCommitCheckpointLineage({
544
+ projectId, bundleId: ticket.worktree_bundle_id, progressionRunId: continuation.progressionRunId,
545
+ }))) {
546
+ continue;
547
+ }
548
+ if (hasActivePostBuildCheck(projectId, 'ticket', ticket.id)) {
549
+ result.busy += 1;
550
+ continue;
551
+ }
552
+ const recoveryKey = `${projectId}:${source.id}`;
553
+ if (isRunning(key) || recoveringSources.has(recoveryKey)) {
554
+ result.busy += 1;
555
+ continue;
556
+ }
557
+ recoveringSources.add(recoveryKey);
558
+ const releaseOwnership = ownRecovery(projectId, epicId);
559
+ let completion;
560
+ try {
561
+ completion = enqueue(key, release => resumeCompletedBuild(projectId, epicId, source, io, release));
562
+ }
563
+ catch (error) {
564
+ recoveringSources.delete(recoveryKey);
565
+ releaseOwnership();
566
+ throw error;
567
+ }
568
+ void completion.catch(error => {
569
+ if (getExecutionRun(projectId, source.id)) {
570
+ appendLifecycleEvent({ projectId, runId: source.id, eventType: 'epic_execution_recovery_deferred',
571
+ metadata: { epic_id: epicId, reason: epicExecutionMessage('recoveryDeferredReason', {
572
+ reason: error instanceof Error ? error.message : String(error),
573
+ }) } }, io);
574
+ }
575
+ }).finally(() => {
576
+ recoveringSources.delete(recoveryKey);
577
+ releaseOwnership();
578
+ });
579
+ result.dispatched += 1;
580
+ }
581
+ return result;
582
+ };
583
+ /** Intent has already been committed. Interrupt only this epic's owned work;
584
+ * do not retire progression, clean workspace, or stop a Build sequence. */
585
+ const stopExecution = async (projectId, epicId, io) => {
586
+ const { stopBuildAgent, stopReviewAgent, interruptExecutionProcesses, stopSpecAgent } = await import('./agent.js');
587
+ const { getSpecAgentProcessKey } = await import('./specAgentRuntime.js');
588
+ if (!getEpic(epicId, projectId)) {
589
+ return;
590
+ }
591
+ await stopSpecAgent(getSpecAgentProcessKey(epicId, 'epic'));
592
+ const bundles = new Set();
593
+ const interrupted = new Set();
594
+ const stopOwnedRun = async (run) => {
595
+ if (interrupted.has(run.id)) {
596
+ return;
597
+ }
598
+ interrupted.add(run.id);
599
+ const links = listExecutionRunLinks(projectId, run.id);
600
+ const ticketId = links.find(link => link.entity_type === 'ticket' && link.relationship === 'primary')?.entity_id;
601
+ if (ticketId && ['build', 'build_follow_up'].includes(run.kind)) {
602
+ await stopBuildAgent(ticketId);
603
+ }
604
+ else if (ticketId && run.kind === 'review') {
605
+ await stopReviewAgent(ticketId);
606
+ }
607
+ else if (run.kind === 'check_batch') {
608
+ const { stopCheckBatch } = await import('./checkRunner.js');
609
+ await stopCheckBatch(projectId, run.id, io);
610
+ }
611
+ await interruptExecutionProcesses(projectId, run.id);
612
+ };
613
+ for (const row of listEpicOwnedRuns(projectId, epicId)) {
614
+ const run = getExecutionRun(projectId, row.id);
615
+ if (!run || !['queued', 'running', 'waiting'].includes(run.status)) {
616
+ continue;
617
+ }
618
+ const links = listExecutionRunLinks(projectId, run.id);
619
+ if (run.kind === 'automation_progression') {
620
+ const bundleId = links.find(link => link.entity_type === 'bundle' && link.relationship === 'primary')?.entity_id;
621
+ if (bundleId && !bundles.has(bundleId)) {
622
+ bundles.add(bundleId);
623
+ await interruptAutomationProgression({ projectId, bundleId, broadcaster: io, stopChild: stopOwnedRun });
624
+ }
625
+ continue;
626
+ }
627
+ await stopOwnedRun(run);
628
+ }
629
+ };
630
+ export const resumeEpicExecution = async (projectId, epicId, io, options = { explicit: true }) => {
631
+ const release = ownRecovery(projectId, epicId);
632
+ try {
633
+ return await resumeExecution(projectId, epicId, io, options);
634
+ }
635
+ finally {
636
+ release();
637
+ }
638
+ };
639
+ export const stopEpicExecution = async (projectId, epicId, io) => {
640
+ if (!getEpic(epicId, projectId)) {
641
+ return;
642
+ }
643
+ const release = ownRecovery(projectId, epicId);
644
+ try {
645
+ await stopExecution(projectId, epicId, io);
646
+ }
647
+ finally {
648
+ release();
649
+ }
650
+ };
651
+ //# sourceMappingURL=epicExecutionRecovery.js.map