@straiffi/archon 1.11.14 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{ActivityView-CXlLfbio.js → ActivityView-jw3H-NeG.js} +1 -1
- package/dist/client/assets/{GitHubActionsDialog-COncogiu.js → GitHubActionsDialog-cUxcoLqx.js} +1 -1
- package/dist/client/assets/VerificationDialog-DP8d6ddQ.js +4 -0
- package/dist/client/assets/{architectureDiagram-3BPJPVTR-BgpjZv9J.js → architectureDiagram-3BPJPVTR-BhWOZPeu.js} +1 -1
- package/dist/client/assets/{blockDiagram-GPEHLZMM-DZOzPj8L.js → blockDiagram-GPEHLZMM-BJjjnCa4.js} +1 -1
- package/dist/client/assets/{c4Diagram-AAUBKEIU-CH8w_-4O.js → c4Diagram-AAUBKEIU-CQldjeAF.js} +1 -1
- package/dist/client/assets/channel-2Q4_MKqQ.js +1 -0
- package/dist/client/assets/{chunk-2J33WTMH-BhCJUMWk.js → chunk-2J33WTMH-D3ULHOwT.js} +1 -1
- package/dist/client/assets/{chunk-3OPIFGDE-B4ljJWcN.js → chunk-3OPIFGDE-zDE6O-L_.js} +1 -1
- package/dist/client/assets/{chunk-5ZQYHXKU-BokkrzzD.js → chunk-5ZQYHXKU-C7W7qahQ.js} +1 -1
- package/dist/client/assets/{chunk-727SXJPM-V-Kd95sz.js → chunk-727SXJPM-ChrtCiX1.js} +1 -1
- package/dist/client/assets/{chunk-AQP2D5EJ-D7ZyW65i.js → chunk-AQP2D5EJ-BJcMYTJ-.js} +1 -1
- package/dist/client/assets/{chunk-CSCIHK7Q-3cPiGWR4.js → chunk-CSCIHK7Q-uFhZVkuh.js} +1 -1
- package/dist/client/assets/{chunk-KSCS5N6A-fh-t3Kan.js → chunk-KSCS5N6A-DNE-cIoY.js} +1 -1
- package/dist/client/assets/{chunk-L5ZTLDWV-Bz_XmsGr.js → chunk-L5ZTLDWV-B1hsOai3.js} +1 -1
- package/dist/client/assets/{chunk-LZXEDZCA-DUQIbmfo.js → chunk-LZXEDZCA-BFcJgF2j.js} +2 -2
- package/dist/client/assets/{chunk-ND2GUHAM-BeaXA2cA.js → chunk-ND2GUHAM-oXJD3VO7.js} +1 -1
- package/dist/client/assets/{chunk-NZK2D7GU-Cljr0eIp.js → chunk-NZK2D7GU-DRK-yrm5.js} +1 -1
- package/dist/client/assets/{chunk-O5CBEL6O-BSZxUONE.js → chunk-O5CBEL6O-LQ2Eqsqb.js} +1 -1
- package/dist/client/assets/{chunk-WU5MYG2G-CqeEBV6t.js → chunk-WU5MYG2G-DW1hrICF.js} +1 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-DlhYAzjF.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DZsqIDkO.js +1 -0
- package/dist/client/assets/{dagre-BM42HDAG-C684sP5O.js → dagre-BM42HDAG-DAOujANI.js} +1 -1
- package/dist/client/assets/{diagram-2AECGRRQ-Bsuw7S1w.js → diagram-2AECGRRQ-CQoEIHep.js} +1 -1
- package/dist/client/assets/{diagram-5GNKFQAL-B7TKNAIK.js → diagram-5GNKFQAL-ChV233vS.js} +1 -1
- package/dist/client/assets/{diagram-KO2AKTUF-RPOTY2uQ.js → diagram-KO2AKTUF-CIkpG_DX.js} +1 -1
- package/dist/client/assets/{diagram-LMA3HP47-Dpk6toIw.js → diagram-LMA3HP47-kxcYwQT7.js} +1 -1
- package/dist/client/assets/{diagram-OG6HWLK6-DVJDTxyc.js → diagram-OG6HWLK6-J5YY8urL.js} +1 -1
- package/dist/client/assets/{erDiagram-TEJ5UH35-BTCHMpI9.js → erDiagram-TEJ5UH35-B5WiaYY1.js} +1 -1
- package/dist/client/assets/{flowDiagram-I6XJVG4X-DJHpUHaK.js → flowDiagram-I6XJVG4X-BuQ2YOAf.js} +1 -1
- package/dist/client/assets/{ganttDiagram-6RSMTGT7-B3lqQNjh.js → ganttDiagram-6RSMTGT7-BKgtiOWd.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PVQCEYII-kSFZuvH6.js → gitGraphDiagram-PVQCEYII-ZT89EFiT.js} +1 -1
- package/dist/client/assets/index-DTsS9gs9.css +2 -0
- package/dist/client/assets/index-X4XsGor3.js +309 -0
- package/dist/client/assets/{infoDiagram-5YYISTIA-D7rhmUR9.js → infoDiagram-5YYISTIA-gSvPZVHC.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-CFrqWdH6.js → ishikawaDiagram-YF4QCWOH-B4t29USy.js} +1 -1
- package/dist/client/assets/{journeyDiagram-JHISSGLW-BPgPF00X.js → journeyDiagram-JHISSGLW-CVmQq2kB.js} +1 -1
- package/dist/client/assets/{kanban-definition-UN3LZRKU-BJU3LTu3.js → kanban-definition-UN3LZRKU-b5O5VKrr.js} +1 -1
- package/dist/client/assets/{line-DTRSChYM.js → line-D6RHOz5K.js} +1 -1
- package/dist/client/assets/{mermaid-parser.core-X8EDtr9G.js → mermaid-parser.core-Cwq8hOlE.js} +1 -1
- package/dist/client/assets/{mermaid.core-CQDbIF5j.js → mermaid.core-D6EV8_i4.js} +3 -3
- package/dist/client/assets/{mindmap-definition-RKZ34NQL-Bcke6M7z.js → mindmap-definition-RKZ34NQL-DivmXvOE.js} +1 -1
- package/dist/client/assets/{pieDiagram-4H26LBE5-j8xeTgqq.js → pieDiagram-4H26LBE5-Bfemol_L.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-W4KKPZXB-OlvBffG8.js → quadrantDiagram-W4KKPZXB-Cas_rlHH.js} +1 -1
- package/dist/client/assets/{requirementDiagram-4Y6WPE33-DA6zNi15.js → requirementDiagram-4Y6WPE33-BM8zTE_j.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-5OEKKPKP-BsS5qud8.js → sankeyDiagram-5OEKKPKP-B6mxh_XP.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-3UESZ5HK-BfZ_W9Jc.js → sequenceDiagram-3UESZ5HK-CYnnYFdz.js} +1 -1
- package/dist/client/assets/{stateDiagram-AJRCARHV-C7uuqC0M.js → stateDiagram-AJRCARHV-DzYqaPIm.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BDRmC9KJ.js +1 -0
- package/dist/client/assets/{timeline-definition-PNZ67QCA-yuywaFQ6.js → timeline-definition-PNZ67QCA-IsLLwa3b.js} +1 -1
- package/dist/client/assets/{vennDiagram-CIIHVFJN-Cxlyjlnx.js → vennDiagram-CIIHVFJN-Dq0WBBOy.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-YWT4CUSO-DcJ0jJo4.js → wardleyDiagram-YWT4CUSO-DD_3WNIO.js} +1 -1
- package/dist/client/assets/{xychartDiagram-2RQKCTM6-Cia16EBC.js → xychartDiagram-2RQKCTM6-Ds-PWhnZ.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/db.js +32 -14
- package/dist/server/db.js.map +1 -1
- package/dist/server/epicRoutes.js +305 -0
- package/dist/server/epicRoutes.js.map +1 -0
- package/dist/server/index.js +186 -60
- package/dist/server/index.js.map +1 -1
- package/dist/server/lib/agent.js +239 -85
- package/dist/server/lib/agent.js.map +1 -1
- package/dist/server/lib/agentProvider.js.map +1 -1
- package/dist/server/lib/agentRuns.js +64 -31
- package/dist/server/lib/agentRuns.js.map +1 -1
- package/dist/server/lib/attachments.js +10 -0
- package/dist/server/lib/attachments.js.map +1 -1
- package/dist/server/lib/automationBuildContinuation.js +14 -2
- package/dist/server/lib/automationBuildContinuation.js.map +1 -1
- package/dist/server/lib/automationCheckEvidence.js +118 -0
- package/dist/server/lib/automationCheckEvidence.js.map +1 -0
- package/dist/server/lib/automationCheckGate.js +60 -162
- package/dist/server/lib/automationCheckGate.js.map +1 -1
- package/dist/server/lib/automationProcessInterruption.js +52 -0
- package/dist/server/lib/automationProcessInterruption.js.map +1 -0
- package/dist/server/lib/automationProgression.js +2 -0
- package/dist/server/lib/automationProgression.js.map +1 -1
- package/dist/server/lib/automationProgressionPurpose.js +27 -0
- package/dist/server/lib/automationProgressionPurpose.js.map +1 -0
- package/dist/server/lib/automationReconciliation.js +46 -17
- package/dist/server/lib/automationReconciliation.js.map +1 -1
- package/dist/server/lib/buildCheckpointSuccessor.js +49 -0
- package/dist/server/lib/buildCheckpointSuccessor.js.map +1 -0
- package/dist/server/lib/buildCompletionContinuation.js +214 -19
- package/dist/server/lib/buildCompletionContinuation.js.map +1 -1
- package/dist/server/lib/buildExecutionAdmission.js +25 -4
- package/dist/server/lib/buildExecutionAdmission.js.map +1 -1
- package/dist/server/lib/buildExecutionLineage.js +50 -0
- package/dist/server/lib/buildExecutionLineage.js.map +1 -0
- package/dist/server/lib/buildFlow.js +13 -0
- package/dist/server/lib/buildFlow.js.map +1 -1
- package/dist/server/lib/buildSequenceCheckpointOwnership.js +34 -0
- package/dist/server/lib/buildSequenceCheckpointOwnership.js.map +1 -0
- package/dist/server/lib/buildSequences.js +18 -1
- package/dist/server/lib/buildSequences.js.map +1 -1
- package/dist/server/lib/buildTicketCheckpointEligibility.js +6 -0
- package/dist/server/lib/buildTicketCheckpointEligibility.js.map +1 -0
- package/dist/server/lib/buildTicketCommit.js +87 -8
- package/dist/server/lib/buildTicketCommit.js.map +1 -1
- package/dist/server/lib/bundleBuildRecovery.js +18 -4
- package/dist/server/lib/bundleBuildRecovery.js.map +1 -1
- package/dist/server/lib/bundleDeletion.js +11 -0
- package/dist/server/lib/bundleDeletion.js.map +1 -1
- package/dist/server/lib/chatOperations.js +7 -0
- package/dist/server/lib/chatOperations.js.map +1 -1
- package/dist/server/lib/chatTurnPurpose.js +15 -0
- package/dist/server/lib/chatTurnPurpose.js.map +1 -0
- package/dist/server/lib/checkAttemptAdmission.js +27 -0
- package/dist/server/lib/checkAttemptAdmission.js.map +1 -0
- package/dist/server/lib/checkAutoFix.js +46 -14
- package/dist/server/lib/checkAutoFix.js.map +1 -1
- package/dist/server/lib/checkAutoFixStepPolicy.js +32 -0
- package/dist/server/lib/checkAutoFixStepPolicy.js.map +1 -0
- package/dist/server/lib/checkRepair.js +31 -14
- package/dist/server/lib/checkRepair.js.map +1 -1
- package/dist/server/lib/checkRepairStepPolicy.js +23 -0
- package/dist/server/lib/checkRepairStepPolicy.js.map +1 -0
- package/dist/server/lib/checkRunner.js +57 -32
- package/dist/server/lib/checkRunner.js.map +1 -1
- package/dist/server/lib/conversationResume.js +22 -0
- package/dist/server/lib/conversationResume.js.map +1 -1
- package/dist/server/lib/epicAdmission.js +173 -0
- package/dist/server/lib/epicAdmission.js.map +1 -0
- package/dist/server/lib/epicAttemptBuildRecovery.js +192 -0
- package/dist/server/lib/epicAttemptBuildRecovery.js.map +1 -0
- package/dist/server/lib/epicAttemptReconciliation.js +164 -0
- package/dist/server/lib/epicAttemptReconciliation.js.map +1 -0
- package/dist/server/lib/epicAttemptRecoverySchema.js +16 -0
- package/dist/server/lib/epicAttemptRecoverySchema.js.map +1 -0
- package/dist/server/lib/epicAttemptRecoveryStore.js +8 -0
- package/dist/server/lib/epicAttemptRecoveryStore.js.map +1 -0
- package/dist/server/lib/epicAutomation.js +104 -0
- package/dist/server/lib/epicAutomation.js.map +1 -0
- package/dist/server/lib/epicBuildCheckpoint.js +141 -0
- package/dist/server/lib/epicBuildCheckpoint.js.map +1 -0
- package/dist/server/lib/epicBuildDispatchInitiation.js +17 -0
- package/dist/server/lib/epicBuildDispatchInitiation.js.map +1 -0
- package/dist/server/lib/epicCheckpointAdmission.js +10 -0
- package/dist/server/lib/epicCheckpointAdmission.js.map +1 -0
- package/dist/server/lib/epicCheckpointAdmissionError.js +7 -0
- package/dist/server/lib/epicCheckpointAdmissionError.js.map +1 -0
- package/dist/server/lib/epicCheckpointAutomationIntegration.js +168 -0
- package/dist/server/lib/epicCheckpointAutomationIntegration.js.map +1 -0
- package/dist/server/lib/epicCheckpointContinuationSchema.js +93 -0
- package/dist/server/lib/epicCheckpointContinuationSchema.js.map +1 -0
- package/dist/server/lib/epicCheckpointContinuations.js +219 -0
- package/dist/server/lib/epicCheckpointContinuations.js.map +1 -0
- package/dist/server/lib/epicCheckpointTicketIntegration.js +69 -0
- package/dist/server/lib/epicCheckpointTicketIntegration.js.map +1 -0
- package/dist/server/lib/epicCommandRequests.js +30 -0
- package/dist/server/lib/epicCommandRequests.js.map +1 -0
- package/dist/server/lib/epicConversationStore.js +88 -0
- package/dist/server/lib/epicConversationStore.js.map +1 -0
- package/dist/server/lib/epicDeletedTargets.js +36 -0
- package/dist/server/lib/epicDeletedTargets.js.map +1 -0
- package/dist/server/lib/epicDeletion.js +101 -0
- package/dist/server/lib/epicDeletion.js.map +1 -0
- package/dist/server/lib/epicDeletionOperations.js +31 -0
- package/dist/server/lib/epicDeletionOperations.js.map +1 -0
- package/dist/server/lib/epicDeletionRuntime.js +63 -0
- package/dist/server/lib/epicDeletionRuntime.js.map +1 -0
- package/dist/server/lib/epicExecutionLineage.js +70 -0
- package/dist/server/lib/epicExecutionLineage.js.map +1 -0
- package/dist/server/lib/epicExecutionPlanOwnership.js +15 -0
- package/dist/server/lib/epicExecutionPlanOwnership.js.map +1 -0
- package/dist/server/lib/epicExecutionPlans.js +150 -0
- package/dist/server/lib/epicExecutionPlans.js.map +1 -0
- package/dist/server/lib/epicExecutionRecovery.js +376 -0
- package/dist/server/lib/epicExecutionRecovery.js.map +1 -0
- package/dist/server/lib/epicExport.js +186 -0
- package/dist/server/lib/epicExport.js.map +1 -0
- package/dist/server/lib/epicFollowUpDeferral.js +16 -0
- package/dist/server/lib/epicFollowUpDeferral.js.map +1 -0
- package/dist/server/lib/epicMaterialization.js +468 -0
- package/dist/server/lib/epicMaterialization.js.map +1 -0
- package/dist/server/lib/epicMessages.js +21 -0
- package/dist/server/lib/epicMessages.js.map +1 -0
- package/dist/server/lib/epicNumberSchema.js +56 -0
- package/dist/server/lib/epicNumberSchema.js.map +1 -0
- package/dist/server/lib/epicOperations.js +431 -0
- package/dist/server/lib/epicOperations.js.map +1 -0
- package/dist/server/lib/epicOrchestration.js +569 -0
- package/dist/server/lib/epicOrchestration.js.map +1 -0
- package/dist/server/lib/epicOwnedRuns.js +13 -0
- package/dist/server/lib/epicOwnedRuns.js.map +1 -0
- package/dist/server/lib/epicPackageInventory.js +49 -0
- package/dist/server/lib/epicPackageInventory.js.map +1 -0
- package/dist/server/lib/epicPlanArtifacts.js +85 -0
- package/dist/server/lib/epicPlanArtifacts.js.map +1 -0
- package/dist/server/lib/epicPlanDocuments.js +82 -0
- package/dist/server/lib/epicPlanDocuments.js.map +1 -0
- package/dist/server/lib/epicPlanningOperations.js +118 -0
- package/dist/server/lib/epicPlanningOperations.js.map +1 -0
- package/dist/server/lib/epicPlanningStore.js +157 -0
- package/dist/server/lib/epicPlanningStore.js.map +1 -0
- package/dist/server/lib/epicPostMergeEvidence.js +83 -0
- package/dist/server/lib/epicPostMergeEvidence.js.map +1 -0
- package/dist/server/lib/epicProposals.js +127 -0
- package/dist/server/lib/epicProposals.js.map +1 -0
- package/dist/server/lib/epicPullRequestExternalOwnership.js +184 -0
- package/dist/server/lib/epicPullRequestExternalOwnership.js.map +1 -0
- package/dist/server/lib/epicPullRequestObservation.js +95 -0
- package/dist/server/lib/epicPullRequestObservation.js.map +1 -0
- package/dist/server/lib/epicPullRequestOwnership.js +224 -0
- package/dist/server/lib/epicPullRequestOwnership.js.map +1 -0
- package/dist/server/lib/epicPullRequestRecovery.js +66 -0
- package/dist/server/lib/epicPullRequestRecovery.js.map +1 -0
- package/dist/server/lib/epicPullRequestTracking.js +353 -0
- package/dist/server/lib/epicPullRequestTracking.js.map +1 -0
- package/dist/server/lib/epicReconciliation.js +308 -0
- package/dist/server/lib/epicReconciliation.js.map +1 -0
- package/dist/server/lib/epicRecovery.js +69 -0
- package/dist/server/lib/epicRecovery.js.map +1 -0
- package/dist/server/lib/epicReferenceNotifications.js +29 -0
- package/dist/server/lib/epicReferenceNotifications.js.map +1 -0
- package/dist/server/lib/epicReferences.js +29 -0
- package/dist/server/lib/epicReferences.js.map +1 -0
- package/dist/server/lib/epicRepositoryIdentity.js +5 -0
- package/dist/server/lib/epicRepositoryIdentity.js.map +1 -0
- package/dist/server/lib/epicRevisionGuards.js +80 -0
- package/dist/server/lib/epicRevisionGuards.js.map +1 -0
- package/dist/server/lib/epicRoadmapValidation.js +99 -0
- package/dist/server/lib/epicRoadmapValidation.js.map +1 -0
- package/dist/server/lib/epicSchema.js +449 -0
- package/dist/server/lib/epicSchema.js.map +1 -0
- package/dist/server/lib/epicStepCheckApplicability.js +19 -0
- package/dist/server/lib/epicStepCheckApplicability.js.map +1 -0
- package/dist/server/lib/epicTargetChecks.js +59 -0
- package/dist/server/lib/epicTargetChecks.js.map +1 -0
- package/dist/server/lib/epicTargetObservation.js +28 -0
- package/dist/server/lib/epicTargetObservation.js.map +1 -0
- package/dist/server/lib/epics.js +840 -0
- package/dist/server/lib/epics.js.map +1 -0
- package/dist/server/lib/executionInterruption.js +20 -0
- package/dist/server/lib/executionInterruption.js.map +1 -0
- package/dist/server/lib/executionReconciliation.js +24 -5
- package/dist/server/lib/executionReconciliation.js.map +1 -1
- package/dist/server/lib/executionRetry.js +11 -1
- package/dist/server/lib/executionRetry.js.map +1 -1
- package/dist/server/lib/executionRetryContext.js +3 -2
- package/dist/server/lib/executionRetryContext.js.map +1 -1
- package/dist/server/lib/executionRunAuthority.js +4 -0
- package/dist/server/lib/executionRunAuthority.js.map +1 -1
- package/dist/server/lib/executionRunLinkMigration.js +37 -0
- package/dist/server/lib/executionRunLinkMigration.js.map +1 -0
- package/dist/server/lib/executionRunNotifications.js +104 -0
- package/dist/server/lib/executionRunNotifications.js.map +1 -0
- package/dist/server/lib/executionRuns.js +35 -20
- package/dist/server/lib/executionRuns.js.map +1 -1
- package/dist/server/lib/executionTimelineScope.js +30 -0
- package/dist/server/lib/executionTimelineScope.js.map +1 -0
- package/dist/server/lib/executionWorkloads.js +1 -1
- package/dist/server/lib/executionWorkloads.js.map +1 -1
- package/dist/server/lib/externalSource.js +18 -0
- package/dist/server/lib/externalSource.js.map +1 -1
- package/dist/server/lib/genericToolCall.js +7 -4
- package/dist/server/lib/genericToolCall.js.map +1 -1
- package/dist/server/lib/git.js +19 -2
- package/dist/server/lib/git.js.map +1 -1
- package/dist/server/lib/gitBranchTracking.js +26 -0
- package/dist/server/lib/gitBranchTracking.js.map +1 -0
- package/dist/server/lib/gitRebaseState.js +38 -0
- package/dist/server/lib/gitRebaseState.js.map +1 -0
- package/dist/server/lib/i18n/checkRepairPolicy.js +13 -0
- package/dist/server/lib/i18n/checkRepairPolicy.js.map +1 -0
- package/dist/server/lib/i18n/epicExecution.js +109 -0
- package/dist/server/lib/i18n/epicExecution.js.map +1 -0
- package/dist/server/lib/i18n/epicPlanning.js +71 -0
- package/dist/server/lib/i18n/epicPlanning.js.map +1 -0
- package/dist/server/lib/i18n/epicProposals.js +18 -0
- package/dist/server/lib/i18n/epicProposals.js.map +1 -0
- package/dist/server/lib/i18n/resources.js +14 -0
- package/dist/server/lib/i18n/resources.js.map +1 -1
- package/dist/server/lib/i18n/specPlanning.js +85 -0
- package/dist/server/lib/i18n/specPlanning.js.map +1 -0
- package/dist/server/lib/integrations/github.js +50 -11
- package/dist/server/lib/integrations/github.js.map +1 -1
- package/dist/server/lib/jsonControlChars.js +41 -0
- package/dist/server/lib/jsonControlChars.js.map +1 -0
- package/dist/server/lib/lightweightPrompt.js +20 -4
- package/dist/server/lib/lightweightPrompt.js.map +1 -1
- package/dist/server/lib/mobileAccess.js +12 -20
- package/dist/server/lib/mobileAccess.js.map +1 -1
- package/dist/server/lib/opencodeActivity.js +58 -0
- package/dist/server/lib/opencodeActivity.js.map +1 -0
- package/dist/server/lib/opencodeAgentProvider.js +11 -1
- package/dist/server/lib/opencodeAgentProvider.js.map +1 -1
- package/dist/server/lib/opencodeApprovalContext.js +38 -0
- package/dist/server/lib/opencodeApprovalContext.js.map +1 -0
- package/dist/server/lib/opencodeApprovalLifecycle.js +49 -0
- package/dist/server/lib/opencodeApprovalLifecycle.js.map +1 -0
- package/dist/server/lib/opencodeApprovalRoutes.js +51 -0
- package/dist/server/lib/opencodeApprovalRoutes.js.map +1 -0
- package/dist/server/lib/opencodeApprovalSchema.js +43 -0
- package/dist/server/lib/opencodeApprovalSchema.js.map +1 -0
- package/dist/server/lib/opencodeApprovalTransport.js +752 -0
- package/dist/server/lib/opencodeApprovalTransport.js.map +1 -0
- package/dist/server/lib/opencodeApprovalTypes.js +2 -0
- package/dist/server/lib/opencodeApprovalTypes.js.map +1 -0
- package/dist/server/lib/opencodeDescendantPermissions.js +52 -0
- package/dist/server/lib/opencodeDescendantPermissions.js.map +1 -0
- package/dist/server/lib/opencodeGuestTrustedPaths.js +44 -0
- package/dist/server/lib/opencodeGuestTrustedPaths.js.map +1 -0
- package/dist/server/lib/opencodeRunRouting.js +56 -0
- package/dist/server/lib/opencodeRunRouting.js.map +1 -0
- package/dist/server/lib/opencodeShellActivity.js +30 -0
- package/dist/server/lib/opencodeShellActivity.js.map +1 -0
- package/dist/server/lib/opencodeStream.js +3 -2
- package/dist/server/lib/opencodeStream.js.map +1 -1
- package/dist/server/lib/opencodeSubagentActivity.js +19 -0
- package/dist/server/lib/opencodeSubagentActivity.js.map +1 -0
- package/dist/server/lib/opencodeToolApprovals.js +371 -0
- package/dist/server/lib/opencodeToolApprovals.js.map +1 -0
- package/dist/server/lib/planModeQuestions.js +4 -0
- package/dist/server/lib/planModeQuestions.js.map +1 -1
- package/dist/server/lib/postBuildCheckRuns.js +81 -12
- package/dist/server/lib/postBuildCheckRuns.js.map +1 -1
- package/dist/server/lib/postBuildChecks.js +22 -1
- package/dist/server/lib/postBuildChecks.js.map +1 -1
- package/dist/server/lib/projectMemorySelections.js +4 -0
- package/dist/server/lib/projectMemorySelections.js.map +1 -1
- package/dist/server/lib/requiredCheckPolicy.js +12 -2
- package/dist/server/lib/requiredCheckPolicy.js.map +1 -1
- package/dist/server/lib/restrictedFilePrompt.js +11 -3
- package/dist/server/lib/restrictedFilePrompt.js.map +1 -1
- package/dist/server/lib/reviewAgentWatchdog.js +5 -5
- package/dist/server/lib/reviewAgentWatchdog.js.map +1 -1
- package/dist/server/lib/reviewPromptContext.js +5 -3
- package/dist/server/lib/reviewPromptContext.js.map +1 -1
- package/dist/server/lib/rootCheckGateEvidence.js +116 -0
- package/dist/server/lib/rootCheckGateEvidence.js.map +1 -0
- package/dist/server/lib/specAgentRuntime.js +37 -0
- package/dist/server/lib/specAgentRuntime.js.map +1 -0
- package/dist/server/lib/specArtifact.js +13 -54
- package/dist/server/lib/specArtifact.js.map +1 -1
- package/dist/server/lib/specDraft.js +2 -0
- package/dist/server/lib/specDraft.js.map +1 -1
- package/dist/server/lib/specEpicPlanFormatting.js +38 -0
- package/dist/server/lib/specEpicPlanFormatting.js.map +1 -0
- package/dist/server/lib/specExport.js +17 -7
- package/dist/server/lib/specExport.js.map +1 -1
- package/dist/server/lib/specMessages.js +9 -2
- package/dist/server/lib/specMessages.js.map +1 -1
- package/dist/server/lib/specOperations.js +76 -2
- package/dist/server/lib/specOperations.js.map +1 -1
- package/dist/server/lib/specPlanningArtifactAuthority.js +10 -0
- package/dist/server/lib/specPlanningArtifactAuthority.js.map +1 -0
- package/dist/server/lib/specPlanningReferences.js +147 -0
- package/dist/server/lib/specPlanningReferences.js.map +1 -0
- package/dist/server/lib/specPlanningSchema.js +39 -0
- package/dist/server/lib/specPlanningSchema.js.map +1 -0
- package/dist/server/lib/specPlanningTargets.js +53 -0
- package/dist/server/lib/specPlanningTargets.js.map +1 -0
- package/dist/server/lib/specReviewContext.js +31 -9
- package/dist/server/lib/specReviewContext.js.map +1 -1
- package/dist/server/lib/specReviewDraft.js +7 -2
- package/dist/server/lib/specReviewDraft.js.map +1 -1
- package/dist/server/lib/specReviewOperations.js +2 -0
- package/dist/server/lib/specReviewOperations.js.map +1 -1
- package/dist/server/lib/specReviewValidation.js +19 -0
- package/dist/server/lib/specReviewValidation.js.map +1 -1
- package/dist/server/lib/specTicketMaterialization.js +2 -0
- package/dist/server/lib/specTicketMaterialization.js.map +1 -1
- package/dist/server/lib/specs.js +116 -47
- package/dist/server/lib/specs.js.map +1 -1
- package/dist/server/lib/ticketAutomationCommit.js +95 -22
- package/dist/server/lib/ticketAutomationCommit.js.map +1 -1
- package/dist/server/lib/ticketPostBuildCheckRerun.js +124 -0
- package/dist/server/lib/ticketPostBuildCheckRerun.js.map +1 -0
- package/dist/server/lib/ticketRunOperations.js +4 -3
- package/dist/server/lib/ticketRunOperations.js.map +1 -1
- package/dist/server/lib/tickets.js +26 -5
- package/dist/server/lib/tickets.js.map +1 -1
- package/dist/server/lib/transcriptRuns.js +105 -3
- package/dist/server/lib/transcriptRuns.js.map +1 -1
- package/dist/server/lib/types.js +5 -1
- package/dist/server/lib/types.js.map +1 -1
- package/dist/server/workers/build.js +75 -42
- package/dist/server/workers/build.js.map +1 -1
- package/dist/server/workers/buildStatus.js +27 -0
- package/dist/server/workers/buildStatus.js.map +1 -0
- package/dist/server/workers/epicArtifactContract.js +156 -0
- package/dist/server/workers/epicArtifactContract.js.map +1 -0
- package/dist/server/workers/epicAssessmentResponse.js +27 -0
- package/dist/server/workers/epicAssessmentResponse.js.map +1 -0
- package/dist/server/workers/epicConversation.js +477 -0
- package/dist/server/workers/epicConversation.js.map +1 -0
- package/dist/server/workers/epicPlanning.js +642 -0
- package/dist/server/workers/epicPlanning.js.map +1 -0
- package/dist/server/workers/epicSpecArtifactContract.js +21 -0
- package/dist/server/workers/epicSpecArtifactContract.js.map +1 -0
- package/dist/server/workers/followUp.js +84 -36
- package/dist/server/workers/followUp.js.map +1 -1
- package/dist/server/workers/plan.js +62 -50
- package/dist/server/workers/plan.js.map +1 -1
- package/dist/server/workers/postBuildCheckRecovery.js +156 -0
- package/dist/server/workers/postBuildCheckRecovery.js.map +1 -0
- package/dist/server/workers/specEpicArtifact.js +4 -0
- package/dist/server/workers/specEpicArtifact.js.map +1 -0
- package/dist/server/workers/specSession.js +68 -28
- package/dist/server/workers/specSession.js.map +1 -1
- package/dist/shared/epicPlan.js +336 -0
- package/dist/shared/epicPlan.js.map +1 -0
- package/dist/shared/epics.js +115 -0
- package/dist/shared/epics.js.map +1 -0
- package/dist/shared/specPlanning.js +2 -0
- package/dist/shared/specPlanning.js.map +1 -0
- package/dist/shared/transcriptRuns.js +2 -0
- package/dist/shared/transcriptRuns.js.map +1 -0
- package/package.json +1 -1
- package/dist/client/assets/VerificationDialog-DcKjv3mg.js +0 -4
- package/dist/client/assets/channel-DOoXSYAr.js +0 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-DKWNm6Cx.js +0 -1
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-JFUHs0Z7.js +0 -1
- package/dist/client/assets/index-C1ZNfkTu.css +0 -2
- package/dist/client/assets/index-CXBsxrT1.js +0 -293
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-B2rL_9Nk.js +0 -1
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import db from '../db.js';
|
|
3
|
+
import * as epics from './epics.js';
|
|
4
|
+
import { resolveEpicAutomation } from './epicAutomation.js';
|
|
5
|
+
import { getExecutionRun, transitionExecutionRun } from './executionRuns.js';
|
|
6
|
+
import { requestProjectEpicAttempt, requireProjectEpic } from './epicOperations.js';
|
|
7
|
+
import { resolveEpicAttemptTicketBuildRecovery } from './epicAttemptBuildRecovery.js';
|
|
8
|
+
import { resolveEpicExternalCompletedBuild } from './epicPullRequestExternalOwnership.js';
|
|
9
|
+
import { readEpicPostMergeEvidence } from './epicPostMergeEvidence.js';
|
|
10
|
+
import { admitEpicPlanningRun, startEpicPlanningRun } from '../workers/epicPlanning.js';
|
|
11
|
+
import { HttpError } from './httpError.js';
|
|
12
|
+
import { epicExecutionMessage as message } from './i18n/epicExecution.js';
|
|
13
|
+
import { assertEpicTargetsNotDeleted, getEpicDeletedTargetReason } from './epicDeletedTargets.js';
|
|
14
|
+
import { listEpicProposals } from './epicProposals.js';
|
|
15
|
+
import { listEpicExecutionPlans } from './epicExecutionPlans.js';
|
|
16
|
+
import { assertEpicAttemptExecutionPlan } from './epicExecutionLineage.js';
|
|
17
|
+
import { sameEpicExecutionPlan } from './epicExecutionPlanOwnership.js';
|
|
18
|
+
const AUTOMATIC_PLAN_DISPATCH_LIMIT = 3;
|
|
19
|
+
const AUTOMATIC_PLAN_RETRY_DELAY_MS = 30_000;
|
|
20
|
+
const tableExists = (name) => !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(name);
|
|
21
|
+
const hash = (value) => createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
22
|
+
const unfinishedContinuation = (projectId, epicId, attemptId) => tableExists('epic_checkpoint_continuations') && !!db.prepare(`
|
|
23
|
+
SELECT 1 FROM epic_checkpoint_continuations c WHERE c.project_id = ? AND c.epic_id = ? AND (? IS NULL OR c.attempt_id = ?)
|
|
24
|
+
AND NOT EXISTS (SELECT 1 FROM epic_checkpoint_stage_receipts r WHERE r.continuation_id = c.id AND r.stage = 'advance') LIMIT 1`)
|
|
25
|
+
.get(projectId, epicId, attemptId ?? null, attemptId ?? null);
|
|
26
|
+
const bundleHasActiveWork = (projectId, bundleId) => !!db.prepare(`SELECT 1 FROM execution_runs r
|
|
27
|
+
JOIN execution_run_links l ON l.execution_run_id = r.id AND l.project_id = r.project_id
|
|
28
|
+
WHERE r.project_id = ? AND l.entity_type = 'bundle' AND l.entity_id = ? AND r.status IN ('queued', 'running', 'waiting')
|
|
29
|
+
AND r.kind != 'epic_build' LIMIT 1`).get(projectId, bundleId);
|
|
30
|
+
const hasBuildChild = (projectId, runId) => !!db.prepare(`WITH RECURSIVE lineage(id) AS (
|
|
31
|
+
SELECT id FROM execution_runs WHERE project_id = ? AND id = ?
|
|
32
|
+
UNION SELECT child.id FROM execution_runs child JOIN lineage parent ON child.parent_run_id = parent.id WHERE child.project_id = ?
|
|
33
|
+
) SELECT 1 FROM execution_runs r JOIN lineage ON lineage.id = r.id WHERE r.kind IN ('build', 'build_follow_up') LIMIT 1`)
|
|
34
|
+
.get(projectId, runId, projectId);
|
|
35
|
+
const hasOutstandingAttemptWork = (projectId, runId) => !!db.prepare(`WITH RECURSIVE lineage(id) AS (
|
|
36
|
+
SELECT id FROM execution_runs WHERE project_id = ? AND id = ?
|
|
37
|
+
UNION SELECT child.id FROM execution_runs child JOIN lineage parent ON child.parent_run_id = parent.id WHERE child.project_id = ?
|
|
38
|
+
) SELECT 1 FROM execution_runs r JOIN lineage ON lineage.id = r.id WHERE r.id != ? AND r.status IN ('queued', 'running', 'waiting') LIMIT 1`)
|
|
39
|
+
.get(projectId, runId, projectId, runId);
|
|
40
|
+
const recoverableDispatch = (projectId, claim) => {
|
|
41
|
+
const action = JSON.parse(claim.action_json);
|
|
42
|
+
const run = claim.execution_run_id && getExecutionRun(projectId, claim.execution_run_id);
|
|
43
|
+
return action.kind === 'build' && !!run && ['queued', 'running'].includes(run.status) && !hasBuildChild(projectId, run.id);
|
|
44
|
+
};
|
|
45
|
+
const hasRecoveredBuildScope = (attempt) => {
|
|
46
|
+
if (!attempt?.retry_of_attempt_id || !attempt.tickets.length) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const checkpoints = epics.listEpicTicketCheckpoints(attempt.epic_id, attempt.project_id);
|
|
50
|
+
return attempt.tickets.every(ticket => {
|
|
51
|
+
if (!ticket.ticket_id || !ticket.completed_build) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const recovery = resolveEpicAttemptTicketBuildRecovery(attempt, ticket.roadmap_ticket_id, ticket.ticket_id, checkpoints);
|
|
55
|
+
return Boolean(recovery.completed_build && !recovery.blocker);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
// A dispatch claim is not a successful planning outcome. After an owned worker
|
|
59
|
+
// fails and its blocker is explicitly resolved, admit a new generation rather
|
|
60
|
+
// than replaying the old failed execution. Queued dispatch retries keep their
|
|
61
|
+
// existing key/cooldown, and active work remains gated by the snapshot.
|
|
62
|
+
const failedDispatchedPlanIds = (projectId, epicId, revisionId, action) => db.prepare(`SELECT DISTINCT run.id FROM epic_automation_claims claim
|
|
63
|
+
JOIN execution_runs run ON run.id = claim.execution_run_id AND run.project_id = claim.project_id
|
|
64
|
+
WHERE claim.project_id = ? AND claim.epic_id = ? AND claim.state = 'dispatched'
|
|
65
|
+
AND claim.claim_key NOT LIKE 'one-shot:%' AND claim.action_json = ?
|
|
66
|
+
AND run.kind = 'epic_plan' AND run.status IN ('failed', 'cancelled', 'interrupted')
|
|
67
|
+
AND json_extract(run.metadata_json, '$.epic_planning.revision_id') IS ?
|
|
68
|
+
ORDER BY run.id`).all(projectId, epicId, JSON.stringify(action), revisionId).map(run => run.id);
|
|
69
|
+
export const readEpicAutomationSnapshot = (projectId, epicId, oneShot) => {
|
|
70
|
+
const epic = requireProjectEpic(projectId, epicId);
|
|
71
|
+
const runs = db.prepare(`SELECT r.id, r.status, r.metadata_json FROM execution_runs r JOIN execution_run_links l
|
|
72
|
+
ON l.execution_run_id = r.id AND l.project_id = r.project_id
|
|
73
|
+
WHERE r.project_id = ? AND l.entity_type = 'epic' AND l.entity_id = ? AND l.relationship = 'primary' AND r.kind = 'epic_plan'
|
|
74
|
+
AND json_extract(r.metadata_json, '$.epic_conversation') IS NULL`)
|
|
75
|
+
.all(projectId, epicId);
|
|
76
|
+
const failedQueuedPlans = new Set(db.prepare(`SELECT execution_run_id FROM epic_automation_claims
|
|
77
|
+
WHERE project_id = ? AND epic_id = ? AND (state = 'failed' OR (state = 'claimed' AND dispatch_attempts > 1)) AND claim_key NOT LIKE 'one-shot:%'
|
|
78
|
+
AND json_extract(action_json, '$.kind') = 'plan' AND execution_run_id IS NOT NULL`)
|
|
79
|
+
.all(projectId, epicId).map(claim => claim.execution_run_id));
|
|
80
|
+
const outcomes = db.prepare('SELECT attempt_id, observation_json FROM epic_pull_request_outcomes WHERE epic_id = ? AND project_id = ?')
|
|
81
|
+
.all(epicId, projectId);
|
|
82
|
+
const attempts = epics.listEpicAttempts(epicId, projectId).map(attempt => {
|
|
83
|
+
const saved = outcomes.find(outcome => outcome.attempt_id === attempt.id);
|
|
84
|
+
const observation = saved ? JSON.parse(saved.observation_json) : null;
|
|
85
|
+
return observation && attempt.pull_request && observation.number === attempt.pull_request.number
|
|
86
|
+
&& observation.head_sha === attempt.pull_request.head_sha ? { ...attempt, pull_request: { ...attempt.pull_request, state: observation.state } } : attempt;
|
|
87
|
+
});
|
|
88
|
+
const buildRuns = attempts.filter(attempt => attempt.kind === 'build').map(attempt => ({ attempt, run: getExecutionRun(projectId, `epic-attempt:${attempt.id}`) }));
|
|
89
|
+
const reconciledAttemptIds = epic.current_revision_id ? readEpicPostMergeEvidence(projectId, epicId, epic.current_revision_id)
|
|
90
|
+
.flatMap(evidence => evidence.merged_pull_requests.filter(pr => attempts.some(attempt => attempt.id === pr.attempt_id
|
|
91
|
+
&& sameEpicExecutionPlan(attempt, pr))).map(pr => pr.attempt_id)) : [];
|
|
92
|
+
const proposals = listEpicProposals(epicId, projectId);
|
|
93
|
+
return { epic, revision: epic.current_revision_id ? epics.getEpicRevision(epic.current_revision_id, epicId, projectId) : null,
|
|
94
|
+
attempts, executionPlans: listEpicExecutionPlans(epicId, projectId), materialization: epics.getEpicMaterialization(epicId, projectId),
|
|
95
|
+
legacyBuildAttemptIds: attempts.filter(attempt => attempt.kind === 'build' && !attempt.execution_plan_id
|
|
96
|
+
&& epics.getEpicRevision(attempt.revision_id, epicId, projectId)?.plan?.kind !== 'packages').map(attempt => attempt.id),
|
|
97
|
+
checkpoints: epics.listEpicTicketCheckpoints(epicId, projectId), pendingApproval: proposals.some(proposal => proposal.status === 'awaiting_review'),
|
|
98
|
+
preparingProposal: proposals.some(proposal => proposal.status === 'preparing'),
|
|
99
|
+
activePlanning: runs.some(run => ['queued', 'running', 'waiting'].includes(run.status) && !(run.status === 'queued' && failedQueuedPlans.has(run.id))),
|
|
100
|
+
outstandingContinuation: unfinishedContinuation(projectId, epicId), reconciledAttemptIds, oneShot,
|
|
101
|
+
deletedTargetReason: getEpicDeletedTargetReason({ project_id: projectId, epic_id: epicId }),
|
|
102
|
+
pendingDispatchAttemptIds: buildRuns.filter(({ attempt, run }) => run && ['queued', 'running'].includes(run.status) && !hasBuildChild(projectId, run.id)
|
|
103
|
+
&& !bundleHasActiveWork(projectId, attempt.bundle_id)).map(({ attempt }) => attempt.id),
|
|
104
|
+
oneShotBuildAttemptIds: buildRuns.filter(({ run }) => run?.metadata?.epic_one_shot).map(({ attempt }) => attempt.id) };
|
|
105
|
+
};
|
|
106
|
+
/** Claims commit before any asynchronous dispatch. Stable keys survive HTTP replay and scheduler restart. */
|
|
107
|
+
export const claimEpicAutomation = (projectId, epicId, oneShot, requestKey, continuationRunId) => db.transaction(() => {
|
|
108
|
+
const snapshot = readEpicAutomationSnapshot(projectId, epicId, oneShot);
|
|
109
|
+
const action = resolveEpicAutomation(snapshot);
|
|
110
|
+
db.prepare(`INSERT INTO epic_automation_state (epic_id, project_id, epic_version, action_json, updated_at)
|
|
111
|
+
VALUES (?, ?, ?, ?, ?) ON CONFLICT(epic_id) DO UPDATE SET epic_version = excluded.epic_version,
|
|
112
|
+
action_json = excluded.action_json, updated_at = excluded.updated_at`)
|
|
113
|
+
.run(epicId, projectId, snapshot.epic.version, JSON.stringify(action), new Date().toISOString());
|
|
114
|
+
if (action.kind === 'wait') {
|
|
115
|
+
const idleDraftWithoutAttempts = snapshot.epic.phase === 'draft' && snapshot.epic.execution_intent === 'idle' && !snapshot.attempts.length;
|
|
116
|
+
if (action.reason === 'deleted_target' && action.message && !idleDraftWithoutAttempts
|
|
117
|
+
&& !snapshot.epic.blockers.some(blocker => blocker.id === 'deleted-materialized-target')) {
|
|
118
|
+
epics.updateEpicProgress({ project_id: projectId, epic_id: epicId, expected_version: snapshot.epic.version, phase: 'blocked',
|
|
119
|
+
blockers: [...snapshot.epic.blockers, { id: 'deleted-materialized-target', kind: 'failure', message: action.message }] });
|
|
120
|
+
return { action, claim: null, blocked: true };
|
|
121
|
+
}
|
|
122
|
+
return { action, claim: null };
|
|
123
|
+
}
|
|
124
|
+
const durableAction = action.kind === 'build' ? { kind: action.kind, roadmap_bundle_id: action.roadmap_bundle_id,
|
|
125
|
+
...(action.execution_plan_id ? { execution_plan_id: action.execution_plan_id, execution_plan_digest: action.execution_plan_digest } : {}) } : action;
|
|
126
|
+
const failedPlans = action.kind === 'plan' && !requestKey
|
|
127
|
+
? failedDispatchedPlanIds(projectId, epicId, snapshot.epic.current_revision_id, durableAction) : [];
|
|
128
|
+
const keyParts = [snapshot.epic.current_revision_id, durableAction,
|
|
129
|
+
snapshot.attempts.filter(attempt => attempt.kind === 'build' && attempt.status === 'completed').map(attempt => attempt.id).sort()];
|
|
130
|
+
const key = requestKey ? `one-shot:${oneShot}:${requestKey}` : hash(failedPlans.length ? [...keyParts, failedPlans] : keyParts);
|
|
131
|
+
const existing = db.prepare('SELECT * FROM epic_automation_claims WHERE epic_id = ? AND claim_key = ?').get(epicId, key);
|
|
132
|
+
if (continuationRunId) {
|
|
133
|
+
const consumed = db.prepare('SELECT claim_key FROM epic_plan_continuation_receipts WHERE source_run_id = ?').get(continuationRunId);
|
|
134
|
+
if (consumed && consumed.claim_key !== key) {
|
|
135
|
+
return { action: { kind: 'wait', reason: 'plan_disabled' }, claim: null };
|
|
136
|
+
}
|
|
137
|
+
db.prepare('INSERT OR IGNORE INTO epic_plan_continuation_receipts (source_run_id, epic_id, project_id, claim_key, consumed_at) VALUES (?, ?, ?, ?, ?)')
|
|
138
|
+
.run(continuationRunId, epicId, projectId, key, new Date().toISOString());
|
|
139
|
+
}
|
|
140
|
+
if (existing) {
|
|
141
|
+
if (existing.action_json !== JSON.stringify(durableAction)) {
|
|
142
|
+
throw new HttpError(409, message('orchestrationIdempotencyConflict'));
|
|
143
|
+
}
|
|
144
|
+
if (existing.state === 'dispatched' && recoverableDispatch(projectId, existing)) {
|
|
145
|
+
db.prepare("UPDATE epic_automation_claims SET state = 'claimed', updated_at = ? WHERE epic_id = ? AND claim_key = ?")
|
|
146
|
+
.run(new Date().toISOString(), epicId, key);
|
|
147
|
+
return { action, claim: { ...existing, state: 'claimed' } };
|
|
148
|
+
}
|
|
149
|
+
if (existing.state === 'failed' && action.kind === 'plan' && !oneShot && !requestKey) {
|
|
150
|
+
if (existing.dispatch_attempts >= AUTOMATIC_PLAN_DISPATCH_LIMIT) {
|
|
151
|
+
const run = existing.execution_run_id ? getExecutionRun(projectId, existing.execution_run_id) : null;
|
|
152
|
+
if (run?.status === 'queued') {
|
|
153
|
+
transitionExecutionRun({ projectId, runId: run.id, status: 'failed', domainStatus: 'dispatch_exhausted',
|
|
154
|
+
failure: { code: 'dispatch_exhausted', message: message('automaticDispatchExhausted') } });
|
|
155
|
+
const state = run.metadata?.epic_planning;
|
|
156
|
+
const attempt = state?.attempt_id ? epics.getEpicAttempt(state.attempt_id, epicId, projectId) : null;
|
|
157
|
+
if (attempt && ['pending', 'running'].includes(attempt.status)) {
|
|
158
|
+
epics.updateEpicAttempt({ project_id: projectId, epic_id: epicId, expected_version: requireProjectEpic(projectId, epicId).version,
|
|
159
|
+
attempt_id: attempt.id, expected_attempt_version: attempt.version, status: 'failed', failure: message('automaticDispatchExhausted') });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
epics.updateEpicProgress({ project_id: projectId, epic_id: epicId, expected_version: requireProjectEpic(projectId, epicId).version, phase: 'blocked',
|
|
163
|
+
blockers: [{ id: `planning-dispatch-${key}`, kind: 'failure', message: message('automaticDispatchExhausted') }] });
|
|
164
|
+
return { action: { kind: 'wait', reason: 'failure' }, claim: null, blocked: true };
|
|
165
|
+
}
|
|
166
|
+
if (Date.now() - Date.parse(existing.updated_at) < AUTOMATIC_PLAN_RETRY_DELAY_MS) {
|
|
167
|
+
return { action, claim: null };
|
|
168
|
+
}
|
|
169
|
+
const runId = existing.execution_run_id && getExecutionRun(projectId, existing.execution_run_id)?.status === 'queued' ? existing.execution_run_id : null;
|
|
170
|
+
db.prepare("UPDATE epic_automation_claims SET state = 'claimed', failure = NULL, execution_run_id = ?, dispatch_attempts = dispatch_attempts + 1, updated_at = ? WHERE epic_id = ? AND claim_key = ?")
|
|
171
|
+
.run(runId, new Date().toISOString(), epicId, key);
|
|
172
|
+
return { action, claim: { ...existing, state: 'claimed', execution_run_id: runId, dispatch_attempts: existing.dispatch_attempts + 1 } };
|
|
173
|
+
}
|
|
174
|
+
return { action, claim: existing.state === 'claimed' ? existing : null };
|
|
175
|
+
}
|
|
176
|
+
db.prepare(`INSERT INTO epic_automation_claims (epic_id, project_id, claim_key, action_json, state, created_at, updated_at)
|
|
177
|
+
VALUES (?, ?, ?, ?, 'claimed', ?, ?)`).run(epicId, projectId, key, JSON.stringify(durableAction), new Date().toISOString(), new Date().toISOString());
|
|
178
|
+
return { action, claim: { claim_key: key, state: 'claimed', execution_run_id: null, action_json: JSON.stringify(durableAction), dispatch_attempts: 1, updated_at: new Date().toISOString() } };
|
|
179
|
+
}).immediate();
|
|
180
|
+
const active = new Set();
|
|
181
|
+
const busy = new Map();
|
|
182
|
+
const ownOrchestration = (projectId, epicId) => {
|
|
183
|
+
requireProjectEpic(projectId, epicId);
|
|
184
|
+
const key = JSON.stringify([projectId, epicId]);
|
|
185
|
+
busy.set(key, (busy.get(key) ?? 0) + 1);
|
|
186
|
+
return () => {
|
|
187
|
+
const remaining = busy.get(key) - 1;
|
|
188
|
+
if (remaining) {
|
|
189
|
+
busy.set(key, remaining);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
busy.delete(key);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
/** Dispatch/admission ownership only; worker lifetime is inspected separately. */
|
|
197
|
+
export const isEpicOrchestrationBusy = (projectId, epicId) => busy.has(JSON.stringify([projectId, epicId]));
|
|
198
|
+
export const createEpicOrchestrator = (options) => {
|
|
199
|
+
const getCommand = (projectId, epicId, kind, requestKey) => {
|
|
200
|
+
requireProjectEpic(projectId, epicId);
|
|
201
|
+
const claim = db.prepare('SELECT * FROM epic_automation_claims WHERE project_id = ? AND epic_id = ? AND claim_key = ?')
|
|
202
|
+
.get(projectId, epicId, `one-shot:${kind}:${requestKey}`);
|
|
203
|
+
return claim ? { action: JSON.parse(claim.action_json), state: claim.state, execution_run_id: claim.execution_run_id,
|
|
204
|
+
recoverable: claim.state === 'dispatched' && recoverableDispatch(projectId, claim) } : null;
|
|
205
|
+
};
|
|
206
|
+
const plan = async (input, claimKey, existingRunId) => {
|
|
207
|
+
if (options.plan) {
|
|
208
|
+
return options.plan(input);
|
|
209
|
+
}
|
|
210
|
+
const run = existingRunId ? getExecutionRun(input.project_id, existingRunId) : await admitEpicPlanningRun(input, options.io);
|
|
211
|
+
db.prepare('UPDATE epic_automation_claims SET execution_run_id = ? WHERE epic_id = ? AND claim_key = ?')
|
|
212
|
+
.run(run.id, input.epic_id, claimKey);
|
|
213
|
+
const { runSpecAgent } = await import('./agent.js');
|
|
214
|
+
requireProjectEpic(input.project_id, input.epic_id);
|
|
215
|
+
const completion = startEpicPlanningRun(input.project_id, run.id, { io: options.io, runAgent: runSpecAgent });
|
|
216
|
+
if (completion) {
|
|
217
|
+
void completion.catch(() => undefined);
|
|
218
|
+
}
|
|
219
|
+
return run;
|
|
220
|
+
};
|
|
221
|
+
const advance = async (projectId, epicId, oneShot, requestKey, roadmapBundleId) => {
|
|
222
|
+
const lock = JSON.stringify([projectId, epicId]);
|
|
223
|
+
requireProjectEpic(projectId, epicId);
|
|
224
|
+
if (active.has(lock)) {
|
|
225
|
+
return { kind: 'wait', reason: 'dispatching' };
|
|
226
|
+
}
|
|
227
|
+
active.add(lock);
|
|
228
|
+
const release = ownOrchestration(projectId, epicId);
|
|
229
|
+
let claimed;
|
|
230
|
+
let attemptId;
|
|
231
|
+
let continuationRunId;
|
|
232
|
+
try {
|
|
233
|
+
if (oneShot) {
|
|
234
|
+
assertEpicTargetsNotDeleted({ project_id: projectId, epic_id: epicId });
|
|
235
|
+
}
|
|
236
|
+
if (oneShot && requestKey) {
|
|
237
|
+
const replay = getCommand(projectId, epicId, oneShot, requestKey);
|
|
238
|
+
if (replay && (replay.action.kind !== oneShot || (roadmapBundleId
|
|
239
|
+
&& replay.action.roadmap_bundle_id && replay.action.roadmap_bundle_id !== roadmapBundleId))) {
|
|
240
|
+
throw new HttpError(409, message('orchestrationIdempotencyConflict'));
|
|
241
|
+
}
|
|
242
|
+
if (replay?.state === 'failed') {
|
|
243
|
+
throw new HttpError(409, message('orchestrationRetryRequired'));
|
|
244
|
+
}
|
|
245
|
+
if (replay?.state === 'dispatched' && !replay.recoverable) {
|
|
246
|
+
return { ...replay.action, execution_run_id: replay.execution_run_id };
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (oneShot && roadmapBundleId) {
|
|
250
|
+
const snapshot = readEpicAutomationSnapshot(projectId, epicId, oneShot);
|
|
251
|
+
const selected = resolveEpicAutomation(snapshot);
|
|
252
|
+
const activeBuild = oneShot === 'build' ? snapshot.attempts.find(attempt => attempt.kind === 'build' && ['pending', 'running'].includes(attempt.status)) : null;
|
|
253
|
+
const target = selected.kind === 'build' || (selected.kind === 'plan' && selected.purpose === 'next_bundle')
|
|
254
|
+
? selected.roadmap_bundle_id : activeBuild?.roadmap_bundle_id;
|
|
255
|
+
if (target && target !== roadmapBundleId) {
|
|
256
|
+
throw new HttpError(409, message('stepNotApproved'));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const liveEpic = requireProjectEpic(projectId, epicId);
|
|
260
|
+
if (!getEpicDeletedTargetReason({ project_id: projectId, epic_id: epicId }) && liveEpic.execution_intent === 'running' && !liveEpic.blockers.length
|
|
261
|
+
&& !['completed', 'cancelled', 'failed'].includes(liveEpic.phase)) {
|
|
262
|
+
const retained = oneShot === 'build' ? epics.listEpicAttempts(epicId, projectId).find(attempt => attempt.kind === 'build'
|
|
263
|
+
&& ['pending', 'running'].includes(attempt.status) && (!roadmapBundleId || attempt.roadmap_bundle_id === roadmapBundleId)
|
|
264
|
+
&& hasRecoveredBuildScope(attempt)) : null;
|
|
265
|
+
if (retained) {
|
|
266
|
+
db.prepare("UPDATE execution_runs SET metadata_json = json_set(COALESCE(metadata_json, '{}'), '$.epic_one_shot', 1) WHERE project_id = ? AND id = ?")
|
|
267
|
+
.run(projectId, `epic-attempt:${retained.id}`);
|
|
268
|
+
await options.resumeExecution?.(projectId, epicId, { explicit: true });
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
await options.resumeExecution?.(projectId, epicId);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (!oneShot) {
|
|
275
|
+
const continuation = db.prepare(`SELECT r.id, r.status, r.metadata_json FROM execution_runs r JOIN execution_run_links l
|
|
276
|
+
ON l.execution_run_id = r.id AND l.project_id = r.project_id WHERE r.project_id = ? AND l.entity_type = 'epic'
|
|
277
|
+
AND l.entity_id = ? AND l.relationship = 'primary' AND r.kind = 'epic_plan'
|
|
278
|
+
AND json_extract(r.metadata_json, '$.epic_conversation') IS NULL ORDER BY r.rowid DESC LIMIT 1`).get(projectId, epicId);
|
|
279
|
+
const metadata = JSON.parse(continuation?.metadata_json ?? '{}');
|
|
280
|
+
const snapshot = readEpicAutomationSnapshot(projectId, epicId);
|
|
281
|
+
const consumed = continuation && db.prepare('SELECT 1 FROM epic_plan_continuation_receipts WHERE source_run_id = ?').get(continuation.id);
|
|
282
|
+
if (!consumed && continuation?.status === 'completed' && metadata.epic_plan_one_shot
|
|
283
|
+
&& metadata.epic_planning?.purpose === 'post_merge_reconciliation' && metadata.epic_planning.result) {
|
|
284
|
+
const next = resolveEpicAutomation({ ...snapshot, oneShot: 'plan' });
|
|
285
|
+
if (next.kind === 'plan' && ['next_bundle', 'final_assessment'].includes(next.purpose)) {
|
|
286
|
+
oneShot = 'plan';
|
|
287
|
+
continuationRunId = continuation.id;
|
|
288
|
+
}
|
|
289
|
+
else if (next.kind === 'wait' && next.reason === 'build_disabled') {
|
|
290
|
+
// An already-materialized successor is the one authorized next step; no further Plan is needed.
|
|
291
|
+
db.prepare('INSERT OR IGNORE INTO epic_plan_continuation_receipts VALUES (?, ?, ?, ?, ?)')
|
|
292
|
+
.run(continuation.id, epicId, projectId, 'materialized_successor', new Date().toISOString());
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (!oneShot) {
|
|
296
|
+
if (snapshot.pendingDispatchAttemptIds?.some(id => snapshot.oneShotBuildAttemptIds?.includes(id))) {
|
|
297
|
+
oneShot = 'build';
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
claimed = claimEpicAutomation(projectId, epicId, oneShot, requestKey, continuationRunId);
|
|
302
|
+
const { action, claim } = claimed;
|
|
303
|
+
if ('blocked' in claimed && claimed.blocked) {
|
|
304
|
+
options.io.emit('epic:updated', requireProjectEpic(projectId, epicId));
|
|
305
|
+
}
|
|
306
|
+
if (!claim) {
|
|
307
|
+
return action;
|
|
308
|
+
}
|
|
309
|
+
if (roadmapBundleId && (action.kind === 'build' || action.purpose === 'next_bundle') && action.roadmap_bundle_id !== roadmapBundleId) {
|
|
310
|
+
throw new HttpError(409, message('stepNotApproved'));
|
|
311
|
+
}
|
|
312
|
+
// Re-read intent, blockers and both independent policy flags at the dispatch boundary.
|
|
313
|
+
const live = readEpicAutomationSnapshot(projectId, epicId, oneShot);
|
|
314
|
+
const selected = resolveEpicAutomation(live);
|
|
315
|
+
if (JSON.stringify(selected) !== JSON.stringify(action)) {
|
|
316
|
+
return selected;
|
|
317
|
+
}
|
|
318
|
+
let runId;
|
|
319
|
+
if (action.kind === 'plan') {
|
|
320
|
+
const run = await plan({ project_id: projectId, epic_id: epicId, expected_version: live.epic.version,
|
|
321
|
+
purpose: action.purpose, roadmap_bundle_id: action.roadmap_bundle_id,
|
|
322
|
+
idempotency_key: claim.dispatch_attempts > 1 && !claim.execution_run_id ? `${claim.claim_key}:dispatch:${claim.dispatch_attempts}` : claim.claim_key,
|
|
323
|
+
automatic: oneShot !== 'plan', oneShotContinuation: oneShot === 'plan' && action.purpose === 'post_merge_reconciliation' }, claim.claim_key, claim.execution_run_id);
|
|
324
|
+
runId = run.id;
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
const admitted = db.transaction(() => {
|
|
328
|
+
const current = requireProjectEpic(projectId, epicId);
|
|
329
|
+
assertEpicTargetsNotDeleted({ project_id: projectId, epic_id: epicId });
|
|
330
|
+
const existing = action.attempt_id ? epics.getEpicAttempt(action.attempt_id, epicId, projectId) : null;
|
|
331
|
+
const savedRequest = existing ? db.prepare('SELECT request_json FROM epic_attempts WHERE id = ? AND epic_id = ? AND project_id = ?')
|
|
332
|
+
.get(existing.id, epicId, projectId) : null;
|
|
333
|
+
const requestRevision = savedRequest ? JSON.parse(savedRequest.request_json).revision_id : current.current_revision_id;
|
|
334
|
+
const admission = requestProjectEpicAttempt(projectId, epicId, 'build', {
|
|
335
|
+
expected_version: current.version, revision_id: requestRevision,
|
|
336
|
+
roadmap_bundle_id: action.roadmap_bundle_id, idempotency_key: existing?.idempotency_key ?? claim.claim_key,
|
|
337
|
+
...(action.execution_plan_id ? { execution_plan_id: action.execution_plan_id, execution_plan_digest: action.execution_plan_digest } : {}),
|
|
338
|
+
...(existing?.retry_of_attempt_id ? { retry_of_attempt_id: existing.retry_of_attempt_id } : {}),
|
|
339
|
+
}, { broadcaster: options.io });
|
|
340
|
+
const attempt = admission.value.attempt;
|
|
341
|
+
assertEpicAttemptExecutionPlan(attempt);
|
|
342
|
+
if (!sameEpicExecutionPlan(attempt, action)) {
|
|
343
|
+
throw new HttpError(409, message('admissionOwnershipRequired'));
|
|
344
|
+
}
|
|
345
|
+
attemptId = attempt.id;
|
|
346
|
+
const runId = `epic-attempt:${attempt.id}`;
|
|
347
|
+
db.prepare('UPDATE epic_automation_claims SET execution_run_id = ? WHERE epic_id = ? AND claim_key = ?')
|
|
348
|
+
.run(runId, epicId, claim.claim_key);
|
|
349
|
+
// One-shot authorization belongs to the immutable admitted execution, not global settings.
|
|
350
|
+
if (oneShot === 'build') {
|
|
351
|
+
db.prepare("UPDATE execution_runs SET metadata_json = json_set(COALESCE(metadata_json, '{}'), '$.epic_one_shot', 1) WHERE id = ? AND project_id = ?")
|
|
352
|
+
.run(runId, projectId);
|
|
353
|
+
}
|
|
354
|
+
if (attempt.status === 'pending') {
|
|
355
|
+
epics.updateEpicAttempt({ project_id: projectId, epic_id: epicId, expected_version: requireProjectEpic(projectId, epicId).version,
|
|
356
|
+
attempt_id: attempt.id, expected_attempt_version: attempt.version, status: 'running' });
|
|
357
|
+
}
|
|
358
|
+
return { attempt, runId, flush: admission.flush };
|
|
359
|
+
}).immediate();
|
|
360
|
+
admitted.flush?.();
|
|
361
|
+
runId = admitted.runId;
|
|
362
|
+
const current = requireProjectEpic(projectId, epicId);
|
|
363
|
+
assertEpicTargetsNotDeleted({ project_id: projectId, epic_id: epicId });
|
|
364
|
+
if (['paused', 'cancelled'].includes(current.execution_intent) || current.blockers.length
|
|
365
|
+
|| (!oneShot && !getExecutionRun(projectId, runId)?.metadata?.epic_one_shot && !current.settings.auto_build_planned_bundle)) {
|
|
366
|
+
throw new HttpError(409, message('buildDispatchUnavailable'));
|
|
367
|
+
}
|
|
368
|
+
if (hasRecoveredBuildScope(admitted.attempt)) {
|
|
369
|
+
transitionExecutionRun({ projectId, runId, status: 'running', domainStatus: 'checkpoint_recovery' }, options.io);
|
|
370
|
+
await options.resumeExecution?.(projectId, epicId, { explicit: oneShot === 'build' || !!getExecutionRun(projectId, runId)?.metadata?.epic_one_shot });
|
|
371
|
+
transitionExecutionRun({ projectId, runId, status: 'waiting',
|
|
372
|
+
domainStatus: unfinishedContinuation(projectId, epicId) ? 'checkpoint_deferred' : 'awaiting_pull_request' }, options.io);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
const result = options.buildBundle(projectId, admitted.attempt.bundle_id, options.io, {
|
|
376
|
+
parentRunId: runId, epicId, attemptId: admitted.attempt.id,
|
|
377
|
+
execution_plan_id: admitted.attempt.execution_plan_id, execution_plan_digest: admitted.attempt.execution_plan_digest,
|
|
378
|
+
retryOfAttemptId: admitted.attempt.retry_of_attempt_id,
|
|
379
|
+
ticketIds: admitted.attempt.tickets.flatMap(ticket => ticket.ticket_id ? [ticket.ticket_id] : []),
|
|
380
|
+
oneShot: oneShot === 'build' || !!getExecutionRun(projectId, runId)?.metadata?.epic_one_shot,
|
|
381
|
+
});
|
|
382
|
+
if (!result.ok) {
|
|
383
|
+
throw new HttpError(result.status, result.error ?? message('buildSchedulingFailed'));
|
|
384
|
+
}
|
|
385
|
+
transitionExecutionRun({ projectId, runId, status: 'running', domainStatus: 'building' }, options.io);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
db.prepare("UPDATE epic_automation_claims SET state = 'dispatched', execution_run_id = ?, updated_at = ? WHERE epic_id = ? AND claim_key = ?")
|
|
389
|
+
.run(runId, new Date().toISOString(), epicId, claim.claim_key);
|
|
390
|
+
return { ...action, execution_run_id: runId };
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
const failure = error instanceof Error ? error.message : String(error);
|
|
394
|
+
db.transaction(() => {
|
|
395
|
+
if (claimed?.claim) {
|
|
396
|
+
db.prepare("UPDATE epic_automation_claims SET state = 'failed', failure = ?, updated_at = ? WHERE epic_id = ? AND claim_key = ?")
|
|
397
|
+
.run(failure, new Date().toISOString(), epicId, claimed.claim.claim_key);
|
|
398
|
+
}
|
|
399
|
+
if (attemptId) {
|
|
400
|
+
const attempt = epics.getEpicAttempt(attemptId, epicId, projectId);
|
|
401
|
+
if (attempt && ['pending', 'running'].includes(attempt.status)) {
|
|
402
|
+
epics.updateEpicAttempt({ project_id: projectId, epic_id: epicId, expected_version: requireProjectEpic(projectId, epicId).version,
|
|
403
|
+
attempt_id: attempt.id, expected_attempt_version: attempt.version, status: 'failed', failure });
|
|
404
|
+
}
|
|
405
|
+
const run = getExecutionRun(projectId, `epic-attempt:${attemptId}`);
|
|
406
|
+
if (run && ['queued', 'running', 'waiting'].includes(run.status)) {
|
|
407
|
+
transitionExecutionRun({ projectId, runId: run.id, status: 'failed', domainStatus: 'scheduling_failed', failure: { code: 'scheduling_failed', message: failure } }, options.io);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}).immediate();
|
|
411
|
+
throw error;
|
|
412
|
+
}
|
|
413
|
+
finally {
|
|
414
|
+
active.delete(lock);
|
|
415
|
+
release();
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
const applyOutcome = async (input, observation) => {
|
|
419
|
+
if (!['merged', 'closed'].includes(observation.state)) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
db.transaction(() => {
|
|
423
|
+
const epic = requireProjectEpic(input.project_id, input.epic_id);
|
|
424
|
+
const attempt = epics.getEpicAttempt(input.attempt_id, epic.id, epic.project_id);
|
|
425
|
+
const run = attempt && getExecutionRun(epic.project_id, `epic-attempt:${attempt.id}`);
|
|
426
|
+
if (!attempt || attempt.kind !== 'build' || attempt.pull_request?.number !== observation.number
|
|
427
|
+
|| attempt.pull_request.head_sha !== observation.head_sha || attempt.pull_request.url !== observation.url
|
|
428
|
+
|| attempt.pull_request.provider_id !== observation.provider_id) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
// Immutable PR links remain untouched; lifecycle observations have their own durable receipt.
|
|
432
|
+
db.prepare(`INSERT INTO epic_pull_request_outcomes (attempt_id, epic_id, project_id, observation_json, observed_at)
|
|
433
|
+
VALUES (?, ?, ?, ?, ?) ON CONFLICT(attempt_id) DO UPDATE SET observation_json = excluded.observation_json, observed_at = excluded.observed_at`)
|
|
434
|
+
.run(attempt.id, epic.id, epic.project_id, JSON.stringify(observation), observation.verified_at);
|
|
435
|
+
const scope = () => ({ project_id: epic.project_id, epic_id: epic.id, expected_version: requireProjectEpic(epic.project_id, epic.id).version });
|
|
436
|
+
if (observation.state === 'closed') {
|
|
437
|
+
if (epics.listEpicAttempts(epic.id, epic.project_id).some(candidate => candidate.retry_of_attempt_id === attempt.id)) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (['pending', 'running'].includes(attempt.status)) {
|
|
441
|
+
epics.updateEpicAttempt({ ...scope(), attempt_id: attempt.id, expected_attempt_version: attempt.version,
|
|
442
|
+
status: 'failed', failure: message('pullRequestClosed') });
|
|
443
|
+
}
|
|
444
|
+
const blockerId = `pr-closed-${attempt.id}`;
|
|
445
|
+
if (!epic.blockers.some(blocker => blocker.id === blockerId)) {
|
|
446
|
+
epics.updateEpicProgress({ ...scope(), phase: 'blocked', blockers: [...epic.blockers, { id: blockerId, kind: 'failure', message: message('pullRequestClosed') }] });
|
|
447
|
+
if (epic.execution_intent === 'cancelled' || epic.execution_intent === 'idle') {
|
|
448
|
+
epics.updateEpic({ ...scope(), execution_intent: epic.execution_intent });
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (run && ['queued', 'running', 'waiting'].includes(run.status)) {
|
|
452
|
+
transitionExecutionRun({ projectId: epic.project_id, runId: run.id, status: 'failed', domainStatus: 'pr_closed' }, options.io);
|
|
453
|
+
}
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (!['pending', 'running'].includes(attempt.status)
|
|
457
|
+
|| ['paused', 'cancelled'].includes(epic.execution_intent) || epic.blockers.length
|
|
458
|
+
|| (run && hasOutstandingAttemptWork(epic.project_id, run.id))
|
|
459
|
+
|| unfinishedContinuation(epic.project_id, epic.id, attempt.id) || bundleHasActiveWork(epic.project_id, attempt.bundle_id)) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
const checkpoints = epics.listEpicTicketCheckpoints(epic.id, epic.project_id, attempt.id);
|
|
463
|
+
assertEpicAttemptExecutionPlan(attempt);
|
|
464
|
+
if (!attempt.tickets.length || checkpoints.some(checkpoint => !sameEpicExecutionPlan(attempt, checkpoint))) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (attempt.status !== 'running') {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (tableExists('automation_stage_details')) {
|
|
471
|
+
for (const ticket of attempt.tickets) {
|
|
472
|
+
if (ticket.ticket_id && !ticket.completed_build && !checkpoints.some(checkpoint => checkpoint.roadmap_ticket_id === ticket.roadmap_ticket_id
|
|
473
|
+
&& checkpoint.phase === 'build_completed')) {
|
|
474
|
+
const externalBuild = resolveEpicExternalCompletedBuild(attempt, ticket.ticket_id);
|
|
475
|
+
const priorRecovery = resolveEpicAttemptTicketBuildRecovery(attempt, ticket.roadmap_ticket_id, ticket.ticket_id, checkpoints);
|
|
476
|
+
if (externalBuild && !priorRecovery.continuation && priorRecovery.completedBuilds.length === 1
|
|
477
|
+
&& priorRecovery.completedBuilds[0]?.build_run_id === externalBuild.build_run_id
|
|
478
|
+
&& (!priorRecovery.completed_build || (priorRecovery.completed_build.build_run_id === externalBuild.build_run_id
|
|
479
|
+
&& priorRecovery.completed_build.completed_at === externalBuild.completed_at && priorRecovery.completed_build.commit_sha === externalBuild.commit_sha))) {
|
|
480
|
+
epics.recordEpicTicketCheckpoint({ ...scope(), attempt_id: attempt.id, roadmap_ticket_id: ticket.roadmap_ticket_id,
|
|
481
|
+
execution_plan_id: attempt.execution_plan_id, execution_plan_digest: attempt.execution_plan_digest,
|
|
482
|
+
phase: 'build_completed', completed_build: externalBuild, idempotency_key: `merge:${attempt.id}:${ticket.roadmap_ticket_id}:build_completed` });
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
// Re-resolve against the copied exact Build evidence; ambiguous/retry/followup lineage still blocks completion.
|
|
488
|
+
const recoveredCheckpoints = epics.listEpicTicketCheckpoints(epic.id, epic.project_id, attempt.id);
|
|
489
|
+
const builds = attempt.tickets.map(ticket => ({ ticket, recovery: ticket.ticket_id
|
|
490
|
+
? resolveEpicAttemptTicketBuildRecovery(attempt, ticket.roadmap_ticket_id, ticket.ticket_id, recoveredCheckpoints) : null }));
|
|
491
|
+
if (builds.some(({ recovery }) => !recovery?.completed_build || recovery.blocker || recovery.continuation)) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
for (const { ticket, recovery } of builds) {
|
|
495
|
+
for (const phase of ['build_completed', 'pr_verified', 'applied']) {
|
|
496
|
+
if (!recoveredCheckpoints.some(checkpoint => checkpoint.roadmap_ticket_id === ticket.roadmap_ticket_id && checkpoint.phase === phase)) {
|
|
497
|
+
epics.recordEpicTicketCheckpoint({ ...scope(), attempt_id: attempt.id, roadmap_ticket_id: ticket.roadmap_ticket_id,
|
|
498
|
+
execution_plan_id: attempt.execution_plan_id, execution_plan_digest: attempt.execution_plan_digest,
|
|
499
|
+
phase, completed_build: recovery.completed_build, idempotency_key: `merge:${attempt.id}:${ticket.roadmap_ticket_id}:${phase}` });
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const current = epics.getEpicAttempt(attempt.id, epic.id, epic.project_id);
|
|
504
|
+
epics.updateEpicAttempt({ ...scope(), attempt_id: attempt.id, expected_attempt_version: current.version, status: 'completed' });
|
|
505
|
+
if (run && ['queued', 'running', 'waiting'].includes(run.status)) {
|
|
506
|
+
transitionExecutionRun({ projectId: epic.project_id, runId: run.id, status: 'completed', domainStatus: 'merged' }, options.io);
|
|
507
|
+
}
|
|
508
|
+
}).immediate();
|
|
509
|
+
options.io.emit('epic:updated', epics.getEpic(input.epic_id, input.project_id));
|
|
510
|
+
await advance(input.project_id, input.epic_id);
|
|
511
|
+
};
|
|
512
|
+
const handleOutcome = async (input, observation) => {
|
|
513
|
+
const release = ownOrchestration(input.project_id, input.epic_id);
|
|
514
|
+
try {
|
|
515
|
+
return await applyOutcome(input, observation);
|
|
516
|
+
}
|
|
517
|
+
finally {
|
|
518
|
+
release();
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
const tick = async (limit = 10, cursor = '') => {
|
|
522
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50) {
|
|
523
|
+
throw new HttpError(400, message('invalidOrchestrationLimit'));
|
|
524
|
+
}
|
|
525
|
+
const rows = db.prepare(`SELECT id, project_id FROM epics WHERE id > ? AND execution_intent IN ('idle', 'running')
|
|
526
|
+
AND phase NOT IN ('completed', 'cancelled') ORDER BY id LIMIT ?`).all(cursor, limit + 1);
|
|
527
|
+
const results = [];
|
|
528
|
+
for (const row of rows.slice(0, limit)) {
|
|
529
|
+
let release;
|
|
530
|
+
try {
|
|
531
|
+
release = ownOrchestration(row.project_id, row.id);
|
|
532
|
+
if (!options.plan) {
|
|
533
|
+
const epic = requireProjectEpic(row.project_id, row.id);
|
|
534
|
+
const pending = db.prepare(`SELECT r.id, r.metadata_json FROM execution_runs r JOIN execution_run_links l
|
|
535
|
+
ON l.execution_run_id = r.id AND l.project_id = r.project_id WHERE r.project_id = ? AND l.entity_type = 'epic'
|
|
536
|
+
AND l.entity_id = ? AND r.kind = 'epic_plan' AND (r.status = 'queued' OR (r.status = 'waiting'
|
|
537
|
+
AND r.domain_status IN ('pending_dispatch', 'policy_wait')))
|
|
538
|
+
AND json_extract(r.metadata_json, '$.epic_conversation') IS NULL`)
|
|
539
|
+
.all(row.project_id, row.id);
|
|
540
|
+
for (const run of pending) {
|
|
541
|
+
const metadata = JSON.parse(run.metadata_json ?? '{}');
|
|
542
|
+
if (getEpicDeletedTargetReason({ project_id: row.project_id, epic_id: row.id })
|
|
543
|
+
|| epic.blockers.length || (metadata.epic_automatic && !epic.settings.auto_plan_next_bundle)) {
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
const { runSpecAgent } = await import('./agent.js');
|
|
547
|
+
requireProjectEpic(row.project_id, row.id);
|
|
548
|
+
const completion = startEpicPlanningRun(row.project_id, run.id, { io: options.io, runAgent: runSpecAgent });
|
|
549
|
+
if (completion) {
|
|
550
|
+
void completion.catch(() => undefined);
|
|
551
|
+
db.prepare("UPDATE epic_automation_claims SET state = 'dispatched', updated_at = ? WHERE epic_id = ? AND execution_run_id = ? AND state = 'claimed'")
|
|
552
|
+
.run(new Date().toISOString(), row.id, run.id);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
results.push({ epic_id: row.id, action: await advance(row.project_id, row.id) });
|
|
557
|
+
}
|
|
558
|
+
catch (error) {
|
|
559
|
+
results.push({ epic_id: row.id, error: error instanceof Error ? error.message : String(error) });
|
|
560
|
+
}
|
|
561
|
+
finally {
|
|
562
|
+
release?.();
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return { results, next_cursor: rows.length > limit ? rows[limit - 1].id : null };
|
|
566
|
+
};
|
|
567
|
+
return { advance, handleOutcome, tick, getCommand };
|
|
568
|
+
};
|
|
569
|
+
//# sourceMappingURL=epicOrchestration.js.map
|