@straiffi/archon 1.13.3 → 1.13.4
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/README.md +15 -0
- package/dist/client/assets/{ConversationMarkdown-D8iVeRE1.js → ConversationMarkdown-DzASmN5F.js} +3 -3
- package/dist/client/assets/{DemonstrationDialog-D01TLRCK.js → DemonstrationDialog-Cf0aJQRv.js} +1 -1
- package/dist/client/assets/{GitHubActionsDialog-BmIcsS_L.js → GitHubActionsDialog-SWdzhK5r.js} +1 -1
- package/dist/client/assets/{IconGitHubActions-CjswQj_b.js → IconGitHubActions-CNbdWcIO.js} +1 -1
- package/dist/client/assets/{IconStop-BN5mT2U1.js → IconStop-1dsHbpO4.js} +1 -1
- package/dist/client/assets/{LifecycleProvider-ei6VLwTM.js → LifecycleProvider-DoalMn3Z.js} +1 -1
- package/dist/client/assets/{VerificationDialog-Cke3OC3c.js → VerificationDialog-DUBa8FRo.js} +1 -1
- package/dist/client/assets/{WorkspaceReviewModal-CLcm4NoU.js → WorkspaceReviewModal-DZSzgA7h.js} +1 -1
- package/dist/client/assets/{architectureDiagram-3BPJPVTR-Pkhiqt5r.js → architectureDiagram-3BPJPVTR-GtxQ0KbU.js} +1 -1
- package/dist/client/assets/{blockDiagram-GPEHLZMM-ruvMsQHK.js → blockDiagram-GPEHLZMM-C7RJmMo9.js} +1 -1
- package/dist/client/assets/bootstrap-CstlZd87.js +98 -0
- package/dist/client/assets/bootstrap-Dzv2N1LT.css +2 -0
- package/dist/client/assets/{c4Diagram-AAUBKEIU-D1brmJbD.js → c4Diagram-AAUBKEIU-D2f6i1DL.js} +1 -1
- package/dist/client/assets/channel-FDr1LDrU.js +1 -0
- package/dist/client/assets/{chunk-2J33WTMH-CLreEKG8.js → chunk-2J33WTMH-B9Wo3hAI.js} +1 -1
- package/dist/client/assets/{chunk-3OPIFGDE-DCODI-Rc.js → chunk-3OPIFGDE-Cyo_Iktv.js} +1 -1
- package/dist/client/assets/{chunk-5ZQYHXKU-Czv3sEec.js → chunk-5ZQYHXKU-BKlRORkG.js} +1 -1
- package/dist/client/assets/{chunk-727SXJPM-CUS5BAia.js → chunk-727SXJPM-Dgg-Mad6.js} +1 -1
- package/dist/client/assets/{chunk-AQP2D5EJ-DuU68eY2.js → chunk-AQP2D5EJ-Bo8h3S3M.js} +1 -1
- package/dist/client/assets/{chunk-CSCIHK7Q-BFj36ajn.js → chunk-CSCIHK7Q-CqFynCvg.js} +1 -1
- package/dist/client/assets/{chunk-KSCS5N6A-iU27-eSU.js → chunk-KSCS5N6A-DAJRRDRy.js} +1 -1
- package/dist/client/assets/{chunk-L5ZTLDWV-Dkr_XhvY.js → chunk-L5ZTLDWV-CpZSmk_0.js} +1 -1
- package/dist/client/assets/{chunk-LZXEDZCA-CvWOZMMQ.js → chunk-LZXEDZCA-DJ9nb0ji.js} +2 -2
- package/dist/client/assets/{chunk-ND2GUHAM-BkfiFlFO.js → chunk-ND2GUHAM-D9YDFQTm.js} +1 -1
- package/dist/client/assets/{chunk-NZK2D7GU-Ci8pOVdE.js → chunk-NZK2D7GU-Bctiv_F4.js} +1 -1
- package/dist/client/assets/{chunk-O5CBEL6O-DQWScC0A.js → chunk-O5CBEL6O-CVguYdsZ.js} +1 -1
- package/dist/client/assets/{chunk-WU5MYG2G-NCbD6q3J.js → chunk-WU5MYG2G-Djvv7tcQ.js} +1 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-VNZavQR_.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-c7rK07SK.js +1 -0
- package/dist/client/assets/{dagre-BM42HDAG-DRbkGBBP.js → dagre-BM42HDAG-DZExso27.js} +1 -1
- package/dist/client/assets/{diagram-2AECGRRQ-D_TKwNab.js → diagram-2AECGRRQ-BNCidogD.js} +1 -1
- package/dist/client/assets/{diagram-5GNKFQAL-DqgxdJ2S.js → diagram-5GNKFQAL-XHq_Rz3r.js} +1 -1
- package/dist/client/assets/{diagram-KO2AKTUF-DC36WkSM.js → diagram-KO2AKTUF-GGoEhXJk.js} +1 -1
- package/dist/client/assets/{diagram-LMA3HP47-CfgPkQ74.js → diagram-LMA3HP47-CGwPzxa0.js} +1 -1
- package/dist/client/assets/{diagram-OG6HWLK6-BecH_4Uu.js → diagram-OG6HWLK6-BtDc_GiR.js} +1 -1
- package/dist/client/assets/{erDiagram-TEJ5UH35-gVKjPSTy.js → erDiagram-TEJ5UH35-CjvscqbC.js} +1 -1
- package/dist/client/assets/{flowDiagram-I6XJVG4X-BI4w94Db.js → flowDiagram-I6XJVG4X-h9PFeGYQ.js} +1 -1
- package/dist/client/assets/{ganttDiagram-6RSMTGT7-CEwscd0z.js → ganttDiagram-6RSMTGT7-_z2FNLFr.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PVQCEYII-BzYnzfZU.js → gitGraphDiagram-PVQCEYII-CV_mfLqV.js} +1 -1
- package/dist/client/assets/{index-C2JPbj12.js → index-d7mv-jUF.js} +2 -2
- package/dist/client/assets/{infoDiagram-5YYISTIA-CPYAdvo1.js → infoDiagram-5YYISTIA-DAb0F7jZ.js} +1 -1
- package/dist/client/assets/{input-AZAw9vJs.js → input-ztf58CfF.js} +3 -3
- package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Ctpfd7Fa.js → ishikawaDiagram-YF4QCWOH-BqdUij2V.js} +1 -1
- package/dist/client/assets/{journeyDiagram-JHISSGLW-CmpICCRR.js → journeyDiagram-JHISSGLW-B1CjBwrD.js} +1 -1
- package/dist/client/assets/{kanban-definition-UN3LZRKU-BvrG2MaR.js → kanban-definition-UN3LZRKU-XQpyKzwG.js} +1 -1
- package/dist/client/assets/{line-BuEChOFl.js → line-CbO38-BR.js} +1 -1
- package/dist/client/assets/{mermaid-parser.core-Cc66WWhM.js → mermaid-parser.core-Dkv9_L-g.js} +1 -1
- package/dist/client/assets/{mermaid.core-01K66m6d.js → mermaid.core-ByXN03jp.js} +3 -3
- package/dist/client/assets/{mindmap-definition-RKZ34NQL-BuyfpCKJ.js → mindmap-definition-RKZ34NQL-BZ802LEb.js} +1 -1
- package/dist/client/assets/{pieDiagram-4H26LBE5-CgGRmchd.js → pieDiagram-4H26LBE5-DJxIIGHN.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-W4KKPZXB-BbiyoZff.js → quadrantDiagram-W4KKPZXB-737xKWR-.js} +1 -1
- package/dist/client/assets/{requirementDiagram-4Y6WPE33-BlYwYv8f.js → requirementDiagram-4Y6WPE33-BcyXer0H.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-5OEKKPKP-Bp_j3oV6.js → sankeyDiagram-5OEKKPKP-pRWMoWA3.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-3UESZ5HK-DqC_KQou.js → sequenceDiagram-3UESZ5HK-B8I9z11_.js} +1 -1
- package/dist/client/assets/{stateDiagram-AJRCARHV-BrG7IGOM.js → stateDiagram-AJRCARHV-DJNYuHfz.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-Ci8_IlV_.js +1 -0
- package/dist/client/assets/{timeline-definition-PNZ67QCA-BDe3IkOy.js → timeline-definition-PNZ67QCA-hy9ZV3k4.js} +1 -1
- package/dist/client/assets/{vennDiagram-CIIHVFJN-DECIVR7V.js → vennDiagram-CIIHVFJN-C6By4K-m.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-YWT4CUSO-Bx3AJaN9.js → wardleyDiagram-YWT4CUSO-DgK8xHry.js} +1 -1
- package/dist/client/assets/{xychartDiagram-2RQKCTM6-152u9kKH.js → xychartDiagram-2RQKCTM6-DV8oxlzo.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/db.js +2 -6452
- package/dist/server/db.js.map +1 -1
- package/dist/server/epicRoutes.js +66 -0
- package/dist/server/epicRoutes.js.map +1 -1
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/lib/buildCompletionContinuation.js +25 -157
- package/dist/server/lib/buildCompletionContinuation.js.map +1 -1
- package/dist/server/lib/buildCompletionContinuationTypes.js +5 -0
- package/dist/server/lib/buildCompletionContinuationTypes.js.map +1 -0
- package/dist/server/lib/buildDemonstrationSchema.js +4 -1
- package/dist/server/lib/buildDemonstrationSchema.js.map +1 -1
- package/dist/server/lib/buildPostFinalization.js +157 -0
- package/dist/server/lib/buildPostFinalization.js.map +1 -0
- package/dist/server/lib/buildTicketCheckpointLineage.js +194 -0
- package/dist/server/lib/buildTicketCheckpointLineage.js.map +1 -0
- package/dist/server/lib/buildTicketCheckpointLineageReads.js +20 -0
- package/dist/server/lib/buildTicketCheckpointLineageReads.js.map +1 -0
- package/dist/server/lib/buildTicketCommit.js +15 -192
- package/dist/server/lib/buildTicketCommit.js.map +1 -1
- package/dist/server/lib/chatSessionUsageMigration.js +7 -3
- package/dist/server/lib/chatSessionUsageMigration.js.map +1 -1
- package/dist/server/lib/chats.js +6 -2
- package/dist/server/lib/chats.js.map +1 -1
- package/dist/server/lib/checkpointExecution.js +33 -27
- package/dist/server/lib/checkpointExecution.js.map +1 -1
- package/dist/server/lib/databaseConnection.js +20 -0
- package/dist/server/lib/databaseConnection.js.map +1 -0
- package/dist/server/lib/databaseInitialization/agentRuns.js +156 -0
- package/dist/server/lib/databaseInitialization/agentRuns.js.map +1 -0
- package/dist/server/lib/databaseInitialization/automationQuestions.js +98 -0
- package/dist/server/lib/databaseInitialization/automationQuestions.js.map +1 -0
- package/dist/server/lib/databaseInitialization/buildSequences.js +198 -0
- package/dist/server/lib/databaseInitialization/buildSequences.js.map +1 -0
- package/dist/server/lib/databaseInitialization/bundleAutomation.js +57 -0
- package/dist/server/lib/databaseInitialization/bundleAutomation.js.map +1 -0
- package/dist/server/lib/databaseInitialization/chatAttachments.js +132 -0
- package/dist/server/lib/databaseInitialization/chatAttachments.js.map +1 -0
- package/dist/server/lib/databaseInitialization/checkBatchGuards.js +198 -0
- package/dist/server/lib/databaseInitialization/checkBatchGuards.js.map +1 -0
- package/dist/server/lib/databaseInitialization/checkGates.js +305 -0
- package/dist/server/lib/databaseInitialization/checkGates.js.map +1 -0
- package/dist/server/lib/databaseInitialization/checkRepairProvenance.js +220 -0
- package/dist/server/lib/databaseInitialization/checkRepairProvenance.js.map +1 -0
- package/dist/server/lib/databaseInitialization/checkRepairs.js +295 -0
- package/dist/server/lib/databaseInitialization/checkRepairs.js.map +1 -0
- package/dist/server/lib/databaseInitialization/coreColumns.js +104 -0
- package/dist/server/lib/databaseInitialization/coreColumns.js.map +1 -0
- package/dist/server/lib/databaseInitialization/coreTables.js +108 -0
- package/dist/server/lib/databaseInitialization/coreTables.js.map +1 -0
- package/dist/server/lib/databaseInitialization/executionArtifacts.js +246 -0
- package/dist/server/lib/databaseInitialization/executionArtifacts.js.map +1 -0
- package/dist/server/lib/databaseInitialization/executionAuthorities.js +426 -0
- package/dist/server/lib/databaseInitialization/executionAuthorities.js.map +1 -0
- package/dist/server/lib/databaseInitialization/executionChecks.js +398 -0
- package/dist/server/lib/databaseInitialization/executionChecks.js.map +1 -0
- package/dist/server/lib/databaseInitialization/executionEnvironmentGuards.js +232 -0
- package/dist/server/lib/databaseInitialization/executionEnvironmentGuards.js.map +1 -0
- package/dist/server/lib/databaseInitialization/executionEnvironments.js +335 -0
- package/dist/server/lib/databaseInitialization/executionEnvironments.js.map +1 -0
- package/dist/server/lib/databaseInitialization/executionLifecycle.js +242 -0
- package/dist/server/lib/databaseInitialization/executionLifecycle.js.map +1 -0
- package/dist/server/lib/databaseInitialization/executionProfiles.js +408 -0
- package/dist/server/lib/databaseInitialization/executionProfiles.js.map +1 -0
- package/dist/server/lib/databaseInitialization/featureSchemas.js +28 -0
- package/dist/server/lib/databaseInitialization/featureSchemas.js.map +1 -0
- package/dist/server/lib/databaseInitialization/finalIndexes.js +79 -0
- package/dist/server/lib/databaseInitialization/finalIndexes.js.map +1 -0
- package/dist/server/lib/databaseInitialization/legacyBackfills.js +103 -0
- package/dist/server/lib/databaseInitialization/legacyBackfills.js.map +1 -0
- package/dist/server/lib/databaseInitialization/projectMemoryMigrations.js +305 -0
- package/dist/server/lib/databaseInitialization/projectMemoryMigrations.js.map +1 -0
- package/dist/server/lib/databaseInitialization/projectMemorySelections.js +28 -0
- package/dist/server/lib/databaseInitialization/projectMemorySelections.js.map +1 -0
- package/dist/server/lib/databaseInitialization/projectMemoryTables.js +155 -0
- package/dist/server/lib/databaseInitialization/projectMemoryTables.js.map +1 -0
- package/dist/server/lib/databaseInitialization/repositoryGraph.js +387 -0
- package/dist/server/lib/databaseInitialization/repositoryGraph.js.map +1 -0
- package/dist/server/lib/databaseInitialization/reviewFindings.js +126 -0
- package/dist/server/lib/databaseInitialization/reviewFindings.js.map +1 -0
- package/dist/server/lib/databaseInitialization/reviewRepair.js +17 -0
- package/dist/server/lib/databaseInitialization/reviewRepair.js.map +1 -0
- package/dist/server/lib/databaseInitialization/reviewRepairTablesSql.js +171 -0
- package/dist/server/lib/databaseInitialization/reviewRepairTablesSql.js.map +1 -0
- package/dist/server/lib/databaseInitialization/reviewRepairTriggersSql.js +438 -0
- package/dist/server/lib/databaseInitialization/reviewRepairTriggersSql.js.map +1 -0
- package/dist/server/lib/databaseInitialization/reviewRuns.js +112 -0
- package/dist/server/lib/databaseInitialization/reviewRuns.js.map +1 -0
- package/dist/server/lib/databaseInitialization/specSessions.js +256 -0
- package/dist/server/lib/databaseInitialization/specSessions.js.map +1 -0
- package/dist/server/lib/databaseInitialization/ticketBundleMigrations.js +184 -0
- package/dist/server/lib/databaseInitialization/ticketBundleMigrations.js.map +1 -0
- package/dist/server/lib/databaseInitialization/types.js +2 -0
- package/dist/server/lib/databaseInitialization/types.js.map +1 -0
- package/dist/server/lib/databaseInitialization.js +81 -0
- package/dist/server/lib/databaseInitialization.js.map +1 -0
- package/dist/server/lib/databaseRuntime.js +34 -0
- package/dist/server/lib/databaseRuntime.js.map +1 -0
- package/dist/server/lib/epicActivity.js +54 -6
- package/dist/server/lib/epicActivity.js.map +1 -1
- package/dist/server/lib/epicAutomation.js.map +1 -1
- package/dist/server/lib/epicAutomationTick.js +23 -4
- package/dist/server/lib/epicAutomationTick.js.map +1 -1
- package/dist/server/lib/epicCapabilityVerificationSchema.js +2 -1
- package/dist/server/lib/epicCapabilityVerificationSchema.js.map +1 -1
- package/dist/server/lib/epicCheckpointTicketIntegration.js +15 -72
- package/dist/server/lib/epicCheckpointTicketIntegration.js.map +1 -1
- package/dist/server/lib/epicCheckpointTicketReads.js +14 -0
- package/dist/server/lib/epicCheckpointTicketReads.js.map +1 -0
- package/dist/server/lib/epicCheckpointTicketService.js +68 -0
- package/dist/server/lib/epicCheckpointTicketService.js.map +1 -0
- package/dist/server/lib/epicContentValidation.js +12 -0
- package/dist/server/lib/epicContentValidation.js.map +1 -0
- package/dist/server/lib/epicContinuationWake.js +22 -5
- package/dist/server/lib/epicContinuationWake.js.map +1 -1
- package/dist/server/lib/epicContributionEvidenceSchema.js +2 -1
- package/dist/server/lib/epicContributionEvidenceSchema.js.map +1 -1
- package/dist/server/lib/epicContributionLineage.js +2 -1
- package/dist/server/lib/epicContributionLineage.js.map +1 -1
- package/dist/server/lib/epicContributionReservationSchema.js +2 -1
- package/dist/server/lib/epicContributionReservationSchema.js.map +1 -1
- package/dist/server/lib/epicContributionSchema.js +2 -1
- package/dist/server/lib/epicContributionSchema.js.map +1 -1
- package/dist/server/lib/epicCorrectiveConditions.js +4 -3
- package/dist/server/lib/epicCorrectiveConditions.js.map +1 -1
- package/dist/server/lib/epicCorrectiveWaveAdmission.js +1 -1
- package/dist/server/lib/epicCorrectiveWaveAdmission.js.map +1 -1
- package/dist/server/lib/epicDetail.js +2 -0
- package/dist/server/lib/epicDetail.js.map +1 -1
- package/dist/server/lib/epicExternalMergedPullRequest.js +5 -1
- package/dist/server/lib/epicExternalMergedPullRequest.js.map +1 -1
- package/dist/server/lib/epicInterfaceAssessmentSchema.js +2 -1
- package/dist/server/lib/epicInterfaceAssessmentSchema.js.map +1 -1
- package/dist/server/lib/epicLegacyTechnicalBlockers.js +2 -19
- package/dist/server/lib/epicLegacyTechnicalBlockers.js.map +1 -1
- package/dist/server/lib/epicLegacyTechnicalIntervention.js +23 -0
- package/dist/server/lib/epicLegacyTechnicalIntervention.js.map +1 -0
- package/dist/server/lib/epicMergedDelivery.js +2 -23
- package/dist/server/lib/epicMergedDelivery.js.map +1 -1
- package/dist/server/lib/epicMergedDeliveryCore.js +24 -0
- package/dist/server/lib/epicMergedDeliveryCore.js.map +1 -0
- package/dist/server/lib/epicObligationMappingSchema.js +4 -1
- package/dist/server/lib/epicObligationMappingSchema.js.map +1 -1
- package/dist/server/lib/epicOperations.js +169 -11
- package/dist/server/lib/epicOperations.js.map +1 -1
- package/dist/server/lib/epicOrchestration.js +4 -830
- package/dist/server/lib/epicOrchestration.js.map +1 -1
- package/dist/server/lib/epicOrchestrationClaims.js +18 -3
- package/dist/server/lib/epicOrchestrationClaims.js.map +1 -1
- package/dist/server/lib/epicOrchestrationCore.js +701 -0
- package/dist/server/lib/epicOrchestrationCore.js.map +1 -0
- package/dist/server/lib/epicOrchestrationEpisodes.js +187 -0
- package/dist/server/lib/epicOrchestrationEpisodes.js.map +1 -0
- package/dist/server/lib/epicOrchestrationPlanning.js +3 -96
- package/dist/server/lib/epicOrchestrationPlanning.js.map +1 -1
- package/dist/server/lib/epicOrchestrationPlanningCore.js +148 -0
- package/dist/server/lib/epicOrchestrationPlanningCore.js.map +1 -0
- package/dist/server/lib/epicOrchestrationRecovery.js +6 -1
- package/dist/server/lib/epicOrchestrationRecovery.js.map +1 -1
- package/dist/server/lib/epicOrchestrationSelection.js +83 -0
- package/dist/server/lib/epicOrchestrationSelection.js.map +1 -0
- package/dist/server/lib/epicOrchestrationSnapshot.js +213 -0
- package/dist/server/lib/epicOrchestrationSnapshot.js.map +1 -0
- package/dist/server/lib/epicOwnedWorkspace.js +35 -265
- package/dist/server/lib/epicOwnedWorkspace.js.map +1 -1
- package/dist/server/lib/epicOwnedWorkspaceService.js +270 -0
- package/dist/server/lib/epicOwnedWorkspaceService.js.map +1 -0
- package/dist/server/lib/epicPackageEvidence.js +1 -1
- package/dist/server/lib/epicPackageEvidence.js.map +1 -1
- package/dist/server/lib/epicPlanningBlockerRecovery.js +133 -0
- package/dist/server/lib/epicPlanningBlockerRecovery.js.map +1 -0
- package/dist/server/lib/epicPlanningBlockerRecoveryPreview.js +281 -0
- package/dist/server/lib/epicPlanningBlockerRecoveryPreview.js.map +1 -0
- package/dist/server/lib/epicPlanningDeferral.js +35 -6
- package/dist/server/lib/epicPlanningDeferral.js.map +1 -1
- package/dist/server/lib/epicPlanningDispatch.js +2 -0
- package/dist/server/lib/epicPlanningDispatch.js.map +1 -0
- package/dist/server/lib/epicPlanningDispatchProduction.js +14 -0
- package/dist/server/lib/epicPlanningDispatchProduction.js.map +1 -0
- package/dist/server/lib/epicPlanningOperations.js +313 -87
- package/dist/server/lib/epicPlanningOperations.js.map +1 -1
- package/dist/server/lib/epicPlanningReadCore.js +182 -0
- package/dist/server/lib/epicPlanningReadCore.js.map +1 -0
- package/dist/server/lib/epicPlanningReads.js +9 -44
- package/dist/server/lib/epicPlanningReads.js.map +1 -1
- package/dist/server/lib/epicPlanningRecoveryAdmissionContext.js +21 -0
- package/dist/server/lib/epicPlanningRecoveryAdmissionContext.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoveryExpiry.js +148 -0
- package/dist/server/lib/epicPlanningRecoveryExpiry.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoveryOperations.js +108 -0
- package/dist/server/lib/epicPlanningRecoveryOperations.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoveryPolicy.js +143 -0
- package/dist/server/lib/epicPlanningRecoveryPolicy.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoveryRuntime.js +313 -0
- package/dist/server/lib/epicPlanningRecoveryRuntime.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoverySchema.js +190 -0
- package/dist/server/lib/epicPlanningRecoverySchema.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoveryStore.js +535 -0
- package/dist/server/lib/epicPlanningRecoveryStore.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoverySummary.js +66 -0
- package/dist/server/lib/epicPlanningRecoverySummary.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoveryTerminal.js +65 -0
- package/dist/server/lib/epicPlanningRecoveryTerminal.js.map +1 -0
- package/dist/server/lib/epicPlanningRecoveryTerminalStore.js +71 -0
- package/dist/server/lib/epicPlanningRecoveryTerminalStore.js.map +1 -0
- package/dist/server/lib/epicPlanningRestartInvocation.js +188 -0
- package/dist/server/lib/epicPlanningRestartInvocation.js.map +1 -0
- package/dist/server/lib/epicPlanningRestartRecovery.js +12 -2
- package/dist/server/lib/epicPlanningRestartRecovery.js.map +1 -1
- package/dist/server/lib/epicPlanningRetry.js +15 -67
- package/dist/server/lib/epicPlanningRetry.js.map +1 -1
- package/dist/server/lib/epicPlanningStartupRecovery.js +4 -0
- package/dist/server/lib/epicPlanningStartupRecovery.js.map +1 -1
- package/dist/server/lib/epicPlanningStore.js +13 -2
- package/dist/server/lib/epicPlanningStore.js.map +1 -1
- package/dist/server/lib/epicPrAcceptedProgressSchema.js +4 -1
- package/dist/server/lib/epicPrAcceptedProgressSchema.js.map +1 -1
- package/dist/server/lib/epicPrReviewedPackageEvidence.js +1 -1
- package/dist/server/lib/epicPrReviewedPackageEvidence.js.map +1 -1
- package/dist/server/lib/epicPrerequisiteRefinementSchema.js +4 -1
- package/dist/server/lib/epicPrerequisiteRefinementSchema.js.map +1 -1
- package/dist/server/lib/epicProviderRead.js +6 -0
- package/dist/server/lib/epicProviderRead.js.map +1 -1
- package/dist/server/lib/epicReadinessService.js +6 -2
- package/dist/server/lib/epicReadinessService.js.map +1 -1
- package/dist/server/lib/epicReconciliation.js +22 -8
- package/dist/server/lib/epicReconciliation.js.map +1 -1
- package/dist/server/lib/epicReconciliationErrors.js +14 -0
- package/dist/server/lib/epicReconciliationErrors.js.map +1 -0
- package/dist/server/lib/epicResidualRecurrence.js +3 -510
- package/dist/server/lib/epicResidualRecurrence.js.map +1 -1
- package/dist/server/lib/epicResidualRecurrenceCore.js +512 -0
- package/dist/server/lib/epicResidualRecurrenceCore.js.map +1 -0
- package/dist/server/lib/epicRewrittenBuildEvidence.js +104 -0
- package/dist/server/lib/epicRewrittenBuildEvidence.js.map +1 -0
- package/dist/server/lib/epicSchema.js +2 -0
- package/dist/server/lib/epicSchema.js.map +1 -1
- package/dist/server/lib/epicSemantics.js +3 -52
- package/dist/server/lib/epicSemantics.js.map +1 -1
- package/dist/server/lib/epicSemanticsPreparation.js +60 -0
- package/dist/server/lib/epicSemanticsPreparation.js.map +1 -0
- package/dist/server/lib/epicSemanticsSchema.js +9 -6
- package/dist/server/lib/epicSemanticsSchema.js.map +1 -1
- package/dist/server/lib/epicTargetAdmission.js +7 -1
- package/dist/server/lib/epicTargetAdmission.js.map +1 -1
- package/dist/server/lib/epicUnitSettlementSchema.js +5 -2
- package/dist/server/lib/epicUnitSettlementSchema.js.map +1 -1
- package/dist/server/lib/epicVerificationCheckAdmissionSchema.js +4 -1
- package/dist/server/lib/epicVerificationCheckAdmissionSchema.js.map +1 -1
- package/dist/server/lib/epicVerificationCheckLineageSchema.js +6 -3
- package/dist/server/lib/epicVerificationCheckLineageSchema.js.map +1 -1
- package/dist/server/lib/epicVerificationCheckOperations.js +4 -1
- package/dist/server/lib/epicVerificationCheckOperations.js.map +1 -1
- package/dist/server/lib/epicVerificationPolicy.js +3 -9
- package/dist/server/lib/epicVerificationPolicy.js.map +1 -1
- package/dist/server/lib/epicVerificationPolicyCapture.js +11 -0
- package/dist/server/lib/epicVerificationPolicyCapture.js.map +1 -1
- package/dist/server/lib/epicWaveArtifact.js +18 -0
- package/dist/server/lib/epicWaveArtifact.js.map +1 -0
- package/dist/server/lib/epicWaveConnectionReads.js +28 -0
- package/dist/server/lib/epicWaveConnectionReads.js.map +1 -0
- package/dist/server/lib/epicWaveContributionProvenance.js +1 -1
- package/dist/server/lib/epicWaveContributionProvenance.js.map +1 -1
- package/dist/server/lib/epicWaveContributionSchema.js +8 -2
- package/dist/server/lib/epicWaveContributionSchema.js.map +1 -1
- package/dist/server/lib/epicWaveErrors.js +11 -0
- package/dist/server/lib/epicWaveErrors.js.map +1 -0
- package/dist/server/lib/epicWaveLifecycle.js +1 -1
- package/dist/server/lib/epicWaveLifecycle.js.map +1 -1
- package/dist/server/lib/epicWavePersistence.js +348 -0
- package/dist/server/lib/epicWavePersistence.js.map +1 -0
- package/dist/server/lib/epicWavePolicyAuthority.js +2 -1
- package/dist/server/lib/epicWavePolicyAuthority.js.map +1 -1
- package/dist/server/lib/epicWaveReadiness.js +25 -445
- package/dist/server/lib/epicWaveReadiness.js.map +1 -1
- package/dist/server/lib/epicWaveReadinessCore.js +478 -0
- package/dist/server/lib/epicWaveReadinessCore.js.map +1 -0
- package/dist/server/lib/epicWaveRetirement.js +3 -100
- package/dist/server/lib/epicWaveRetirement.js.map +1 -1
- package/dist/server/lib/epicWaveRetirementStore.js +95 -0
- package/dist/server/lib/epicWaveRetirementStore.js.map +1 -0
- package/dist/server/lib/epicWaveStore.js +11 -359
- package/dist/server/lib/epicWaveStore.js.map +1 -1
- package/dist/server/lib/epicWaveValidation.js +2 -2
- package/dist/server/lib/epicWaveValidation.js.map +1 -1
- package/dist/server/lib/epicWorkspaceSnapshot.js +32 -5
- package/dist/server/lib/epicWorkspaceSnapshot.js.map +1 -1
- package/dist/server/lib/epics.js +3 -9
- package/dist/server/lib/epics.js.map +1 -1
- package/dist/server/lib/executionWorkerCompletion.js +76 -0
- package/dist/server/lib/executionWorkerCompletion.js.map +1 -1
- package/dist/server/lib/i18n/epicPlanning.js +14 -0
- package/dist/server/lib/i18n/epicPlanning.js.map +1 -1
- package/dist/server/lib/integrations/githubTransport.js +30 -1
- package/dist/server/lib/integrations/githubTransport.js.map +1 -1
- package/dist/server/lib/runtimePaths.js +2 -2
- package/dist/server/lib/runtimePaths.js.map +1 -1
- package/dist/server/lib/sessionActivitySummaries.js +29 -0
- package/dist/server/lib/sessionActivitySummaries.js.map +1 -0
- package/dist/server/lib/specs.js +6 -2
- package/dist/server/lib/specs.js.map +1 -1
- package/dist/server/lib/stageSnapshotStorage.js +153 -0
- package/dist/server/lib/stageSnapshotStorage.js.map +1 -0
- package/dist/server/lib/ticketUndo.js +48 -22
- package/dist/server/lib/ticketUndo.js.map +1 -1
- package/dist/server/lib/types.js.map +1 -1
- package/dist/server/lib/workspaceIdentity.js +35 -2
- package/dist/server/lib/workspaceIdentity.js.map +1 -1
- package/dist/server/workers/epicArtifactContract.js +92 -17
- package/dist/server/workers/epicArtifactContract.js.map +1 -1
- package/dist/server/workers/epicArtifactPurposeError.js +19 -12
- package/dist/server/workers/epicArtifactPurposeError.js.map +1 -1
- package/dist/server/workers/epicPlanning.js +36 -762
- package/dist/server/workers/epicPlanning.js.map +1 -1
- package/dist/server/workers/epicPlanningAdmission.js +194 -50
- package/dist/server/workers/epicPlanningAdmission.js.map +1 -1
- package/dist/server/workers/epicPlanningAdmissionRecovery.js +201 -0
- package/dist/server/workers/epicPlanningAdmissionRecovery.js.map +1 -0
- package/dist/server/workers/epicPlanningArtifactRepair.js +158 -38
- package/dist/server/workers/epicPlanningArtifactRepair.js.map +1 -1
- package/dist/server/workers/epicPlanningAssessmentRepair.js +1 -1
- package/dist/server/workers/epicPlanningAssessmentRepair.js.map +1 -1
- package/dist/server/workers/epicPlanningClosure.js +1 -1
- package/dist/server/workers/epicPlanningClosure.js.map +1 -1
- package/dist/server/workers/epicPlanningContributionRefinement.js +71 -23
- package/dist/server/workers/epicPlanningContributionRefinement.js.map +1 -1
- package/dist/server/workers/epicPlanningEvidence.js +29 -0
- package/dist/server/workers/epicPlanningEvidence.js.map +1 -0
- package/dist/server/workers/epicPlanningFailurePublication.js +39 -0
- package/dist/server/workers/epicPlanningFailurePublication.js.map +1 -0
- package/dist/server/workers/epicPlanningFirstWave.js.map +1 -1
- package/dist/server/workers/epicPlanningGuards.js +63 -1
- package/dist/server/workers/epicPlanningGuards.js.map +1 -1
- package/dist/server/workers/epicPlanningLivePorts.js +12 -0
- package/dist/server/workers/epicPlanningLivePorts.js.map +1 -0
- package/dist/server/workers/epicPlanningOutputAuthority.js.map +1 -1
- package/dist/server/workers/epicPlanningOutputRecovery.js +213 -0
- package/dist/server/workers/epicPlanningOutputRecovery.js.map +1 -0
- package/dist/server/workers/epicPlanningPolicy.js +36 -0
- package/dist/server/workers/epicPlanningPolicy.js.map +1 -0
- package/dist/server/workers/epicPlanningPrerequisiteRefinement.js +5 -2
- package/dist/server/workers/epicPlanningPrerequisiteRefinement.js.map +1 -1
- package/dist/server/workers/epicPlanningServices.js +171 -0
- package/dist/server/workers/epicPlanningServices.js.map +1 -0
- package/dist/server/workers/epicPlanningStaleTarget.js +82 -5
- package/dist/server/workers/epicPlanningStaleTarget.js.map +1 -1
- package/dist/server/workers/epicPlanningWorker.js +720 -0
- package/dist/server/workers/epicPlanningWorker.js.map +1 -0
- package/dist/server/workers/epicPlanningWorkerTypes.js +2 -0
- package/dist/server/workers/epicPlanningWorkerTypes.js.map +1 -0
- package/dist/server/workers/epicReadinessPlanningPrompt.js +1 -1
- package/dist/server/workers/epicReadinessPlanningPrompt.js.map +1 -1
- package/dist/server/workers/epicReadinessPlanningTurn.js +27 -14
- package/dist/server/workers/epicReadinessPlanningTurn.js.map +1 -1
- package/dist/server/workers/epicRevisionPrompt.js +2 -8
- package/dist/server/workers/epicRevisionPrompt.js.map +1 -1
- package/dist/server/workers/epicRevisionRules.js +10 -0
- package/dist/server/workers/epicRevisionRules.js.map +1 -0
- package/dist/shared/epicActivity.js +35 -2
- package/dist/shared/epicActivity.js.map +1 -1
- package/dist/shared/epicPlanningRecovery.js +2 -0
- package/dist/shared/epicPlanningRecovery.js.map +1 -0
- package/dist/shared/epicPlanningRecoveryOperations.js +2 -0
- package/dist/shared/epicPlanningRecoveryOperations.js.map +1 -0
- package/dist/shared/epics.js.map +1 -1
- package/dist/shared/sessionActivity.js +2 -0
- package/dist/shared/sessionActivity.js.map +1 -0
- package/package.json +1 -1
- package/dist/client/assets/bootstrap-CKROdR45.js +0 -98
- package/dist/client/assets/bootstrap-CX5EVEtc.css +0 -2
- package/dist/client/assets/channel-B01NDmbu.js +0 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-D_Jv2gIy.js +0 -1
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CcxVBrx5.js +0 -1
- package/dist/client/assets/stateDiagram-v2-BHNVJYJU-rcRVsbsd.js +0 -1
|
@@ -1,831 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { consumeEpicUnitCorrectiveExecution } from './epicUnitAttempts.js';
|
|
6
|
-
import * as epics from './epics.js';
|
|
7
|
-
import { getExecutionRun, transitionExecutionRun } from './executionRuns.js';
|
|
8
|
-
import { requestPreparedProjectEpicAttempt, requireProjectEpic } from './epicOperations.js';
|
|
9
|
-
import { resolveEpicAttemptTicketBuildRecovery } from './epicAttemptBuildRecovery.js';
|
|
10
|
-
import { isEpicMergeDelivered, matchesEpicPullRequestObservation, readEpicMergedDelivery, readEpicUnitReplacementDelivery } from './epicMergedDelivery.js';
|
|
11
|
-
import { readEpicReplacementDelivery } from './epicReplacementDelivery.js';
|
|
12
|
-
import { readEpicPostMergeEvidence, readEpicApprovedRevisionReconciliationEvidence } from './epicPostMergeEvidence.js';
|
|
13
|
-
import { admitEpicPlanningRun, startEpicPlanningRun, retireSupersededEpicPlanningRuns } from '../workers/epicPlanning.js';
|
|
14
|
-
import { HttpError } from './httpError.js';
|
|
15
|
-
import { epicExecutionMessage as message } from './i18n/epicExecution.js';
|
|
16
|
-
import { assertEpicTargetsNotDeleted, getEpicDeletedTargetReason } from './epicDeletedTargets.js';
|
|
17
|
-
import { listEpicProposals } from './epicProposals.js';
|
|
18
|
-
import { epicBuildMatchesApprovedPackage, listEpicExecutionPlans } from './epicExecutionPlans.js';
|
|
19
|
-
import { assertEpicAttemptExecutionPlan } from './epicExecutionLineage.js';
|
|
20
|
-
import { sameEpicExecutionPlan } from './epicExecutionPlanOwnership.js';
|
|
21
|
-
import { withAvailableEpicTargetObservation, withEpicTargetObservation } from './epicTargetObservation.js';
|
|
22
|
-
import { failedDispatchedEpicPlanIds, hasEpicReconciliationGeneration, readEpicReconciliationGeneration } from './epicAutomationGeneration.js';
|
|
23
|
-
import { ensureEpicTargetRecovery } from './epicTargetRecovery.js';
|
|
24
|
-
import { requireEpicTarget } from './epicTargetResolution.js';
|
|
25
|
-
import { prepareEpicTargetAdmission, recordEpicTargetAdmission } from './epicTargetAdmission.js';
|
|
26
|
-
import { listEpicWaves, getEpicWaveMemberHistory, getEpicPackageAssessmentHistory, listEpicUnitDeliveryReceipts } from './epicWaveStore.js';
|
|
27
|
-
import { recordVerifiedEpicUnitDelivery } from './epicUnitDelivery.js';
|
|
28
|
-
import { isActiveEpicWave } from './epicWaveRetirement.js';
|
|
29
|
-
import { resolveReconciledEpicAttemptIds } from './epicAutomationEvidence.js';
|
|
30
|
-
import { getEpicWaveReconciliationState } from './epicWaveReconciliation.js';
|
|
31
|
-
import { epicBlockerAppliesToExecution, isEpicGlobalBlocker } from '../../shared/epicWaves.js';
|
|
32
|
-
import { dispatchRetainedEpicPlanningRuns } from './epicOrchestrationPlanning.js';
|
|
33
|
-
import { selectEpicContributionPlanning, readEpicContributionPlanningAnchor, resolveEpicCoordinatedAutomation } from './epicContributionCoordinator.js';
|
|
34
|
-
import { getPendingEpicPlanningDecisionResolution, hasActiveEpicChecks, listEpicPlanningDecisionResolutions } from './epicPlanningDecisionResolution.js';
|
|
35
|
-
import { EpicCleanupPendingError } from './epicWaveResources.js';
|
|
36
|
-
import { createEpicMergedCleanup, createEpicPlanningCleanupGuard, projectEpicCleanupWait } from './epicOrchestrationCleanup.js';
|
|
37
|
-
import { recoverTerminalEpicPlanningCleanups } from './epicTerminalPlanningCleanup.js';
|
|
38
|
-
import { holdEpicContinuationWake, claimEpicContinuationWakeDelivery } from './epicContinuationWake.js';
|
|
39
|
-
import { getEpicVerificationPolicy, resolveEpicVerificationPolicyCapture, assertEpicVerificationPolicyCurrent } from './epicVerificationPolicy.js';
|
|
40
|
-
import { completePrReviewedEpic } from './epicOrchestrationCompletion.js';
|
|
41
|
-
import { needsEpicReadinessPreparation, readEpicReadinessReassessment } from '../workers/epicPlanningPrerequisiteRefinement.js';
|
|
42
|
-
import { getEpicPrAcceptedProgress } from './epicPrAcceptedProgress.js';
|
|
43
|
-
import { reconcileEpicPrAcceptedProgress } from './epicPrAcceptedProgressOperations.js';
|
|
44
|
-
import { getEpicPlanningSemanticInput, isEpicPlanningNoActionSuppressed } from './epicPlanningNoAction.js';
|
|
45
|
-
import { retainEpicAutomationClaim, recoverableEpicDispatch as recoverableDispatch, hasEpicBuildChild as hasBuildChild } from './epicOrchestrationClaims.js';
|
|
46
|
-
import { describeEpicAutomationError } from './epicOrchestrationDiagnostics.js';
|
|
47
|
-
import { expireRetainedEpicPlanningRecovery } from './epicOrchestrationRecovery.js';
|
|
48
|
-
import { createEpicPrerequisiteRefinementStore } from './epicPrerequisiteRefinement.js';
|
|
49
|
-
import { buildEpicReadinessRecoveryInstruction, READINESS_RECOVERY_INSTRUCTION } from '../workers/epicReadinessRecovery.js';
|
|
50
|
-
import { isEpicFirstWaveEligible, supersedeFirstWaveReadinessBlockers } from './epicFirstWave.js';
|
|
51
|
-
const tableExists = (name) => !!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(name);
|
|
52
|
-
const hasExecutionUnits = (projectId, epicId) => tableExists('epic_wave_units')
|
|
53
|
-
&& Boolean(db.prepare(`SELECT 1 FROM epic_wave_units u WHERE project_id = ? AND epic_id = ?
|
|
54
|
-
${tableExists('epic_wave_retirements') ? `AND NOT EXISTS (SELECT 1 FROM epic_wave_retirements retired
|
|
55
|
-
WHERE retired.project_id = u.project_id AND retired.epic_id = u.epic_id AND retired.wave_id = u.wave_id)` : ''} LIMIT 1`).get(projectId, epicId));
|
|
56
|
-
const hash = (value) => createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
57
|
-
const resolveEpicAutomation = (snapshot) => {
|
|
58
|
-
if (snapshot.first_wave) {
|
|
59
|
-
return resolveEpicCoordinatedAutomation(snapshot);
|
|
60
|
-
}
|
|
61
|
-
const activeProposal = snapshot.pendingApproval || snapshot.preparingProposal;
|
|
62
|
-
if (!activeProposal && (!snapshot.prAcceptedProgress?.required || snapshot.prAcceptedProgress.current) && needsEpicReadinessPreparation(db, snapshot)
|
|
63
|
-
&& !getPendingEpicPlanningDecisionResolution(snapshot.epic)) {
|
|
64
|
-
if (isEpicPlanningNoActionSuppressed(snapshot.epic, 'prepare_readiness', null)) {
|
|
65
|
-
return { kind: 'wait', reason: 'dependency' };
|
|
66
|
-
}
|
|
67
|
-
if (hasActiveEpicChecks(snapshot.epic.project_id, snapshot.epic.id)) {
|
|
68
|
-
return { kind: 'wait', reason: 'checks' };
|
|
69
|
-
}
|
|
70
|
-
return { kind: 'plan', purpose: 'prepare_readiness' };
|
|
71
|
-
}
|
|
72
|
-
const action = resolveEpicCoordinatedAutomation(snapshot);
|
|
73
|
-
// No-action is scheduling history, never a substitute for current delivery
|
|
74
|
-
// proof. The trusted snapshot drops reconciled IDs when their target binding
|
|
75
|
-
// becomes stale; only that required reconciliation bypasses suppression.
|
|
76
|
-
const requiresTrustedReconciliation = action.kind === 'plan' && action.purpose === 'post_merge_reconciliation'
|
|
77
|
-
&& snapshot.attempts.some(attempt => attempt.kind === 'build'
|
|
78
|
-
&& !snapshot.attempts.some(successor => successor.retry_of_attempt_id === attempt.id)
|
|
79
|
-
&& snapshot.mergeDeliveredAttemptIds?.includes(attempt.id) && !snapshot.reconciledAttemptIds.includes(attempt.id));
|
|
80
|
-
if (!snapshot.oneShot && !requiresTrustedReconciliation && action.kind === 'plan' && isEpicPlanningNoActionSuppressed(snapshot.epic, action.purpose, action.roadmap_bundle_id ?? null)) {
|
|
81
|
-
return { kind: 'wait', reason: 'dependency' };
|
|
82
|
-
}
|
|
83
|
-
const canReconsider = action.kind === 'plan' || action.kind === 'complete'
|
|
84
|
-
|| (action.kind === 'wait' && ['plan_disabled', 'dependency'].includes(action.reason));
|
|
85
|
-
const resolution = !activeProposal && canReconsider && snapshot.oneShot !== 'build' && getPendingEpicPlanningDecisionResolution(snapshot.epic);
|
|
86
|
-
const reconsider = resolution && (action.kind === 'plan'
|
|
87
|
-
|| (action.kind === 'wait' && ['plan_disabled', 'dependency'].includes(action.reason)));
|
|
88
|
-
if (action.kind !== 'plan' && action.kind !== 'complete' && !reconsider) {
|
|
89
|
-
return action;
|
|
90
|
-
}
|
|
91
|
-
if (hasActiveEpicChecks(snapshot.epic.project_id, snapshot.epic.id)) {
|
|
92
|
-
return { kind: 'wait', reason: 'checks' };
|
|
93
|
-
}
|
|
94
|
-
return reconsider
|
|
95
|
-
? { kind: 'plan', purpose: !snapshot.epic.current_revision_id ? 'initial_roadmap'
|
|
96
|
-
: snapshot.verification_policy?.mode === 'pr_reviewed' ? 'resume_reconciliation' : 'post_merge_reconciliation' } : action;
|
|
97
|
-
};
|
|
98
|
-
const unfinishedContinuation = (projectId, epicId, attemptId) => tableExists('epic_checkpoint_continuations') && !!db.prepare(`
|
|
99
|
-
SELECT 1 FROM epic_checkpoint_continuations c WHERE c.project_id = ? AND c.epic_id = ? AND (? IS NULL OR c.attempt_id = ?)
|
|
100
|
-
AND NOT EXISTS (SELECT 1 FROM epic_checkpoint_stage_receipts r WHERE r.continuation_id = c.id AND r.stage = 'advance') LIMIT 1`)
|
|
101
|
-
.get(projectId, epicId, attemptId ?? null, attemptId ?? null);
|
|
102
|
-
const bundleHasActiveWork = (projectId, bundleId) => !!db.prepare(`SELECT 1 FROM execution_runs r
|
|
103
|
-
JOIN execution_run_links l ON l.execution_run_id = r.id AND l.project_id = r.project_id
|
|
104
|
-
WHERE r.project_id = ? AND l.entity_type = 'bundle' AND l.entity_id = ? AND r.status IN ('queued', 'running', 'waiting')
|
|
105
|
-
AND r.kind != 'epic_build' LIMIT 1`).get(projectId, bundleId);
|
|
106
|
-
const hasRecoveredBuildScope = (attempt) => {
|
|
107
|
-
if (!attempt?.retry_of_attempt_id || !attempt.tickets.length) {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
const checkpoints = epics.listEpicTicketCheckpoints(attempt.epic_id, attempt.project_id);
|
|
111
|
-
return attempt.tickets.every(ticket => {
|
|
112
|
-
if (!ticket.ticket_id || !ticket.completed_build) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
const recovery = resolveEpicAttemptTicketBuildRecovery(attempt, ticket.roadmap_ticket_id, ticket.ticket_id, checkpoints);
|
|
116
|
-
return Boolean(recovery.completed_build && !recovery.blocker);
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
/** Local snapshot; remote reconciliation authority requires a surrounding
|
|
120
|
-
* withEpicTargetObservation callback. Without it, receipts fail closed. */
|
|
121
|
-
export const readObservedEpicAutomationSnapshot = (projectId, epicId, oneShot, unitSelection) => {
|
|
122
|
-
ensureEpicTargetRecovery(projectId, epicId);
|
|
123
|
-
const epic = requireProjectEpic(projectId, epicId);
|
|
124
|
-
const runs = db.prepare(`SELECT r.id, r.status, r.metadata_json FROM execution_runs r JOIN execution_run_links l
|
|
125
|
-
ON l.execution_run_id = r.id AND l.project_id = r.project_id
|
|
126
|
-
WHERE r.project_id = ? AND l.entity_type = 'epic' AND l.entity_id = ? AND l.relationship = 'primary' AND r.kind = 'epic_plan'
|
|
127
|
-
AND json_extract(r.metadata_json, '$.epic_conversation') IS NULL
|
|
128
|
-
AND json_extract(r.metadata_json, '$.epic_planning_invocation') IS NULL`)
|
|
129
|
-
.all(projectId, epicId);
|
|
130
|
-
const failedQueuedPlans = new Set(db.prepare(`SELECT execution_run_id FROM epic_automation_claims
|
|
131
|
-
WHERE project_id = ? AND epic_id = ? AND (state = 'failed' OR (state = 'claimed' AND dispatch_attempts > 1)) AND claim_key NOT LIKE 'one-shot:%'
|
|
132
|
-
AND json_extract(action_json, '$.kind') = 'plan' AND execution_run_id IS NOT NULL`)
|
|
133
|
-
.all(projectId, epicId).map(claim => claim.execution_run_id));
|
|
134
|
-
const outcomes = db.prepare('SELECT attempt_id, observation_json FROM epic_pull_request_outcomes WHERE epic_id = ? AND project_id = ?')
|
|
135
|
-
.all(epicId, projectId);
|
|
136
|
-
const attempts = epics.listEpicAttempts(epicId, projectId).map(attempt => {
|
|
137
|
-
const replacement = readEpicReplacementDelivery(attempt);
|
|
138
|
-
if (replacement) {
|
|
139
|
-
return attempt;
|
|
140
|
-
}
|
|
141
|
-
const saved = outcomes.find(outcome => outcome.attempt_id === attempt.id);
|
|
142
|
-
const observation = saved ? JSON.parse(saved.observation_json) : null;
|
|
143
|
-
return observation && matchesEpicPullRequestObservation(attempt, observation)
|
|
144
|
-
? { ...attempt, pull_request: { ...attempt.pull_request, state: observation.state } } : attempt;
|
|
145
|
-
});
|
|
146
|
-
const buildRuns = attempts.filter(attempt => attempt.kind === 'build').map(attempt => ({ attempt, run: getExecutionRun(projectId, `epic-attempt:${attempt.id}`) }));
|
|
147
|
-
const proposals = listEpicProposals(epicId, projectId);
|
|
148
|
-
const activeProposal = proposals.some(proposal => ['preparing', 'awaiting_review'].includes(proposal.status));
|
|
149
|
-
const waves = hasExecutionUnits(projectId, epicId) ? listEpicWaves(epicId, projectId).filter(isActiveEpicWave) : [];
|
|
150
|
-
const unitDeliveries = waves.flatMap(wave => listEpicUnitDeliveryReceipts({ project_id: projectId, epic_id: epicId, wave_id: wave.id }));
|
|
151
|
-
const waveProjection = epic.current_revision_id && waves.length
|
|
152
|
-
? getEpicWaveReconciliationState(projectId, epicId, epic.current_revision_id) : null;
|
|
153
|
-
const reconciled = waveProjection?.receipts ?? [];
|
|
154
|
-
const readReconciliation = activeProposal ? readEpicApprovedRevisionReconciliationEvidence : readEpicPostMergeEvidence;
|
|
155
|
-
const reconciledAttemptIds = epic.current_revision_id ? resolveReconciledEpicAttemptIds(readReconciliation(projectId, epicId, epic.current_revision_id), attempts, unitDeliveries) : [];
|
|
156
|
-
const effectiveReconciledAttemptIds = reconciledAttemptIds.filter(id => {
|
|
157
|
-
const attempt = attempts.find(attempt => attempt.id === id);
|
|
158
|
-
return !readEpicReplacementDelivery(attempt) || reconciled.some(receipt => receipt.members.some(member => member.attempt_id === id));
|
|
159
|
-
});
|
|
160
|
-
const revision = epic.current_revision_id ? epics.getEpicRevision(epic.current_revision_id, epicId, projectId) : null;
|
|
161
|
-
const prAccepted = revision && getEpicVerificationPolicy(projectId, epicId).mode === 'pr_reviewed'
|
|
162
|
-
? getEpicPrAcceptedProgress(projectId, epicId) : null;
|
|
163
|
-
const currentWaveIds = new Set(waves.filter(wave => wave.revision_id === revision?.id).map(wave => wave.id));
|
|
164
|
-
const snapshot = { epic, revision, verification_policy: getEpicVerificationPolicy(projectId, epicId),
|
|
165
|
-
...(prAccepted ? { prAcceptedProgress: { required: prAccepted.required, current: Boolean(prAccepted.receipt),
|
|
166
|
-
generation: prAccepted.generation, acceptedPackageIds: [...prAccepted.acceptedPackageIds], remainingPackageIds: prAccepted.remainingPackageIds,
|
|
167
|
-
settledUnits: prAccepted.inventory.waves.flatMap(source => source.settlements.filter(settlement => settlement.completed_at)
|
|
168
|
-
.map(({ wave_id, unit_id, execution_plan_id, execution_plan_digest }) => ({ wave_id, unit_id, execution_plan_id, execution_plan_digest }))) } } : {}),
|
|
169
|
-
...(waveProjection ? { completedWavePackageIds: [...waveProjection.completed], assessmentOnlyPackageIds: [...waveProjection.assessmentOnly] } : {}),
|
|
170
|
-
attempts, hasExecutionUnits: hasExecutionUnits(projectId, epicId), executionPlans: listEpicExecutionPlans(epicId, projectId), materialization: epics.getEpicMaterialization(epicId, projectId),
|
|
171
|
-
waves: waves.map(wave => getEpicWaveMemberHistory({ project_id: projectId, epic_id: epicId, wave_id: wave.id })),
|
|
172
|
-
deliveryAssessments: revision?.roadmap.bundles.flatMap(pkg => getEpicPackageAssessmentHistory({ project_id: projectId,
|
|
173
|
-
epic_id: epicId, package_id: pkg.id }).assessments.filter(assessment => currentWaveIds.has(assessment.wave_id))),
|
|
174
|
-
approvedLegacyDeliveredPackageIds: attempts.filter(attempt => attempt.kind === 'build' && !attempt.wave_id && !attempt.execution_unit_id
|
|
175
|
-
&& revision?.plan?.kind === 'packages' && epicBuildMatchesApprovedPackage(attempt, revision.plan)
|
|
176
|
-
&& isEpicMergeDelivered(attempt)).map(attempt => attempt.roadmap_bundle_id),
|
|
177
|
-
mergeDeliveredAttemptIds: attempts.filter(attempt => isEpicMergeDelivered(attempt)
|
|
178
|
-
&& (!attempt.execution_unit_id || unitDeliveries.some(receipt => receipt.attempt_id === attempt.id))).map(attempt => attempt.id),
|
|
179
|
-
legacyBuildAttemptIds: attempts.filter(attempt => attempt.kind === 'build' && !attempt.execution_plan_id
|
|
180
|
-
&& epics.getEpicRevision(attempt.revision_id, epicId, projectId)?.plan?.kind !== 'packages').map(attempt => attempt.id),
|
|
181
|
-
checkpoints: epics.listEpicTicketCheckpoints(epicId, projectId), pendingApproval: proposals.some(proposal => proposal.status === 'awaiting_review'),
|
|
182
|
-
preparingProposal: proposals.some(proposal => proposal.status === 'preparing'),
|
|
183
|
-
approvedBuildRecoveryAttemptIds: activeProposal ? attempts.filter(attempt => attempt.kind === 'build'
|
|
184
|
-
&& hasEpicApprovedBuildRecoveryAuthority(projectId, attempt.id)).map(attempt => attempt.id) : [],
|
|
185
|
-
activePlanning: runs.some(run => ['queued', 'running', 'waiting'].includes(run.status) && !(run.status === 'queued' && failedQueuedPlans.has(run.id))),
|
|
186
|
-
outstandingContinuation: attempts.some(attempt => !isEpicMergeDelivered(attempt) && !readEpicUnitReplacementDelivery(attempt)
|
|
187
|
-
&& unfinishedContinuation(projectId, epicId, attempt.id)),
|
|
188
|
-
reconciledAttemptIds: effectiveReconciledAttemptIds, oneShot,
|
|
189
|
-
...(oneShot === 'build' && unitSelection ? { oneShotBuildUnit: unitSelection } : {}),
|
|
190
|
-
deletedTargetReason: getEpicDeletedTargetReason({ project_id: projectId, epic_id: epicId }),
|
|
191
|
-
pendingDispatchAttemptIds: buildRuns.filter(({ attempt, run }) => run && !readEpicUnitReplacementDelivery(attempt)
|
|
192
|
-
&& ['queued', 'running'].includes(run.status) && !hasBuildChild(projectId, run.id)
|
|
193
|
-
&& !bundleHasActiveWork(projectId, attempt.bundle_id)).map(({ attempt }) => attempt.id),
|
|
194
|
-
oneShotBuildAttemptIds: buildRuns.filter(({ run }) => run?.metadata?.epic_one_shot).map(({ attempt }) => attempt.id) };
|
|
195
|
-
if (isEpicFirstWaveEligible(projectId, epicId)) {
|
|
196
|
-
return { ...snapshot, first_wave: true };
|
|
197
|
-
}
|
|
198
|
-
return { ...snapshot, readiness_reassessment: readEpicReadinessReassessment(db, snapshot), contribution_planning_anchor: epic.target?.status === 'ready'
|
|
199
|
-
? readEpicContributionPlanningAnchor(snapshot) : undefined };
|
|
200
|
-
};
|
|
201
|
-
const readWithTarget = (projectId, epicId, read) => {
|
|
202
|
-
const target = ensureEpicTargetRecovery(projectId, epicId);
|
|
203
|
-
const epic = requireProjectEpic(projectId, epicId);
|
|
204
|
-
if (isEpicFirstWaveEligible(projectId, epicId)) {
|
|
205
|
-
return Promise.resolve(read());
|
|
206
|
-
}
|
|
207
|
-
const assessment = target.status === 'ready' && (hasEpicReconciliationGeneration(projectId, epicId, epic.current_revision_id)
|
|
208
|
-
|| getEpicVerificationPolicy(projectId, epicId).mode === 'pr_reviewed'
|
|
209
|
-
|| selectEpicContributionPlanning(projectId, epicId));
|
|
210
|
-
return assessment ? withAvailableEpicTargetObservation(projectId, epicId, read) : Promise.resolve(read());
|
|
211
|
-
};
|
|
212
|
-
export const readEpicAutomationSnapshot = (projectId, epicId, oneShot, unitSelection) => readWithTarget(projectId, epicId, () => readObservedEpicAutomationSnapshot(projectId, epicId, oneShot, unitSelection));
|
|
213
|
-
/** Claims commit in a local transaction after asynchronous observation and exact
|
|
214
|
-
* authority revalidation. Stable keys survive HTTP replay and scheduler restart. */
|
|
215
|
-
export const claimEpicAutomation = (projectId, epicId, oneShot, requestKey, continuationRunId, unitSelection, assertCleanupReady) => readWithTarget(projectId, epicId, () => db.transaction(() => {
|
|
216
|
-
supersedeLegacyEpicTechnicalBlockers(projectId, epicId, 'advance');
|
|
217
|
-
supersedeFirstWaveReadinessBlockers(projectId, epicId);
|
|
218
|
-
const snapshot = readObservedEpicAutomationSnapshot(projectId, epicId, oneShot, unitSelection);
|
|
219
|
-
const action = resolveEpicAutomation(snapshot);
|
|
220
|
-
assertCleanupReady?.(action);
|
|
221
|
-
db.prepare(`INSERT INTO epic_automation_state (epic_id, project_id, epic_version, action_json, updated_at)
|
|
222
|
-
VALUES (?, ?, ?, ?, ?) ON CONFLICT(epic_id) DO UPDATE SET epic_version = excluded.epic_version,
|
|
223
|
-
action_json = excluded.action_json, updated_at = excluded.updated_at`)
|
|
224
|
-
.run(epicId, projectId, snapshot.epic.version, JSON.stringify(action), new Date().toISOString());
|
|
225
|
-
if (action.kind === 'wait') {
|
|
226
|
-
const idleDraftWithoutAttempts = snapshot.epic.phase === 'draft' && snapshot.epic.execution_intent === 'idle' && !snapshot.attempts.length;
|
|
227
|
-
if (action.reason === 'deleted_target' && action.message && !idleDraftWithoutAttempts
|
|
228
|
-
&& !snapshot.epic.blockers.some(blocker => blocker.id === 'deleted-materialized-target')) {
|
|
229
|
-
epics.updateEpicProgress({ project_id: projectId, epic_id: epicId, expected_version: snapshot.epic.version, phase: 'blocked',
|
|
230
|
-
blockers: [...snapshot.epic.blockers, { id: 'deleted-materialized-target', kind: 'failure', message: action.message }] });
|
|
231
|
-
return { action, claim: null, blocked: true };
|
|
232
|
-
}
|
|
233
|
-
return { action, claim: null };
|
|
234
|
-
}
|
|
235
|
-
requireEpicTarget(projectId, epicId);
|
|
236
|
-
const durableAction = { ...(action.kind === 'build' ? { kind: action.kind, roadmap_bundle_id: action.roadmap_bundle_id,
|
|
237
|
-
...(action.execution_unit_id ? { execution_unit_id: action.execution_unit_id, wave_id: action.wave_id } : {}),
|
|
238
|
-
...(action.execution_plan_id ? { execution_plan_id: action.execution_plan_id, execution_plan_digest: action.execution_plan_digest } : {}) } : action),
|
|
239
|
-
verification_policy: snapshot.verification_policy };
|
|
240
|
-
const failedPlans = action.kind === 'plan' && !requestKey
|
|
241
|
-
? failedDispatchedEpicPlanIds(projectId, epicId, snapshot.epic.current_revision_id, durableAction) : [];
|
|
242
|
-
// A sibling completing (or settings/revision edits) must not create another unit dispatch claim.
|
|
243
|
-
const keyParts = action.kind === 'build' && action.execution_unit_id
|
|
244
|
-
? [durableAction, action.attempt_id ? snapshot.attempts.find(attempt => attempt.id === action.attempt_id)?.retry_of_attempt_id ?? null : null]
|
|
245
|
-
: [snapshot.epic.current_revision_id, durableAction,
|
|
246
|
-
snapshot.attempts.filter(attempt => attempt.kind === 'build' && attempt.status === 'completed').map(attempt => attempt.id).sort()];
|
|
247
|
-
const generation = !requestKey ? readEpicReconciliationGeneration(projectId, epicId, snapshot.epic.current_revision_id, durableAction) : null;
|
|
248
|
-
if (action.kind === 'plan') {
|
|
249
|
-
if (action.purpose === 'prepare_readiness' && snapshot.revision
|
|
250
|
-
&& createEpicPrerequisiteRefinementStore(db).get(projectId, epicId, snapshot.revision.id)) {
|
|
251
|
-
keyParts.push(READINESS_RECOVERY_INSTRUCTION);
|
|
252
|
-
}
|
|
253
|
-
keyParts.push(getEpicPlanningSemanticInput(snapshot.epic));
|
|
254
|
-
const resolutions = listEpicPlanningDecisionResolutions(snapshot.epic).map(item => item.message_id);
|
|
255
|
-
if (resolutions.length) {
|
|
256
|
-
keyParts.push(resolutions);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (generation) {
|
|
260
|
-
keyParts.push(generation);
|
|
261
|
-
}
|
|
262
|
-
if (action.kind === 'plan' && action.purpose === 'post_merge_reconciliation') {
|
|
263
|
-
keyParts.push(snapshot.attempts.flatMap(attempt => {
|
|
264
|
-
const replacement = readEpicReplacementDelivery(attempt);
|
|
265
|
-
return replacement ? [[attempt.id, replacement.selection_version]] : [];
|
|
266
|
-
}));
|
|
267
|
-
}
|
|
268
|
-
const ownedClaim = !requestKey && action.kind === 'build' && action.execution_unit_id && action.attempt_id
|
|
269
|
-
? db.prepare('SELECT claim_key FROM epic_automation_claims WHERE project_id = ? AND epic_id = ? AND execution_run_id = ? AND action_json = ? ORDER BY created_at LIMIT 1')
|
|
270
|
-
.get(projectId, epicId, `epic-attempt:${action.attempt_id}`, JSON.stringify(durableAction))
|
|
271
|
-
: undefined;
|
|
272
|
-
const key = requestKey ? `one-shot:${oneShot}:${requestKey}` : ownedClaim?.claim_key ?? hash(failedPlans.length ? [...keyParts, failedPlans] : keyParts);
|
|
273
|
-
return retainEpicAutomationClaim(projectId, epicId, key, action, durableAction, !oneShot && !requestKey, continuationRunId);
|
|
274
|
-
}).immediate());
|
|
275
|
-
const active = new Set();
|
|
276
|
-
const busy = new Map();
|
|
277
|
-
const ownOrchestration = (projectId, epicId) => {
|
|
278
|
-
requireProjectEpic(projectId, epicId);
|
|
279
|
-
const key = JSON.stringify([projectId, epicId]);
|
|
280
|
-
busy.set(key, (busy.get(key) ?? 0) + 1);
|
|
281
|
-
return () => {
|
|
282
|
-
const remaining = busy.get(key) - 1;
|
|
283
|
-
if (remaining) {
|
|
284
|
-
busy.set(key, remaining);
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
busy.delete(key);
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
/** Dispatch/admission ownership only; worker lifetime is inspected separately. */
|
|
292
|
-
export const isEpicOrchestrationBusy = (projectId, epicId) => busy.has(JSON.stringify([projectId, epicId]));
|
|
293
|
-
export const createEpicOrchestrator = (options) => {
|
|
294
|
-
const recoverPlanningCleanup = async (projectId, epicId) => {
|
|
295
|
-
try {
|
|
296
|
-
await recoverTerminalEpicPlanningCleanups(projectId, epicId);
|
|
297
|
-
}
|
|
298
|
-
catch (error) {
|
|
299
|
-
if (error instanceof EpicCleanupPendingError) {
|
|
300
|
-
return error;
|
|
301
|
-
}
|
|
302
|
-
throw error;
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
const getCommand = (projectId, epicId, kind, requestKey) => {
|
|
306
|
-
requireProjectEpic(projectId, epicId);
|
|
307
|
-
const claim = db.prepare('SELECT * FROM epic_automation_claims WHERE project_id = ? AND epic_id = ? AND claim_key = ?')
|
|
308
|
-
.get(projectId, epicId, `one-shot:${kind}:${requestKey}`);
|
|
309
|
-
return claim ? { action: JSON.parse(claim.action_json), state: claim.state, execution_run_id: claim.execution_run_id,
|
|
310
|
-
recoverable: claim.state === 'dispatched' && recoverableDispatch(projectId, claim) } : null;
|
|
311
|
-
};
|
|
312
|
-
const plan = async (input, claimKey, existingRunId, policy) => {
|
|
313
|
-
assertEpicVerificationPolicyCurrent(input.project_id, input.epic_id, policy);
|
|
314
|
-
if (options.plan) {
|
|
315
|
-
return options.plan(input);
|
|
316
|
-
}
|
|
317
|
-
const run = existingRunId ? getExecutionRun(input.project_id, existingRunId) : await admitEpicPlanningRun(input, options.io);
|
|
318
|
-
db.prepare('UPDATE epic_automation_claims SET execution_run_id = ? WHERE epic_id = ? AND claim_key = ?')
|
|
319
|
-
.run(run.id, input.epic_id, claimKey);
|
|
320
|
-
const { runSpecAgent } = await import('./agent.js');
|
|
321
|
-
assertEpicVerificationPolicyCurrent(input.project_id, input.epic_id, policy);
|
|
322
|
-
requireProjectEpic(input.project_id, input.epic_id);
|
|
323
|
-
requireEpicTarget(input.project_id, input.epic_id);
|
|
324
|
-
const completion = startEpicPlanningRun(input.project_id, run.id, { io: options.io, runAgent: runSpecAgent });
|
|
325
|
-
if (completion) {
|
|
326
|
-
void completion.catch(() => undefined);
|
|
327
|
-
}
|
|
328
|
-
return run;
|
|
329
|
-
};
|
|
330
|
-
const advanceOnce = async (projectId, epicId, cleanup, oneShot, requestKey, roadmapBundleId, unitSelection, retainWake) => {
|
|
331
|
-
const snapshot = (mode = oneShot, selection = unitSelection) => readEpicAutomationSnapshot(projectId, epicId, mode, selection);
|
|
332
|
-
if (unitSelection && (oneShot !== 'build' || !unitSelection.execution_unit_id?.trim() || !unitSelection.wave_id?.trim())) {
|
|
333
|
-
throw new HttpError(409, message('stepNotApproved'));
|
|
334
|
-
}
|
|
335
|
-
const lock = JSON.stringify([projectId, epicId]);
|
|
336
|
-
requireProjectEpic(projectId, epicId);
|
|
337
|
-
if (active.has(lock)) {
|
|
338
|
-
retainWake?.();
|
|
339
|
-
return { kind: 'wait', reason: 'dispatching' };
|
|
340
|
-
}
|
|
341
|
-
active.add(lock);
|
|
342
|
-
const release = ownOrchestration(projectId, epicId);
|
|
343
|
-
const releaseWake = holdEpicContinuationWake(projectId, epicId);
|
|
344
|
-
let claimed;
|
|
345
|
-
let attemptId;
|
|
346
|
-
let continuationRunId;
|
|
347
|
-
const planningCleanup = createEpicPlanningCleanupGuard(projectId, epicId);
|
|
348
|
-
const assertCleanupReady = (action) => {
|
|
349
|
-
planningCleanup.assertReady(action);
|
|
350
|
-
cleanup.assertReady(action);
|
|
351
|
-
};
|
|
352
|
-
try {
|
|
353
|
-
await retireSupersededEpicPlanningRuns(projectId, epicId, options.io);
|
|
354
|
-
await cleanup.replay();
|
|
355
|
-
await planningCleanup.recover();
|
|
356
|
-
const target = ensureEpicTargetRecovery(projectId, epicId);
|
|
357
|
-
const pendingTarget = target.status === 'failed' || target.status === 'provisioning';
|
|
358
|
-
if (target.status === 'historical_confirmation_required' || (pendingTarget && oneShot !== 'plan')) {
|
|
359
|
-
throw new HttpError(409, message('targetRecoveryRequired'));
|
|
360
|
-
}
|
|
361
|
-
if (oneShot) {
|
|
362
|
-
assertEpicTargetsNotDeleted({ project_id: projectId, epic_id: epicId });
|
|
363
|
-
}
|
|
364
|
-
if (oneShot && requestKey) {
|
|
365
|
-
const replay = getCommand(projectId, epicId, oneShot, requestKey);
|
|
366
|
-
if (replay && ((replay.action.kind !== oneShot && !(oneShot === 'plan' && ['complete', 'reconcile_pr_accepted'].includes(replay.action.kind))) || (roadmapBundleId
|
|
367
|
-
&& (replay.action.kind === 'plan' || replay.action.kind === 'build')
|
|
368
|
-
&& replay.action.roadmap_bundle_id && replay.action.roadmap_bundle_id !== roadmapBundleId)
|
|
369
|
-
|| (unitSelection && (replay.action.kind !== 'build' || replay.action.execution_unit_id !== unitSelection.execution_unit_id
|
|
370
|
-
|| replay.action.wave_id !== unitSelection.wave_id)))) {
|
|
371
|
-
throw new HttpError(409, message('orchestrationIdempotencyConflict'));
|
|
372
|
-
}
|
|
373
|
-
if (!unitSelection && replay?.action.kind === 'build' && replay.action.execution_unit_id && replay.action.wave_id) {
|
|
374
|
-
unitSelection = { execution_unit_id: replay.action.execution_unit_id, wave_id: replay.action.wave_id };
|
|
375
|
-
}
|
|
376
|
-
if (replay?.state === 'failed') {
|
|
377
|
-
throw new HttpError(409, message('orchestrationRetryRequired'));
|
|
378
|
-
}
|
|
379
|
-
if (replay?.state === 'dispatched' && !replay.recoverable) {
|
|
380
|
-
return { ...replay.action, execution_run_id: replay.execution_run_id };
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if (oneShot && roadmapBundleId) {
|
|
384
|
-
const observed = await snapshot();
|
|
385
|
-
const selected = resolveEpicAutomation(observed);
|
|
386
|
-
const activeBuild = oneShot === 'build' ? observed.attempts.find(attempt => attempt.kind === 'build' && ['pending', 'running'].includes(attempt.status)
|
|
387
|
-
&& (!unitSelection || (attempt.execution_unit_id === unitSelection.execution_unit_id && attempt.wave_id === unitSelection.wave_id))) : null;
|
|
388
|
-
const target = selected.kind === 'build' || (selected.kind === 'plan' && selected.purpose === 'next_bundle')
|
|
389
|
-
? selected.roadmap_bundle_id : activeBuild?.roadmap_bundle_id;
|
|
390
|
-
if (target && target !== roadmapBundleId) {
|
|
391
|
-
throw new HttpError(409, message('stepNotApproved'));
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
if (pendingTarget) {
|
|
395
|
-
const retry = await snapshot();
|
|
396
|
-
if (resolveEpicAutomation(retry).kind !== 'plan') {
|
|
397
|
-
throw new HttpError(409, message('targetRecoveryRequired'));
|
|
398
|
-
}
|
|
399
|
-
await prepareEpicTargetAdmission(projectId, epicId, retry.epic.version);
|
|
400
|
-
}
|
|
401
|
-
const liveEpic = requireProjectEpic(projectId, epicId);
|
|
402
|
-
if (!getEpicDeletedTargetReason({ project_id: projectId, epic_id: epicId }) && liveEpic.execution_intent === 'running' && !liveEpic.blockers.some(isEpicGlobalBlocker)
|
|
403
|
-
&& !['completed', 'cancelled', 'failed'].includes(liveEpic.phase)) {
|
|
404
|
-
requireEpicTarget(projectId, epicId);
|
|
405
|
-
const retained = oneShot === 'build' ? epics.listEpicAttempts(epicId, projectId).find(attempt => attempt.kind === 'build'
|
|
406
|
-
&& ['pending', 'running'].includes(attempt.status) && (!roadmapBundleId || attempt.roadmap_bundle_id === roadmapBundleId)
|
|
407
|
-
&& (!unitSelection || (attempt.execution_unit_id === unitSelection.execution_unit_id && attempt.wave_id === unitSelection.wave_id))
|
|
408
|
-
&& hasRecoveredBuildScope(attempt)) : null;
|
|
409
|
-
if (retained) {
|
|
410
|
-
db.prepare("UPDATE execution_runs SET metadata_json = json_set(COALESCE(metadata_json, '{}'), '$.epic_one_shot', 1) WHERE project_id = ? AND id = ?")
|
|
411
|
-
.run(projectId, `epic-attempt:${retained.id}`);
|
|
412
|
-
await options.resumeExecution?.(projectId, epicId, { explicit: true,
|
|
413
|
-
pullRequestTracking: { handleOutcome: async (input, observation) => { applyOutcome(input, observation); } } });
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
await options.resumeExecution?.(projectId, epicId, { explicit: false,
|
|
417
|
-
pullRequestTracking: { handleOutcome: async (input, observation) => { applyOutcome(input, observation); } } });
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
const observed = await snapshot();
|
|
421
|
-
if (!oneShot) {
|
|
422
|
-
const snapshot = observed;
|
|
423
|
-
const continuation = db.prepare(`SELECT r.id, r.status, r.metadata_json FROM execution_runs r JOIN execution_run_links l
|
|
424
|
-
ON l.execution_run_id = r.id AND l.project_id = r.project_id WHERE r.project_id = ? AND l.entity_type = 'epic'
|
|
425
|
-
AND l.entity_id = ? AND l.relationship = 'primary' AND r.kind = 'epic_plan'
|
|
426
|
-
AND json_extract(r.metadata_json, '$.epic_conversation') IS NULL
|
|
427
|
-
AND json_extract(r.metadata_json, '$.epic_planning_invocation') IS NULL ORDER BY r.rowid DESC LIMIT 1`).get(projectId, epicId);
|
|
428
|
-
const metadata = JSON.parse(continuation?.metadata_json ?? '{}');
|
|
429
|
-
const consumed = continuation && db.prepare('SELECT 1 FROM epic_plan_continuation_receipts WHERE source_run_id = ?').get(continuation.id);
|
|
430
|
-
if (!consumed && continuation?.status === 'completed' && metadata.epic_plan_one_shot
|
|
431
|
-
&& metadata.epic_planning?.purpose === 'post_merge_reconciliation' && metadata.epic_planning.result) {
|
|
432
|
-
const next = resolveEpicAutomation({ ...snapshot, oneShot: 'plan' });
|
|
433
|
-
if (next.kind === 'plan' && ['next_bundle', 'final_assessment'].includes(next.purpose)) {
|
|
434
|
-
oneShot = 'plan';
|
|
435
|
-
continuationRunId = continuation.id;
|
|
436
|
-
}
|
|
437
|
-
else if (next.kind === 'wait' && next.reason === 'build_disabled') {
|
|
438
|
-
// An already-materialized successor is the one authorized next step; no further Plan is needed.
|
|
439
|
-
db.prepare('INSERT OR IGNORE INTO epic_plan_continuation_receipts VALUES (?, ?, ?, ?, ?)')
|
|
440
|
-
.run(continuation.id, epicId, projectId, 'materialized_successor', new Date().toISOString());
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
if (!oneShot) {
|
|
444
|
-
if (!snapshot.hasExecutionUnits && snapshot.pendingDispatchAttemptIds?.some(id => snapshot.oneShotBuildAttemptIds?.includes(id))) {
|
|
445
|
-
oneShot = 'build';
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
const beforeClaim = observed.oneShot === oneShot ? observed : await snapshot();
|
|
450
|
-
const nextAction = resolveEpicAutomation(beforeClaim);
|
|
451
|
-
assertCleanupReady(nextAction);
|
|
452
|
-
if (target.status === 'unstarted' && resolveEpicAutomation(beforeClaim).kind !== 'wait') {
|
|
453
|
-
await prepareEpicTargetAdmission(projectId, epicId, beforeClaim.epic.version);
|
|
454
|
-
}
|
|
455
|
-
claimed = await claimEpicAutomation(projectId, epicId, oneShot, requestKey, continuationRunId, unitSelection, assertCleanupReady);
|
|
456
|
-
const { action, claim } = claimed;
|
|
457
|
-
if ('blocked' in claimed && claimed.blocked) {
|
|
458
|
-
options.io.emit('epic:updated', requireProjectEpic(projectId, epicId));
|
|
459
|
-
}
|
|
460
|
-
if (!claim) {
|
|
461
|
-
return action;
|
|
462
|
-
}
|
|
463
|
-
if (roadmapBundleId && (action.kind === 'build' || (action.kind === 'plan' && action.purpose === 'next_bundle')) && action.roadmap_bundle_id !== roadmapBundleId) {
|
|
464
|
-
throw new HttpError(409, message('stepNotApproved'));
|
|
465
|
-
}
|
|
466
|
-
// Re-read intent, blockers and both independent policy flags at the dispatch boundary.
|
|
467
|
-
const live = await snapshot();
|
|
468
|
-
const selected = resolveEpicAutomation(live);
|
|
469
|
-
if (JSON.stringify(selected) !== JSON.stringify(action)) {
|
|
470
|
-
return selected;
|
|
471
|
-
}
|
|
472
|
-
assertCleanupReady(selected);
|
|
473
|
-
const policy = resolveEpicVerificationPolicyCapture(JSON.parse(claim.action_json).verification_policy);
|
|
474
|
-
const assertPolicy = () => assertEpicVerificationPolicyCurrent(projectId, epicId, policy);
|
|
475
|
-
assertPolicy();
|
|
476
|
-
let runId;
|
|
477
|
-
if (action.kind === 'reconcile_pr_accepted') {
|
|
478
|
-
const receipt = await reconcileEpicPrAcceptedProgress({ project_id: projectId, epic_id: epicId,
|
|
479
|
-
expected_version: live.epic.version, verification_policy: policy }, () => {
|
|
480
|
-
assertPolicy();
|
|
481
|
-
assertCleanupReady(action);
|
|
482
|
-
const current = readObservedEpicAutomationSnapshot(projectId, epicId, oneShot, unitSelection);
|
|
483
|
-
if (JSON.stringify(resolveEpicAutomation(current)) !== JSON.stringify(action)) {
|
|
484
|
-
throw new HttpError(409, message('reconciliationVersionConflict'));
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
db.prepare("UPDATE epic_automation_claims SET state = 'dispatched', updated_at = ? WHERE epic_id = ? AND claim_key = ?")
|
|
488
|
-
.run(new Date().toISOString(), epicId, claim.claim_key);
|
|
489
|
-
options.io.emit('epic:updated', requireProjectEpic(projectId, epicId));
|
|
490
|
-
return { ...action, receipt_digest: receipt.digest };
|
|
491
|
-
}
|
|
492
|
-
else if (action.kind === 'complete') {
|
|
493
|
-
runId = await withEpicTargetObservation(projectId, epicId, () => {
|
|
494
|
-
assertPolicy();
|
|
495
|
-
const current = readObservedEpicAutomationSnapshot(projectId, epicId, oneShot, unitSelection);
|
|
496
|
-
if (resolveEpicAutomation(current).kind !== 'complete') {
|
|
497
|
-
throw new HttpError(409, message('reconciliationVersionConflict'));
|
|
498
|
-
}
|
|
499
|
-
assertCleanupReady(action);
|
|
500
|
-
return completePrReviewedEpic(current, claim.claim_key, policy);
|
|
501
|
-
});
|
|
502
|
-
options.io.emit('epic:updated', requireProjectEpic(projectId, epicId));
|
|
503
|
-
}
|
|
504
|
-
else if (action.kind === 'plan') {
|
|
505
|
-
const resolution = live.pendingApproval || live.preparingProposal ? null : getPendingEpicPlanningDecisionResolution(live.epic);
|
|
506
|
-
const run = await plan({ project_id: projectId, epic_id: epicId, expected_version: live.epic.version,
|
|
507
|
-
purpose: action.purpose, roadmap_bundle_id: action.roadmap_bundle_id, ...{ verification_policy: policy },
|
|
508
|
-
...(action.purpose === 'next_bundle' && selectEpicContributionPlanning(projectId, epicId) ? { contribution_aware: true } : {}),
|
|
509
|
-
idempotency_key: claim.dispatch_attempts > 1 && !claim.execution_run_id ? `${claim.claim_key}:dispatch:${claim.dispatch_attempts}` : claim.claim_key,
|
|
510
|
-
automatic: resolution ? false : oneShot !== 'plan',
|
|
511
|
-
...(action.purpose === 'prepare_readiness' && live.revision
|
|
512
|
-
&& createEpicPrerequisiteRefinementStore(db).get(projectId, epicId, live.revision.id)
|
|
513
|
-
? { instruction: buildEpicReadinessRecoveryInstruction(db, projectId, epicId, live.revision.id) } : {}),
|
|
514
|
-
...(resolution ? { instruction: resolution.instruction, decisionResolution: {
|
|
515
|
-
source_run_id: resolution.source_run_id, message_id: resolution.message_id
|
|
516
|
-
} } : {}),
|
|
517
|
-
oneShotContinuation: oneShot === 'plan' && action.purpose === 'post_merge_reconciliation' }, claim.claim_key, claim.execution_run_id, policy);
|
|
518
|
-
runId = run.id;
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
const acceptedVersion = await prepareEpicTargetAdmission(projectId, epicId, live.epic.version);
|
|
522
|
-
const admitted = await withEpicTargetObservation(projectId, epicId, () => db.transaction(() => {
|
|
523
|
-
assertPolicy();
|
|
524
|
-
const current = requireProjectEpic(projectId, epicId);
|
|
525
|
-
if (current.version !== acceptedVersion) {
|
|
526
|
-
throw new HttpError(409, message('reconciliationVersionConflict'));
|
|
527
|
-
}
|
|
528
|
-
recordEpicTargetAdmission(projectId, epicId);
|
|
529
|
-
assertCleanupReady(action);
|
|
530
|
-
assertEpicTargetsNotDeleted({ project_id: projectId, epic_id: epicId });
|
|
531
|
-
const existing = action.attempt_id ? epics.getEpicAttempt(action.attempt_id, epicId, projectId) : null;
|
|
532
|
-
const savedRequest = existing ? db.prepare('SELECT request_json FROM epic_attempts WHERE id = ? AND epic_id = ? AND project_id = ?')
|
|
533
|
-
.get(existing.id, epicId, projectId) : null;
|
|
534
|
-
const requestRevision = savedRequest ? JSON.parse(savedRequest.request_json).revision_id : current.current_revision_id;
|
|
535
|
-
const admission = requestPreparedProjectEpicAttempt(projectId, epicId, 'build', {
|
|
536
|
-
expected_version: current.version, revision_id: requestRevision,
|
|
537
|
-
roadmap_bundle_id: action.roadmap_bundle_id, idempotency_key: existing?.idempotency_key ?? claim.claim_key,
|
|
538
|
-
...(action.execution_unit_id ? { execution_unit_id: action.execution_unit_id, wave_id: action.wave_id } : {}),
|
|
539
|
-
...(action.execution_plan_id ? { execution_plan_id: action.execution_plan_id, execution_plan_digest: action.execution_plan_digest } : {}),
|
|
540
|
-
...(existing?.retry_of_attempt_id ? { retry_of_attempt_id: existing.retry_of_attempt_id } : {}),
|
|
541
|
-
}, { broadcaster: options.io });
|
|
542
|
-
const attempt = admission.value.attempt;
|
|
543
|
-
assertEpicAttemptExecutionPlan(attempt);
|
|
544
|
-
if (!sameEpicExecutionPlan(attempt, action)) {
|
|
545
|
-
throw new HttpError(409, message('admissionOwnershipRequired'));
|
|
546
|
-
}
|
|
547
|
-
attemptId = attempt.id;
|
|
548
|
-
const runId = `epic-attempt:${attempt.id}`;
|
|
549
|
-
db.prepare('UPDATE epic_automation_claims SET execution_run_id = ? WHERE epic_id = ? AND claim_key = ?')
|
|
550
|
-
.run(runId, epicId, claim.claim_key);
|
|
551
|
-
// One-shot authorization belongs to the immutable admitted execution, not global settings.
|
|
552
|
-
if (oneShot === 'build') {
|
|
553
|
-
db.prepare("UPDATE execution_runs SET metadata_json = json_set(COALESCE(metadata_json, '{}'), '$.epic_one_shot', 1) WHERE id = ? AND project_id = ?")
|
|
554
|
-
.run(runId, projectId);
|
|
555
|
-
}
|
|
556
|
-
if (attempt.status === 'pending') {
|
|
557
|
-
epics.updateEpicAttempt({ project_id: projectId, epic_id: epicId, expected_version: requireProjectEpic(projectId, epicId).version,
|
|
558
|
-
attempt_id: attempt.id, expected_attempt_version: attempt.version, status: 'running' });
|
|
559
|
-
}
|
|
560
|
-
return { attempt, runId, flush: admission.flush };
|
|
561
|
-
}).immediate());
|
|
562
|
-
admitted.flush?.();
|
|
563
|
-
runId = admitted.runId;
|
|
564
|
-
const assertDispatchAvailable = () => {
|
|
565
|
-
assertPolicy();
|
|
566
|
-
assertCleanupReady(action);
|
|
567
|
-
const current = requireProjectEpic(projectId, epicId);
|
|
568
|
-
requireEpicTarget(projectId, epicId);
|
|
569
|
-
assertEpicTargetsNotDeleted({ project_id: projectId, epic_id: epicId });
|
|
570
|
-
if (!hasBuildChild(projectId, runId)
|
|
571
|
-
&& listEpicProposals(epicId, projectId).some(proposal => ['preparing', 'awaiting_review'].includes(proposal.status))
|
|
572
|
-
&& !hasEpicApprovedBuildRecoveryAuthority(projectId, admitted.attempt.id)) {
|
|
573
|
-
throw new HttpError(409, message('admissionProposalUnresolved'));
|
|
574
|
-
}
|
|
575
|
-
const blocked = current.blockers.some(blocker => epicBlockerAppliesToExecution(blocker, admitted.attempt));
|
|
576
|
-
if (['paused', 'cancelled'].includes(current.execution_intent) || blocked
|
|
577
|
-
|| (!oneShot && !getExecutionRun(projectId, runId)?.metadata?.epic_one_shot && !current.settings.auto_build_planned_bundle)) {
|
|
578
|
-
throw new HttpError(409, message('buildDispatchUnavailable'));
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
if (hasRecoveredBuildScope(admitted.attempt)) {
|
|
582
|
-
assertDispatchAvailable();
|
|
583
|
-
consumeEpicUnitCorrectiveExecution(admitted.attempt);
|
|
584
|
-
transitionExecutionRun({ projectId, runId, status: 'running', domainStatus: 'checkpoint_recovery' }, options.io);
|
|
585
|
-
await options.resumeExecution?.(projectId, epicId, { explicit: oneShot === 'build' || !!getExecutionRun(projectId, runId)?.metadata?.epic_one_shot });
|
|
586
|
-
transitionExecutionRun({ projectId, runId, status: 'waiting',
|
|
587
|
-
domainStatus: unfinishedContinuation(projectId, epicId) ? 'checkpoint_deferred' : 'awaiting_pull_request' }, options.io);
|
|
588
|
-
}
|
|
589
|
-
else {
|
|
590
|
-
const result = await withEpicTargetObservation(projectId, epicId, () => {
|
|
591
|
-
assertDispatchAvailable();
|
|
592
|
-
consumeEpicUnitCorrectiveExecution(admitted.attempt);
|
|
593
|
-
return options.buildBundle(projectId, admitted.attempt.bundle_id, options.io, {
|
|
594
|
-
parentRunId: runId, epicId, attemptId: admitted.attempt.id,
|
|
595
|
-
execution_plan_id: admitted.attempt.execution_plan_id, execution_plan_digest: admitted.attempt.execution_plan_digest,
|
|
596
|
-
execution_unit_id: admitted.attempt.execution_unit_id, wave_id: admitted.attempt.wave_id,
|
|
597
|
-
retryOfAttemptId: admitted.attempt.retry_of_attempt_id,
|
|
598
|
-
ticketIds: admitted.attempt.tickets.flatMap(ticket => ticket.ticket_id ? [ticket.ticket_id] : []),
|
|
599
|
-
oneShot: oneShot === 'build' || !!getExecutionRun(projectId, runId)?.metadata?.epic_one_shot,
|
|
600
|
-
});
|
|
601
|
-
});
|
|
602
|
-
if (!result.ok) {
|
|
603
|
-
throw new HttpError(result.status, result.error ?? message('buildSchedulingFailed'));
|
|
604
|
-
}
|
|
605
|
-
const root = getExecutionRun(projectId, runId);
|
|
606
|
-
if (root?.status !== 'running' || root.domain_status !== 'building') {
|
|
607
|
-
transitionExecutionRun({ projectId, runId, status: 'running', domainStatus: 'building' }, options.io);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
db.prepare("UPDATE epic_automation_claims SET state = 'dispatched', execution_run_id = ?, updated_at = ? WHERE epic_id = ? AND claim_key = ?")
|
|
612
|
-
.run(runId, new Date().toISOString(), epicId, claim.claim_key);
|
|
613
|
-
return { ...action, execution_run_id: runId };
|
|
614
|
-
}
|
|
615
|
-
catch (error) {
|
|
616
|
-
if (error instanceof EpicCleanupPendingError && !claimed?.claim) {
|
|
617
|
-
projectEpicCleanupWait(projectId, epicId, options.io);
|
|
618
|
-
}
|
|
619
|
-
const failure = error instanceof Error ? error.message : String(error);
|
|
620
|
-
db.transaction(() => {
|
|
621
|
-
if (claimed?.claim) {
|
|
622
|
-
db.prepare("UPDATE epic_automation_claims SET state = 'failed', failure = ?, updated_at = ? WHERE epic_id = ? AND claim_key = ?")
|
|
623
|
-
.run(failure, new Date().toISOString(), epicId, claimed.claim.claim_key);
|
|
624
|
-
}
|
|
625
|
-
if (attemptId) {
|
|
626
|
-
const attempt = epics.getEpicAttempt(attemptId, epicId, projectId);
|
|
627
|
-
if (attempt && ['pending', 'running'].includes(attempt.status)) {
|
|
628
|
-
epics.updateEpicAttempt({ project_id: projectId, epic_id: epicId, expected_version: requireProjectEpic(projectId, epicId).version,
|
|
629
|
-
attempt_id: attempt.id, expected_attempt_version: attempt.version, status: 'failed', failure });
|
|
630
|
-
}
|
|
631
|
-
const run = getExecutionRun(projectId, `epic-attempt:${attemptId}`);
|
|
632
|
-
if (run && ['queued', 'running', 'waiting'].includes(run.status)) {
|
|
633
|
-
transitionExecutionRun({ projectId, runId: run.id, status: 'failed', domainStatus: 'scheduling_failed', failure: { code: 'scheduling_failed', message: failure } }, options.io);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
}).immediate();
|
|
637
|
-
throw error;
|
|
638
|
-
}
|
|
639
|
-
finally {
|
|
640
|
-
active.delete(lock);
|
|
641
|
-
release();
|
|
642
|
-
releaseWake();
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
// Drain only the already-published wave. Each admission owns its own durable claim,
|
|
646
|
-
// and advanceOnce releases its lock as soon as dispatch returns, not at worker completion.
|
|
647
|
-
const advance = async (projectId, epicId, oneShot, requestKey, roadmapBundleId, unitSelection) => {
|
|
648
|
-
const cleanup = createEpicMergedCleanup(projectId, epicId, options.stopMergedExecution, applyOutcome, options.io);
|
|
649
|
-
const retainWake = claimEpicContinuationWakeDelivery(projectId, epicId);
|
|
650
|
-
if (oneShot || unitSelection || !hasExecutionUnits(projectId, epicId)) {
|
|
651
|
-
return advanceOnce(projectId, epicId, cleanup, oneShot, requestKey, roadmapBundleId, unitSelection, retainWake);
|
|
652
|
-
}
|
|
653
|
-
const visited = new Set();
|
|
654
|
-
let firstResult;
|
|
655
|
-
let firstError;
|
|
656
|
-
while (true) {
|
|
657
|
-
const selected = resolveEpicAutomation(await readEpicAutomationSnapshot(projectId, epicId));
|
|
658
|
-
if (selected.kind !== 'build' || !selected.execution_unit_id) {
|
|
659
|
-
break;
|
|
660
|
-
}
|
|
661
|
-
const identity = JSON.stringify([selected.wave_id, selected.execution_unit_id, selected.attempt_id]);
|
|
662
|
-
if (visited.has(identity)) {
|
|
663
|
-
break;
|
|
664
|
-
}
|
|
665
|
-
visited.add(identity);
|
|
666
|
-
try {
|
|
667
|
-
const result = await advanceOnce(projectId, epicId, cleanup, undefined, undefined, undefined, undefined, retainWake);
|
|
668
|
-
firstResult ??= result;
|
|
669
|
-
if (result.kind === 'wait') {
|
|
670
|
-
break;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
catch (error) {
|
|
674
|
-
firstError ??= error;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
if (firstError) {
|
|
678
|
-
throw firstError;
|
|
679
|
-
}
|
|
680
|
-
return firstResult ?? advanceOnce(projectId, epicId, cleanup, undefined, undefined, undefined, undefined, retainWake);
|
|
681
|
-
};
|
|
682
|
-
const applyOutcome = (input, observation) => {
|
|
683
|
-
if (!['merged', 'closed'].includes(observation.state)) {
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
db.transaction(() => {
|
|
687
|
-
const epic = requireProjectEpic(input.project_id, input.epic_id);
|
|
688
|
-
const attempt = epics.getEpicAttempt(input.attempt_id, epic.id, epic.project_id);
|
|
689
|
-
const run = attempt && getExecutionRun(epic.project_id, `epic-attempt:${attempt.id}`);
|
|
690
|
-
if (!attempt) {
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
// Replacement evidence is independent of the immutable original outcome ledger.
|
|
694
|
-
if (readEpicUnitReplacementDelivery(attempt)) {
|
|
695
|
-
const replacement = readEpicReplacementDelivery(attempt);
|
|
696
|
-
if (replacement) {
|
|
697
|
-
recordVerifiedEpicUnitDelivery(attempt, replacement.observation);
|
|
698
|
-
}
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
if (!matchesEpicPullRequestObservation(attempt, observation)) {
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
// A late closed observation must never regress a verified merge.
|
|
705
|
-
const priorMerge = readEpicMergedDelivery(attempt);
|
|
706
|
-
if (priorMerge && (observation.state === 'closed' || priorMerge.merge_commit_sha || !observation.merge_commit_sha)) {
|
|
707
|
-
observation = priorMerge;
|
|
708
|
-
}
|
|
709
|
-
// Immutable PR links remain untouched; lifecycle observations have their own durable receipt.
|
|
710
|
-
db.prepare(`INSERT INTO epic_pull_request_outcomes (attempt_id, epic_id, project_id, observation_json, observed_at)
|
|
711
|
-
VALUES (?, ?, ?, ?, ?) ON CONFLICT(attempt_id) DO UPDATE SET observation_json = excluded.observation_json, observed_at = excluded.observed_at`)
|
|
712
|
-
.run(attempt.id, epic.id, epic.project_id, JSON.stringify(observation), observation.verified_at);
|
|
713
|
-
const scope = () => ({ project_id: epic.project_id, epic_id: epic.id, expected_version: requireProjectEpic(epic.project_id, epic.id).version });
|
|
714
|
-
if (observation.state === 'closed') {
|
|
715
|
-
if (attempt.status === 'completed' || attempt.status === 'cancelled') {
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
if (epics.listEpicAttempts(epic.id, epic.project_id).some(candidate => candidate.retry_of_attempt_id === attempt.id)) {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
if (['pending', 'running'].includes(attempt.status)) {
|
|
722
|
-
epics.updateEpicAttempt({ ...scope(), attempt_id: attempt.id, expected_attempt_version: attempt.version,
|
|
723
|
-
status: 'failed', failure: message('pullRequestClosed') });
|
|
724
|
-
}
|
|
725
|
-
const blockerId = `pr-closed-${attempt.id}`;
|
|
726
|
-
if (!epic.blockers.some(blocker => blocker.id === blockerId)) {
|
|
727
|
-
epics.updateEpicProgress({ ...scope(), phase: 'blocked', blockers: [...epic.blockers, { id: blockerId, kind: 'failure', message: message('pullRequestClosed'),
|
|
728
|
-
...(attempt.execution_unit_id ? { scope: { kind: 'unit', wave_id: attempt.wave_id, unit_id: attempt.execution_unit_id } } : {}) }] });
|
|
729
|
-
if (epic.execution_intent === 'cancelled' || epic.execution_intent === 'idle') {
|
|
730
|
-
epics.updateEpic({ ...scope(), execution_intent: epic.execution_intent });
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
if (run && ['queued', 'running', 'waiting'].includes(run.status)) {
|
|
734
|
-
transitionExecutionRun({ projectId: epic.project_id, runId: run.id, status: 'failed', domainStatus: 'pr_closed' }, options.io);
|
|
735
|
-
}
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
if (!['pending', 'running'].includes(attempt.status)) {
|
|
739
|
-
if (attempt.status === 'completed' || attempt.execution_unit_id) {
|
|
740
|
-
recordVerifiedEpicUnitDelivery(attempt, observation);
|
|
741
|
-
}
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
// Delivery authority is the verified merge, not reconstruction of the
|
|
745
|
-
// agent's historical checkpoints. Preserve those records without inventing receipts.
|
|
746
|
-
if (attempt.status === 'pending') {
|
|
747
|
-
epics.updateEpicAttempt({ ...scope(), attempt_id: attempt.id, expected_attempt_version: attempt.version, status: 'running' });
|
|
748
|
-
}
|
|
749
|
-
const current = epics.getEpicAttempt(attempt.id, epic.id, epic.project_id);
|
|
750
|
-
const completed = epics.updateEpicAttempt({ ...scope(), attempt_id: attempt.id, expected_attempt_version: current.version, status: 'completed' });
|
|
751
|
-
recordVerifiedEpicUnitDelivery(completed, observation);
|
|
752
|
-
if (run && ['queued', 'running', 'waiting'].includes(run.status)) {
|
|
753
|
-
transitionExecutionRun({ projectId: epic.project_id, runId: run.id, status: 'completed', domainStatus: 'merged' }, options.io);
|
|
754
|
-
}
|
|
755
|
-
}).immediate();
|
|
756
|
-
options.io.emit('epic:updated', epics.getEpic(input.epic_id, input.project_id));
|
|
757
|
-
};
|
|
758
|
-
const replayMergedDeliveries = async (projectId, epicId) => {
|
|
759
|
-
await createEpicMergedCleanup(projectId, epicId, options.stopMergedExecution, applyOutcome, options.io).replay();
|
|
760
|
-
};
|
|
761
|
-
const handleOutcome = async (input, observation) => {
|
|
762
|
-
const release = ownOrchestration(input.project_id, input.epic_id);
|
|
763
|
-
try {
|
|
764
|
-
applyOutcome(input, observation);
|
|
765
|
-
await advance(input.project_id, input.epic_id);
|
|
766
|
-
}
|
|
767
|
-
finally {
|
|
768
|
-
release();
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
const tick = async (limit = 10, cursor = '') => {
|
|
772
|
-
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50) {
|
|
773
|
-
throw new HttpError(400, message('invalidOrchestrationLimit'));
|
|
774
|
-
}
|
|
775
|
-
const rows = db.prepare(`SELECT id, project_id FROM epics WHERE id > ? AND execution_intent IN ('idle', 'running', 'paused')
|
|
776
|
-
AND phase NOT IN ('completed', 'cancelled') ORDER BY id LIMIT ?`).all(cursor, limit + 1);
|
|
777
|
-
const results = [];
|
|
778
|
-
for (const row of rows.slice(0, limit)) {
|
|
779
|
-
let release;
|
|
780
|
-
try {
|
|
781
|
-
release = ownOrchestration(row.project_id, row.id);
|
|
782
|
-
const key = JSON.stringify([row.project_id, row.id]);
|
|
783
|
-
if (await expireRetainedEpicPlanningRecovery(row.project_id, row.id, options.io, () => busy.get(key) === 1 && !active.has(key))) {
|
|
784
|
-
options.io.emit('epic:updated', requireProjectEpic(row.project_id, row.id));
|
|
785
|
-
results.push({ epic_id: row.id, action: { kind: 'wait', reason: 'failure' } });
|
|
786
|
-
continue;
|
|
787
|
-
}
|
|
788
|
-
await retireSupersededEpicPlanningRuns(row.project_id, row.id, options.io);
|
|
789
|
-
const target = ensureEpicTargetRecovery(row.project_id, row.id);
|
|
790
|
-
const paused = requireProjectEpic(row.project_id, row.id).execution_intent === 'paused';
|
|
791
|
-
if (paused || target.status !== 'ready') {
|
|
792
|
-
await replayMergedDeliveries(row.project_id, row.id);
|
|
793
|
-
await recoverPlanningCleanup(row.project_id, row.id);
|
|
794
|
-
}
|
|
795
|
-
if (paused) {
|
|
796
|
-
await options.resumeExecution?.(row.project_id, row.id, { explicit: false,
|
|
797
|
-
pullRequestTracking: { handleOutcome: async (input, observation) => { applyOutcome(input, observation); } } });
|
|
798
|
-
results.push({ epic_id: row.id, action: { kind: 'wait', reason: 'unavailable' } });
|
|
799
|
-
continue;
|
|
800
|
-
}
|
|
801
|
-
if (!options.plan) {
|
|
802
|
-
await dispatchRetainedEpicPlanningRuns(row.project_id, row.id, options.io);
|
|
803
|
-
// Retained failures own their cooldown and budget even when an older
|
|
804
|
-
// claim key differs from today's automatic admission generation.
|
|
805
|
-
const pendingFailure = db.prepare(`SELECT 1 FROM epic_automation_claims c JOIN execution_runs r
|
|
806
|
-
ON r.id = c.execution_run_id AND r.project_id = c.project_id WHERE c.project_id = ? AND c.epic_id = ?
|
|
807
|
-
AND c.state = 'failed' AND r.kind = 'epic_plan' AND r.status IN ('queued', 'waiting') LIMIT 1`)
|
|
808
|
-
.get(row.project_id, row.id);
|
|
809
|
-
if (pendingFailure) {
|
|
810
|
-
results.push({ epic_id: row.id, action: { kind: 'wait', reason: 'planning' } });
|
|
811
|
-
continue;
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
if (target.status !== 'ready') {
|
|
815
|
-
results.push({ epic_id: row.id, action: { kind: 'wait', reason: 'unavailable' } });
|
|
816
|
-
continue;
|
|
817
|
-
}
|
|
818
|
-
results.push({ epic_id: row.id, action: await advance(row.project_id, row.id) });
|
|
819
|
-
}
|
|
820
|
-
catch (error) {
|
|
821
|
-
results.push({ epic_id: row.id, error: describeEpicAutomationError(error) });
|
|
822
|
-
}
|
|
823
|
-
finally {
|
|
824
|
-
release?.();
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
return { results, next_cursor: rows.length > limit ? rows[limit - 1].id : null };
|
|
828
|
-
};
|
|
829
|
-
return { advance, handleOutcome, tick, getCommand, replayMergedDeliveries };
|
|
830
|
-
};
|
|
1
|
+
import { createEpicOrchestrator as createCoreOrchestrator } from './epicOrchestrationCore.js';
|
|
2
|
+
import { productionEpicPlanningDispatch } from './epicPlanningDispatchProduction.js';
|
|
3
|
+
export { claimEpicAutomation, isEpicOrchestrationBusy, readEpicAutomationSnapshot, readObservedEpicAutomationSnapshot } from './epicOrchestrationCore.js';
|
|
4
|
+
export const createEpicOrchestrator = (options) => createCoreOrchestrator({ ...options, planningDispatch: options.planningDispatch ?? productionEpicPlanningDispatch });
|
|
831
5
|
//# sourceMappingURL=epicOrchestration.js.map
|