specrails-desktop 2.29.1 → 2.29.3
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/client/dist/assets/ActivityFeedPage-CFB4UBhT.js +1 -0
- package/client/dist/assets/AgentBrowserCapture-C-T0r16B.js +1 -0
- package/client/dist/assets/AgentModeCodePane-IljV5FOQ.js +2 -0
- package/client/dist/assets/AgentModeJobsPane-B5miH10_.js +1 -0
- package/client/dist/assets/AgentsPage-BgYQrAcH.js +86 -0
- package/client/dist/assets/AnalyticsPage-BtVCuNjL.js +1 -0
- package/client/dist/assets/BarChart-nBOMNfiy.js +33 -0
- package/client/dist/assets/CodePage-Cb_jAjSV.js +2 -0
- package/client/dist/assets/DesktopAnalyticsPage-s_Cc_JL1.js +1 -0
- package/client/dist/assets/DocsDialog-Cr47QI9L.js +11 -0
- package/client/dist/assets/DocsPage-C_WPRuG_.js +11 -0
- package/client/dist/assets/ExportDropdown-BrtfWzEG.js +1 -0
- package/client/dist/assets/IntegrationsPage-Bs00_tl4.js +1 -0
- package/client/dist/assets/InteractiveJobComposer-NfFOciRB.js +19 -0
- package/client/dist/assets/JobDetailModal-DqEW7Z7K.js +1 -0
- package/client/dist/assets/JobDetailPage-D4ppEpDE.js +1 -0
- package/client/dist/assets/JobsPage-DStSoMyq.js +1 -0
- package/client/dist/assets/LoopBuilderPage-DltCwS4P.js +7 -0
- package/client/dist/assets/LoopPreviewModal-BWaiAbUq.js +1 -0
- package/client/dist/assets/LoopsPage-BqjbXuBZ.js +1 -0
- package/client/dist/assets/MinimizedChatsContext--o3JAM9F.js +1 -0
- package/client/dist/assets/PluginsPage-B-UOmzXw.js +2 -0
- package/client/dist/assets/ProjectSettingsDialog-DkGajIxE.js +1 -0
- package/client/dist/assets/TemplatePreviewModal-5CUXlkw7.js +1 -0
- package/client/dist/assets/TicketDetailModal-B_igqmti.js +14 -0
- package/client/dist/assets/Trans-DDMIBBUd.js +1 -0
- package/client/dist/assets/activity-DiyjsgQV.js +1 -0
- package/client/dist/assets/addon-image-BRmmRHgQ.js +1 -0
- package/client/dist/assets/addon-ligatures-qIZUPvRV.js +2 -0
- package/client/dist/assets/{addon-webgl-DMbGeI_u.js → addon-webgl-C2d7lriQ.js} +3 -3
- package/client/dist/assets/addspec-Rw8uVBC1.js +1 -0
- package/client/dist/assets/agent-BXc59ARK2.js +1 -0
- package/client/dist/assets/agent-BbIFXdDq.js +1 -0
- package/client/dist/assets/agent-BqEfA5u5.js +1 -0
- package/client/dist/assets/agent-BtGzgTC4.js +1 -0
- package/client/dist/assets/agent-CIhys_5d.js +1 -0
- package/client/dist/assets/agent-CJPaqsVR.js +1 -0
- package/client/dist/assets/agent-n-hY4GuL.js +1 -0
- package/client/dist/assets/agent-tJ-efa3_2.js +1 -0
- package/client/dist/assets/agents-DhG7mg6-.js +1 -0
- package/client/dist/assets/agentstudio-BIUe1Im2.js +1 -0
- package/client/dist/assets/aiedit-iIjz2_Qk.js +1 -0
- package/client/dist/assets/analytics-DZ8Aoq3I.js +1 -0
- package/client/dist/assets/api-B2M7CtDw.js +1 -0
- package/client/dist/assets/arrow-left-CpIR4j7G.js +1 -0
- package/client/dist/assets/arrow-up-right-9DoMn7fD.js +1 -0
- package/client/dist/assets/attachments-B53PG733.js +1 -0
- package/client/dist/assets/brain-DI9lHkKY.js +1 -0
- package/client/dist/assets/browser-CXUcnTMI.js +1 -0
- package/client/dist/assets/button-BUIIBQPT.js +1 -0
- package/client/dist/assets/chat-BGD7MXAy.js +1 -0
- package/client/dist/assets/chevron-right-CViMxucY.js +1 -0
- package/client/dist/assets/chunk-KS7C4IRE-Cx5sqopX.js +3 -0
- package/client/dist/assets/circle-x-CMYsN4ZH.js +1 -0
- package/client/dist/assets/code-BDXEM4ml.js +1 -0
- package/client/dist/assets/commands-DyUZQ1FI.js +1 -0
- package/client/dist/assets/common-6MLbD-jM.js +1 -0
- package/client/dist/assets/common-BKGEu4rm.js +1 -0
- package/client/dist/assets/common-BNbnv8cE2.js +1 -0
- package/client/dist/assets/common-BqGWtDbt.js +1 -0
- package/client/dist/assets/common-DBtTzeYm2.js +1 -0
- package/client/dist/assets/common-DEW3Nr8n.js +1 -0
- package/client/dist/assets/common-DHsv9N5d.js +1 -0
- package/client/dist/assets/common-mkrEcW-Y.js +1 -0
- package/client/dist/assets/createLucideIcon-Bjbbp_KS.js +1 -0
- package/client/dist/assets/{css.worker-Wv5dxAWO.js → css.worker-yKcq13f2.js} +13 -13
- package/client/dist/assets/{cssMode-DBHbkBvI.js → cssMode-BM4z9OX0.js} +1 -1
- package/client/dist/assets/dashboard-BYzxom0L.js +1 -0
- package/client/dist/assets/dashboard-BmDZmHyY.js +1 -0
- package/client/dist/assets/dashboard-CnNtJBQ5.js +1 -0
- package/client/dist/assets/dashboard-D4Uj-XWc2.js +1 -0
- package/client/dist/assets/dashboard-D57uRaGw2.js +1 -0
- package/client/dist/assets/dashboard-DAr6F9et.js +1 -0
- package/client/dist/assets/dashboard-vAcsn0L3.js +1 -0
- package/client/dist/assets/dashboard-vrjZvxWy.js +1 -0
- package/client/dist/assets/dialog-CzIekCw0.js +45 -0
- package/client/dist/assets/dist-Cez5CRkX.js +1 -0
- package/client/dist/assets/dist-bVqfYmby.js +1 -0
- package/client/dist/assets/{dist-js-CgpP6tKI.js → dist-js-BCUhGUXS.js} +1 -1
- package/client/dist/assets/{dist-js-DHiN-A_E.js → dist-js-DcoXTnEI.js} +1 -1
- package/client/dist/assets/download-CFHyyHcw.js +1 -0
- package/client/dist/assets/editor.api2-4ndOupAA.js +872 -0
- package/client/dist/assets/{editor.main-C9J2ikJK.js → editor.main-DxrmGfoq.js} +2 -2
- package/client/dist/assets/editor.worker-tytyn86m.js +26 -0
- package/client/dist/assets/explore-DgBACn39.js +1 -0
- package/client/dist/assets/external-link-BcU5EWZp.js +1 -0
- package/client/dist/assets/file-text-CFT-xXKN.js +1 -0
- package/client/dist/assets/formatDistanceToNow-DP3Ab6fX.js +1 -0
- package/client/dist/assets/{freemarker2-J5iIIIK-.js → freemarker2-CELlTDJ2.js} +1 -1
- package/client/dist/assets/getTimezoneOffsetInMilliseconds-DdKKL8Fx.js +1 -0
- package/client/dist/assets/git-branch-BRM0F5GN.js +1 -0
- package/client/dist/assets/{handlebars-DSw1l_tw.js → handlebars-NEjHJ7o_.js} +1 -1
- package/client/dist/assets/{html-h2-wE1Lj.js → html-CA10zN5A.js} +1 -1
- package/client/dist/assets/{html.worker-CQP8QQsS.js → html.worker-DSJ9zmd7.js} +12 -12
- package/client/dist/assets/{htmlMode-Cc_ij7lW.js → htmlMode-89rPYiyq.js} +1 -1
- package/client/dist/assets/i18n-DREQCE2F.js +2 -0
- package/client/dist/assets/index-B784m8RT.js +76 -0
- package/client/dist/assets/index-CQBIemiz.css +2 -0
- package/client/dist/assets/integrations-mB-7zoyT.js +1 -0
- package/client/dist/assets/{javascript-C1q3xv6N.js → javascript-B1gDmwzS.js} +1 -1
- package/client/dist/assets/jira-CmKWERE0.js +1 -0
- package/client/dist/assets/jira-api-BgFIr8eD.js +1 -0
- package/client/dist/assets/job-time-BCL7wee9.js +1 -0
- package/client/dist/assets/jobs-B-sDHEay2.js +1 -0
- package/client/dist/assets/jobs-BCtGfgUA.js +1 -0
- package/client/dist/assets/jobs-BHR_EnDI.js +1 -0
- package/client/dist/assets/jobs-BMbZJjJJ.js +1 -0
- package/client/dist/assets/jobs-CVFD8rar.js +1 -0
- package/client/dist/assets/jobs-DoSaFzAa.js +1 -0
- package/client/dist/assets/jobs-DzSIR8V62.js +1 -0
- package/client/dist/assets/jobs-lk1_Dq1U.js +1 -0
- package/client/dist/assets/json.worker-Oa9UrkKE.js +58 -0
- package/client/dist/assets/{jsonMode-CeaCdEhr.js → jsonMode-xHLMfzhF.js} +1 -1
- package/client/dist/assets/jsx-runtime-zu2_FqZY.js +1 -0
- package/client/dist/assets/lib-C7Mhm-gT.js +7 -0
- package/client/dist/assets/lib-CGdyxIWg.js +29 -0
- package/client/dist/assets/{liquid-eFsVK0V-.js → liquid-BY6hCUXG.js} +1 -1
- package/client/dist/assets/loader-circle-DcygOQpC.js +1 -0
- package/client/dist/assets/loops-BzfXWEwO.js +1 -0
- package/client/dist/assets/{lspLanguageFeatures-DT3-bbhn.js → lspLanguageFeatures-ira2aEJh.js} +1 -1
- package/client/dist/assets/mcp-uDkXYu4L.js +1 -0
- package/client/dist/assets/{mdx-Fuwnh1cX.js → mdx-BNx0xr3N.js} +1 -1
- package/client/dist/assets/monaco.contribution-Bt92R3Vw.js +2 -0
- package/client/dist/assets/nav-myFaXRHD.js +1 -0
- package/client/dist/assets/pencil-C9RkrIPZ.js +1 -0
- package/client/dist/assets/play-DNlrawbS.js +1 -0
- package/client/dist/assets/plus-CsnjfkmX.js +1 -0
- package/client/dist/assets/preload-helper-Czpn1I53.js +1 -0
- package/client/dist/assets/{python-BgoEs6Cj.js → python-DLdbtmNw.js} +1 -1
- package/client/dist/assets/{razor-CM1sPMMq.js → razor-B9gdhAbR.js} +1 -1
- package/client/dist/assets/react-dom-DiWzBDP9.js +1 -0
- package/client/dist/assets/rolldown-runtime-CNC7AqOf.js +1 -0
- package/client/dist/assets/save-28sIlCdr.js +1 -0
- package/client/dist/assets/search-Cq_gE3Ik.js +1 -0
- package/client/dist/assets/settings-B0ypw9uw.js +1 -0
- package/client/dist/assets/setup-CmK87LuS.js +1 -0
- package/client/dist/assets/sparkles-DrY8hb0X.js +1 -0
- package/client/dist/assets/specs-DII0C8gw.js +1 -0
- package/client/dist/assets/spending-CtY7yYes.js +1 -0
- package/client/dist/assets/terminal-BFRZnMPP.js +1 -0
- package/client/dist/assets/tickets-B8BuAaj5.js +1 -0
- package/client/dist/assets/tickets-B_yh4qQk.js +1 -0
- package/client/dist/assets/tickets-Bs37scwY2.js +1 -0
- package/client/dist/assets/tickets-CFk2n2Or.js +1 -0
- package/client/dist/assets/tickets-DQp7JS2R2.js +1 -0
- package/client/dist/assets/tickets-D_yDquEw.js +1 -0
- package/client/dist/assets/tickets-DpmdE8tv2.js +1 -0
- package/client/dist/assets/tickets-pAUJkDTu.js +1 -0
- package/client/dist/assets/trash-2-BOU3WdZZ.js +1 -0
- package/client/dist/assets/triangle-alert-H9T4jAmh.js +1 -0
- package/client/dist/assets/{ts.worker-METxwbDZ.js → ts.worker-BtjBFNHX.js} +48 -33
- package/client/dist/assets/{tsMode-BmT8WogI.js → tsMode-DEjSThU9.js} +1 -1
- package/client/dist/assets/{typescript-CQrQPsoW.js → typescript-CRRnD2Ts.js} +1 -1
- package/client/dist/assets/upload-DYMjAQ6M.js +1 -0
- package/client/dist/assets/useBrowserCaptureSession-BFBdW59q.js +1 -0
- package/client/dist/assets/useDesktop-uWVZ8eia.js +1 -0
- package/client/dist/assets/useSharedWebSocket-DaPh7QBL.js +1 -0
- package/client/dist/assets/utils-BC4DHlz2.js +1 -0
- package/client/dist/assets/value-s-gzBeyF.js +1 -0
- package/client/dist/assets/{workers-U0UXyLUf.js → workers-uOo7WLaa.js} +1 -1
- package/client/dist/assets/x-CBMI9ejn.js +1 -0
- package/client/dist/assets/{xml-WRxJs8_I.js → xml-EDREH2X7.js} +1 -1
- package/client/dist/assets/{yaml-CjpSTjJU.js → yaml-BjaDVX1E.js} +1 -1
- package/client/dist/assets/zap-CHo3aCD1.js +1 -0
- package/client/dist/index.html +73 -32
- package/docs/guide/en/integrations/5-mcp-server.md +2 -2
- package/docs/internals/safe-pr-review-flow.md +382 -141
- package/docs/mcp.md +15 -5
- package/package.json +11 -7
- package/server/dist/active-pr-continuation.js +250 -50
- package/server/dist/agent-chat-manager.js +387 -191
- package/server/dist/agent-cwd-manager.js +52 -8
- package/server/dist/agent-generator.js +90 -48
- package/server/dist/agent-mcp-config.js +69 -36
- package/server/dist/agent-operator-prompt.js +3 -2
- package/server/dist/agent-refine-manager.js +47 -6
- package/server/dist/agent-store.js +19 -4
- package/server/dist/agent-tier.js +13 -11
- package/server/dist/artifact-registry.js +33 -2
- package/server/dist/auth.js +5 -4
- package/server/dist/browser-capture-manager.js +92 -29
- package/server/dist/chat-manager.js +302 -46
- package/server/dist/contract-refine-runner.js +19 -6
- package/server/dist/db.js +686 -8
- package/server/dist/desktop-router.js +1 -2
- package/server/dist/headroom-manager.js +1310 -121
- package/server/dist/headroom-routing.js +120 -2
- package/server/dist/index.js +48 -13
- package/server/dist/interactive-job-session.js +237 -82
- package/server/dist/jira/jira-adf.js +10 -0
- package/server/dist/jira/jira-db.js +15 -3
- package/server/dist/jira/jira-sync-manager.js +182 -13
- package/server/dist/job-listing.js +140 -0
- package/server/dist/job-spawn-idempotency.js +67 -0
- package/server/dist/loop-run-manager.js +508 -98
- package/server/dist/loop-runs-store.js +266 -13
- package/server/dist/mcp/agent-capability.js +71 -0
- package/server/dist/mcp/guide.js +5 -2
- package/server/dist/mcp/mcp-server.js +5 -10
- package/server/dist/mcp/mcp-token.js +5 -5
- package/server/dist/mcp/tools/jobs.js +20 -13
- package/server/dist/mcp/tools/types.js +20 -42
- package/server/dist/mobile/mobile-router.js +1 -1
- package/server/dist/pr-lifecycle.js +169 -0
- package/server/dist/pr-publisher.js +94 -27
- package/server/dist/process-admission.js +82 -0
- package/server/dist/project-git.js +62 -2
- package/server/dist/project-registry.js +572 -174
- package/server/dist/project-router-git.js +13 -2
- package/server/dist/project-router-jobs.js +111 -55
- package/server/dist/project-router-tickets.js +32 -2
- package/server/dist/providers/claude-adapter.js +21 -13
- package/server/dist/queue-manager.js +2332 -623
- package/server/dist/rail-isolated-launch.js +1679 -296
- package/server/dist/rail-isolation.js +4 -2
- package/server/dist/rail-pr-decision.js +1665 -307
- package/server/dist/rail-pr-delivery.js +2 -1
- package/server/dist/rail-pr-recovery-git.js +235 -0
- package/server/dist/rail-pr-store.js +429 -19
- package/server/dist/rail-pr-ticket-effects.js +328 -0
- package/server/dist/rail-worktree-release.js +305 -3
- package/server/dist/rails-router.js +238 -120
- package/server/dist/rails-store.js +106 -3
- package/server/dist/ticket-store.js +23 -1
- package/server/dist/transient-children.js +13 -0
- package/server/dist/util/cli-prompt.js +42 -8
- package/server/dist/util/secure-token-file.js +84 -0
- package/server/dist/worktree-manager.js +126 -21
- package/server/dist/worktree-overlay.js +166 -4
- package/client/dist/assets/ActivityFeedPage-D8RKRRoM.js +0 -1
- package/client/dist/assets/AgentBrowserCapture-BUHPHNSN.js +0 -1
- package/client/dist/assets/AgentModeCodePane-GZc8bNGT.js +0 -2
- package/client/dist/assets/AgentModeJobsPane-DWtQqj3k.js +0 -1
- package/client/dist/assets/AgentsPage-CKPtHkRP.js +0 -86
- package/client/dist/assets/AnalyticsPage-CZW8c77k.js +0 -1
- package/client/dist/assets/BarChart-DugEoe2q.js +0 -33
- package/client/dist/assets/CodePage-CQ-uKETG.js +0 -2
- package/client/dist/assets/DesktopAnalyticsPage-Bgo4SyCH.js +0 -1
- package/client/dist/assets/DocsDialog-DxpWw_La.js +0 -11
- package/client/dist/assets/DocsPage-CmcOkK19.js +0 -11
- package/client/dist/assets/ExportDropdown-DvTS2wc7.js +0 -1
- package/client/dist/assets/IntegrationsPage-B72WxJ3Z.js +0 -1
- package/client/dist/assets/InteractiveJobComposer-B5gh4Qoy.js +0 -19
- package/client/dist/assets/JobDetailModal-D-BeqsJ6.js +0 -1
- package/client/dist/assets/JobDetailPage-DwdozwLO.js +0 -1
- package/client/dist/assets/JobsPage-BDkinklt.js +0 -1
- package/client/dist/assets/LoopBuilderPage-CclJ3VZA.js +0 -7
- package/client/dist/assets/LoopPreviewModal-Dw4UgoLu.js +0 -1
- package/client/dist/assets/LoopsPage-D7ac4M24.js +0 -1
- package/client/dist/assets/PluginsPage-wdC-qa40.js +0 -2
- package/client/dist/assets/ProjectSettingsDialog-BlTlRtGI.js +0 -1
- package/client/dist/assets/TemplatePreviewModal-CeMx2Red.js +0 -1
- package/client/dist/assets/activity-Dbl71S-E.js +0 -1
- package/client/dist/assets/addon-image-CwoZj17F.js +0 -1
- package/client/dist/assets/addon-ligatures-CWDrED80.js +0 -2
- package/client/dist/assets/addspec-DrXqP8ip.js +0 -1
- package/client/dist/assets/agent-B8BXmlUQ2.js +0 -1
- package/client/dist/assets/agent-BEXYxDbs.js +0 -1
- package/client/dist/assets/agent-BYc3-6Ln2.js +0 -1
- package/client/dist/assets/agent-BbJorPdT.js +0 -1
- package/client/dist/assets/agent-CewFImgL.js +0 -1
- package/client/dist/assets/agent-DfhYoUmp.js +0 -1
- package/client/dist/assets/agent-TK_rrK4d.js +0 -1
- package/client/dist/assets/agent-bHjA9R_j2.js +0 -1
- package/client/dist/assets/agents-CGDn_3kB.js +0 -1
- package/client/dist/assets/agentstudio-Dxe_94PK.js +0 -1
- package/client/dist/assets/aiedit-DrfHQnlz.js +0 -1
- package/client/dist/assets/analytics-CxDYcBl9.js +0 -1
- package/client/dist/assets/attachments-DvxQbBTC.js +0 -1
- package/client/dist/assets/brain-C92rjjYP.js +0 -1
- package/client/dist/assets/browser-DM8G151q.js +0 -1
- package/client/dist/assets/chat-0dg5hOo_.js +0 -1
- package/client/dist/assets/chunk-BNv3lrIs.js +0 -1
- package/client/dist/assets/code-B62fClk-.js +0 -1
- package/client/dist/assets/commands-DCJ-R9E4.js +0 -1
- package/client/dist/assets/common-BM3LFLCE2.js +0 -1
- package/client/dist/assets/common-Bwafujnc2.js +0 -1
- package/client/dist/assets/common-C-vU-j-I.js +0 -1
- package/client/dist/assets/common-C5HKSbbz.js +0 -1
- package/client/dist/assets/common-DXrmj6WD.js +0 -1
- package/client/dist/assets/common-DhWTkocg.js +0 -1
- package/client/dist/assets/common-DiPTT7V_2.js +0 -1
- package/client/dist/assets/common-DmqBPwZG.js +0 -1
- package/client/dist/assets/dashboard-B5ang-ZS.js +0 -1
- package/client/dist/assets/dashboard-CHHcOWVL2.js +0 -1
- package/client/dist/assets/dashboard-DBD4wPGY2.js +0 -1
- package/client/dist/assets/dashboard-DBuLfWo9.js +0 -1
- package/client/dist/assets/dashboard-DSnztwWH.js +0 -1
- package/client/dist/assets/dashboard-D_aP_InU.js +0 -1
- package/client/dist/assets/dashboard-DmBcdl1B.js +0 -1
- package/client/dist/assets/dashboard-RIcUKY1Y2.js +0 -1
- package/client/dist/assets/editor.api2-C3B0tp2x.js +0 -872
- package/client/dist/assets/editor.worker-Bd9IXS8d.js +0 -26
- package/client/dist/assets/explore-_XyU5e7R.js +0 -1
- package/client/dist/assets/index-BVbgKXUu.css +0 -2
- package/client/dist/assets/index-DyY1QyIn.js +0 -158
- package/client/dist/assets/integrations-By80EBkf.js +0 -1
- package/client/dist/assets/jira-DeIjwCK3.js +0 -1
- package/client/dist/assets/jobs-1GV2-4zd2.js +0 -1
- package/client/dist/assets/jobs-26F9gGcE.js +0 -1
- package/client/dist/assets/jobs-BgQzB0Sx2.js +0 -1
- package/client/dist/assets/jobs-BqWui9_f.js +0 -1
- package/client/dist/assets/jobs-CE8qeIYj.js +0 -1
- package/client/dist/assets/jobs-DrYmsKy5.js +0 -1
- package/client/dist/assets/jobs-DzeuASRf.js +0 -1
- package/client/dist/assets/jobs-Wh7dn28q2.js +0 -1
- package/client/dist/assets/json.worker-DzV-CpCQ.js +0 -58
- package/client/dist/assets/lib-0PFDyMxJ.js +0 -7
- package/client/dist/assets/loops-CO6q75W8.js +0 -1
- package/client/dist/assets/mcp-HwBbQDk0.js +0 -1
- package/client/dist/assets/monaco.contribution-Desq7oq4.js +0 -2
- package/client/dist/assets/nav-BTg8s-cD.js +0 -1
- package/client/dist/assets/preload-helper-DSXbuxSR.js +0 -1
- package/client/dist/assets/settings-cJNynGIZ.js +0 -1
- package/client/dist/assets/setup-D2CmgAro.js +0 -1
- package/client/dist/assets/specs-PGIOzMtc.js +0 -1
- package/client/dist/assets/terminal-CFt56A5f.js +0 -1
- package/client/dist/assets/tickets-B7zT4IRf.js +0 -1
- package/client/dist/assets/tickets-BHv3ewvq.js +0 -1
- package/client/dist/assets/tickets-BoXom7l8.js +0 -1
- package/client/dist/assets/tickets-C3b8cHhd2.js +0 -1
- package/client/dist/assets/tickets-CFXnJsYF.js +0 -1
- package/client/dist/assets/tickets-CWYFvx1W2.js +0 -1
- package/client/dist/assets/tickets-DTHo9c3C.js +0 -1
- package/client/dist/assets/tickets-SuX_HkK4.js +0 -1
- package/client/dist/assets/upload-CmR4h9H1.js +0 -1
- package/client/dist/assets/value-JA3bf47v.js +0 -1
- /package/client/dist/assets/{abap-D0E4FfVW.js → abap-08VXUWAP.js} +0 -0
- /package/client/dist/assets/{activity--iN4Ad2R2.js → activity-B-rp4h_v.js} +0 -0
- /package/client/dist/assets/{activity-6hM_ZSg9.js → activity-C6kJpm9q2.js} +0 -0
- /package/client/dist/assets/{activity-CIOLxGvh.js → activity-CGx4kb_j.js} +0 -0
- /package/client/dist/assets/{activity-BZNfOdiS.js → activity-CnoX2bH7.js} +0 -0
- /package/client/dist/assets/{activity-BuVo5sPB.js → activity-DAyekdlt2.js} +0 -0
- /package/client/dist/assets/{activity-D2r2h3SE2.js → activity-DCxtpT7j.js} +0 -0
- /package/client/dist/assets/{activity-DtxrAUMo2.js → activity-JzwRaWPD.js} +0 -0
- /package/client/dist/assets/{addspec-BMtLZLW62.js → addspec-BXjvkh5q.js} +0 -0
- /package/client/dist/assets/{addspec-CRuvWn8d.js → addspec-C4bwrmpi.js} +0 -0
- /package/client/dist/assets/{addspec-D-JLDsUV.js → addspec-CArHXUDM.js} +0 -0
- /package/client/dist/assets/{addspec-mgPOt5q02.js → addspec-DTKJcXiR.js} +0 -0
- /package/client/dist/assets/{addspec-DfhDbg5c.js → addspec-DbNBbrha2.js} +0 -0
- /package/client/dist/assets/{addspec-CP0HRuxY.js → addspec-htHGZHOe2.js} +0 -0
- /package/client/dist/assets/{addspec-bsNDdqRm2.js → addspec-lr_LP6jk.js} +0 -0
- /package/client/dist/assets/{agents-78bTZGZh.js → agents-6ZOJXWVk2.js} +0 -0
- /package/client/dist/assets/{agents-DDtCJ5M02.js → agents-BZ0XQKjg.js} +0 -0
- /package/client/dist/assets/{agents-CWo-KyAB.js → agents-BqWklnHR.js} +0 -0
- /package/client/dist/assets/{agents-BUdEi3-N.js → agents-Bz-thHkB2.js} +0 -0
- /package/client/dist/assets/{agents-bvyRLczL.js → agents-CJclElx6.js} +0 -0
- /package/client/dist/assets/{agents-BpoUaoW92.js → agents-D_l9L0VA.js} +0 -0
- /package/client/dist/assets/{agents-BLhWCmDS2.js → agents-u_C0jPB5.js} +0 -0
- /package/client/dist/assets/{agentstudio-BMQxc_bz.js → agentstudio-BF19hbXj.js} +0 -0
- /package/client/dist/assets/{agentstudio-C_Jq8Tl4.js → agentstudio-BLGvxWBx2.js} +0 -0
- /package/client/dist/assets/{agentstudio-Dtq3dGYk.js → agentstudio-D9UKiWTj2.js} +0 -0
- /package/client/dist/assets/{agentstudio-CWgXG5W52.js → agentstudio-Drs37nIM.js} +0 -0
- /package/client/dist/assets/{agentstudio-sI27TpBu2.js → agentstudio-nEnKkcXM.js} +0 -0
- /package/client/dist/assets/{agentstudio-jKMTdT70.js → agentstudio-pyFcSBKy.js} +0 -0
- /package/client/dist/assets/{agentstudio-COZriimI2.js → agentstudio-zfTzQh3U.js} +0 -0
- /package/client/dist/assets/{aiedit-hknZlly82.js → aiedit-B0KUbpB6.js} +0 -0
- /package/client/dist/assets/{aiedit-eMN4eQPF.js → aiedit-BoG24nlg2.js} +0 -0
- /package/client/dist/assets/{aiedit-pc5JDUq1.js → aiedit-CjlSRQVP.js} +0 -0
- /package/client/dist/assets/{aiedit-B03pD_Na.js → aiedit-DCjA7jLJ.js} +0 -0
- /package/client/dist/assets/{aiedit-6CHdb_iv2.js → aiedit-DNXxq_Dr.js} +0 -0
- /package/client/dist/assets/{aiedit-igmw-ZoZ2.js → aiedit-DQ-0_pvE.js} +0 -0
- /package/client/dist/assets/{aiedit-BtRqRxML.js → aiedit-olnv3QSt2.js} +0 -0
- /package/client/dist/assets/{analytics-CCprAqk3.js → analytics-BC7mwR4s.js} +0 -0
- /package/client/dist/assets/{analytics-CR1TJqUi2.js → analytics-BiNg8edP.js} +0 -0
- /package/client/dist/assets/{analytics-Bj-SmKHa.js → analytics-C0s_T2GN.js} +0 -0
- /package/client/dist/assets/{analytics-C5dpiS0o.js → analytics-CdsAPAwZ2.js} +0 -0
- /package/client/dist/assets/{analytics-BWMUZ2Pq2.js → analytics-Cr1_q-lC.js} +0 -0
- /package/client/dist/assets/{analytics-DfNdXR0y2.js → analytics-IEsKZvpW2.js} +0 -0
- /package/client/dist/assets/{analytics-rmHuJv0V.js → analytics-SRPf84OT.js} +0 -0
- /package/client/dist/assets/{apex-D_X_8J4d.js → apex-BWPQTe0t.js} +0 -0
- /package/client/dist/assets/{atom-one-dark-BMDPFwRZ.js → atom-one-dark-qiGhVQxg.js} +0 -0
- /package/client/dist/assets/{attachments-BgBNSqQd.js → attachments-D0wXXt9T2.js} +0 -0
- /package/client/dist/assets/{attachments-C9GTTJsx2.js → attachments-DenIjuVI.js} +0 -0
- /package/client/dist/assets/{attachments-BjyMmrwE.js → attachments-DhO7LPfy.js} +0 -0
- /package/client/dist/assets/{attachments-DPCmkFZu2.js → attachments-DoH5w0x4.js} +0 -0
- /package/client/dist/assets/{attachments-DCZOL1RU.js → attachments-Q9yNtiEM.js} +0 -0
- /package/client/dist/assets/{attachments-rNn1ekRy2.js → attachments-V_WZAYXx2.js} +0 -0
- /package/client/dist/assets/{attachments-DL-bPy9E.js → attachments-eaeScpjM.js} +0 -0
- /package/client/dist/assets/{auth-DpZq5p1e.js → auth-D_5bQv5W.js} +0 -0
- /package/client/dist/assets/{azcli-PZLnZ3jH.js → azcli-Bc_sGQ0U.js} +0 -0
- /package/client/dist/assets/{bat-KlBOxpO4.js → bat-i0X4ZdIN.js} +0 -0
- /package/client/dist/assets/{bicep-CgG9oF3V.js → bicep-B5-_aFwp.js} +0 -0
- /package/client/dist/assets/{browser-BPkhILSJ.js → browser-C25DkQiO.js} +0 -0
- /package/client/dist/assets/{browser-BqLqJVVT.js → browser-CiJ7-L32.js} +0 -0
- /package/client/dist/assets/{browser-rWKj-RR_2.js → browser-CvgDySd9.js} +0 -0
- /package/client/dist/assets/{browser-Cvg-QHvd2.js → browser-CyR1Kp3m2.js} +0 -0
- /package/client/dist/assets/{browser-FRv8P02E.js → browser-DwZljcRh2.js} +0 -0
- /package/client/dist/assets/{browser-Cc0iDqUi.js → browser-DxP-alBK.js} +0 -0
- /package/client/dist/assets/{browser-BijVYG0Y2.js → browser-rRCwi7Y7.js} +0 -0
- /package/client/dist/assets/{cameligo-6R45j6Ph.js → cameligo-DMUM7wLl.js} +0 -0
- /package/client/dist/assets/{chat-Bom6bqK3.js → chat-2rIB8HhT.js} +0 -0
- /package/client/dist/assets/{chat-vylxqR0P2.js → chat-BR8oe53x2.js} +0 -0
- /package/client/dist/assets/{chat-Dnwg-NpQ.js → chat-Bua03tty.js} +0 -0
- /package/client/dist/assets/{chat-BgL3zv6x2.js → chat-CZpAQan1.js} +0 -0
- /package/client/dist/assets/{chat-DsbwJhus.js → chat-CdY5SGvS.js} +0 -0
- /package/client/dist/assets/{chat-Bh3NdgJs.js → chat-DZyu3ImY2.js} +0 -0
- /package/client/dist/assets/{chat-DdwZjT8K2.js → chat-D_I7nU5K.js} +0 -0
- /package/client/dist/assets/{clojure-CLAAMO7J.js → clojure-Cm7r79vr.js} +0 -0
- /package/client/dist/assets/{clsx-CNmW0Nip.js → clsx-CjueKrWZ.js} +0 -0
- /package/client/dist/assets/{code-UPVvmAKM2.js → code-76gS0IdL.js} +0 -0
- /package/client/dist/assets/{code-BRcDlze52.js → code-C1VwxlML.js} +0 -0
- /package/client/dist/assets/{code-CeQ0FZpC.js → code-CnMZyJpr.js} +0 -0
- /package/client/dist/assets/{code-DgeHz9CB.js → code-D20ef9Cf2.js} +0 -0
- /package/client/dist/assets/{code-DzC1rMk12.js → code-DdOXaWRY.js} +0 -0
- /package/client/dist/assets/{code-CwnBPPyA.js → code-Duohuf9l.js} +0 -0
- /package/client/dist/assets/{code-BdMy3Ffq.js → code-geHmknB92.js} +0 -0
- /package/client/dist/assets/{coffee-AruSygo-.js → coffee-Ba7i2nA0.js} +0 -0
- /package/client/dist/assets/{commands-DkU0qliq.js → commands-B9RZO4qS.js} +0 -0
- /package/client/dist/assets/{commands-u-4eEHCN.js → commands-BEwbAjtD2.js} +0 -0
- /package/client/dist/assets/{commands-JWMfGDmr.js → commands-Bbxu8kLU.js} +0 -0
- /package/client/dist/assets/{commands-C4Y3C-PF2.js → commands-CDU3qv68.js} +0 -0
- /package/client/dist/assets/{commands-xHDDGfcP2.js → commands-CzezgtQj.js} +0 -0
- /package/client/dist/assets/{commands-CSDs9q_2.js → commands-DTQBF_q52.js} +0 -0
- /package/client/dist/assets/{commands-RHOchN4n2.js → commands-hOtKuOXc.js} +0 -0
- /package/client/dist/assets/{cpp-DEE5r4Pw.js → cpp-C7h46wYY.js} +0 -0
- /package/client/dist/assets/{csharp-BVXJUvbK.js → csharp-BKxtCVv1.js} +0 -0
- /package/client/dist/assets/{csp-cXOF0JoV.js → csp-bTuwJoIa.js} +0 -0
- /package/client/dist/assets/{css-C_zQuAoy.js → css-DIMkf-bt.js} +0 -0
- /package/client/dist/assets/{cypher-t95m_Q-O.js → cypher-CVaqCwHa.js} +0 -0
- /package/client/dist/assets/{dart-B4r1Tg-e.js → dart-onAF5SnQ.js} +0 -0
- /package/client/dist/assets/{dockerfile-6mt7zHQw.js → dockerfile-DZFCIeNp.js} +0 -0
- /package/client/dist/assets/{ecl-DEY_Fz_Q.js → ecl-D05T4iGw.js} +0 -0
- /package/client/dist/assets/{elixir-R6-q1c5t.js → elixir-6RTg0lbw.js} +0 -0
- /package/client/dist/assets/{explore-B7fblXBb2.js → explore-BG99VGpL.js} +0 -0
- /package/client/dist/assets/{explore-CNBzrEPS.js → explore-C0TjprJW2.js} +0 -0
- /package/client/dist/assets/{explore-C0k8HrkN.js → explore-C2dgEo7q.js} +0 -0
- /package/client/dist/assets/{explore-BHtEpoNN2.js → explore-C8NDHbob.js} +0 -0
- /package/client/dist/assets/{explore-Dahc1lOx.js → explore-CWWgzQGR.js} +0 -0
- /package/client/dist/assets/{explore-D_mWBYCS2.js → explore-CcQXpdtS.js} +0 -0
- /package/client/dist/assets/{explore-UvW1jEMa.js → explore-DsXAgnmJ2.js} +0 -0
- /package/client/dist/assets/{flow9-CNQvHBOt.js → flow9-C5_-GSwl.js} +0 -0
- /package/client/dist/assets/{format-command-CuWuRvka.js → format-command-Dfa1o2d-.js} +0 -0
- /package/client/dist/assets/{fsharp-vPZkFXwv.js → fsharp-C8Ef5oNN.js} +0 -0
- /package/client/dist/assets/{go-KUzBMYJ_.js → go-C-y9NEjX.js} +0 -0
- /package/client/dist/assets/{graphql-C3W0rCsD.js → graphql-fmXr3nnJ.js} +0 -0
- /package/client/dist/assets/{hcl-BOOMFSNX.js → hcl-CpzslTdj.js} +0 -0
- /package/client/dist/assets/{ini-CFat1WJr.js → ini-sBoK_t0W.js} +0 -0
- /package/client/dist/assets/{integrations-TAcYNh0b.js → integrations-CH0zy1Mw2.js} +0 -0
- /package/client/dist/assets/{integrations-C1ThkTC52.js → integrations-CIAjhd7L.js} +0 -0
- /package/client/dist/assets/{integrations-2YcNyAl3.js → integrations-CZdwOe8A.js} +0 -0
- /package/client/dist/assets/{integrations-BXCvXUlG2.js → integrations-Ct7omMld.js} +0 -0
- /package/client/dist/assets/{integrations-Crk2rFhL2.js → integrations-D6MSxy3-.js} +0 -0
- /package/client/dist/assets/{integrations-Dn4JiGtW.js → integrations-DbZa-Zyc.js} +0 -0
- /package/client/dist/assets/{integrations-D9YrJ_Ep.js → integrations-b8pH-vfl2.js} +0 -0
- /package/client/dist/assets/{java-Dee-CNAM.js → java-BEtHBSE6.js} +0 -0
- /package/client/dist/assets/{jira-D5efgwp_.js → jira-BySfUuQZ.js} +0 -0
- /package/client/dist/assets/{jira-bDs7Im2C.js → jira-Byw2C0F8.js} +0 -0
- /package/client/dist/assets/{jira-BHAKtc4B.js → jira-CNeYi06w2.js} +0 -0
- /package/client/dist/assets/{jira-Be369RIR2.js → jira-D11gPhxz.js} +0 -0
- /package/client/dist/assets/{jira-CPpgA-5z2.js → jira-D38Gj7AT.js} +0 -0
- /package/client/dist/assets/{jira-uNH1gETL2.js → jira-gAvOyije.js} +0 -0
- /package/client/dist/assets/{jira-DS7ownDy.js → jira-pRaL7JQo2.js} +0 -0
- /package/client/dist/assets/{julia-CGNlLYuU.js → julia-Bri6UV-V.js} +0 -0
- /package/client/dist/assets/{kotlin-CY7lhknJ.js → kotlin-BOotOW0E.js} +0 -0
- /package/client/dist/assets/{less-D0KN7hfJ.js → less-B9JPFI3C.js} +0 -0
- /package/client/dist/assets/{lexon-CuRJufPs.js → lexon-CfSJPG6W.js} +0 -0
- /package/client/dist/assets/{loops-LIgO_-eM.js → loops-CPpgMapU.js} +0 -0
- /package/client/dist/assets/{loops-DJNhp17p2.js → loops-CWWbKuVL.js} +0 -0
- /package/client/dist/assets/{loops-D6D3XHjj.js → loops-Crc9It8o2.js} +0 -0
- /package/client/dist/assets/{loops-CvOWsi5r.js → loops-DH2hZcbK2.js} +0 -0
- /package/client/dist/assets/{loops-vhJdbcz92.js → loops-DS5TmvIU2.js} +0 -0
- /package/client/dist/assets/{loops-K5_HXfJa.js → loops-P2f0cN8-.js} +0 -0
- /package/client/dist/assets/{loops-BvqQ-bHR2.js → loops-fJV-9hH7.js} +0 -0
- /package/client/dist/assets/{lua-DHvH62Zf.js → lua-CsQS60Ue.js} +0 -0
- /package/client/dist/assets/{m3-tlthQ8Fo.js → m3-D-oSqn_W.js} +0 -0
- /package/client/dist/assets/{markdown-Dbx1LgUZ.js → markdown-Cimd5fb3.js} +0 -0
- /package/client/dist/assets/{mcp-Dcl-XxkR.js → mcp-Czd_iyp02.js} +0 -0
- /package/client/dist/assets/{mcp-XJNRfxVp2.js → mcp-D2pc5GGx.js} +0 -0
- /package/client/dist/assets/{mcp-sRmWE8WJ.js → mcp-D4ZjtIx32.js} +0 -0
- /package/client/dist/assets/{mcp-DtbxuH3V2.js → mcp-DIfBUv2D2.js} +0 -0
- /package/client/dist/assets/{mcp-H-gnQUdN.js → mcp-DsTwmjST.js} +0 -0
- /package/client/dist/assets/{mcp-N1nzp8oL.js → mcp-SMkn8boG.js} +0 -0
- /package/client/dist/assets/{mcp-CjVKXAhD2.js → mcp-fSfiVYAc.js} +0 -0
- /package/client/dist/assets/{mips-D_O3IUz_.js → mips-CIPQ_RoX.js} +0 -0
- /package/client/dist/assets/{msdax-C_ZmCnRt.js → msdax-DauUninz.js} +0 -0
- /package/client/dist/assets/{mysql-C-dCEYSX.js → mysql-SOo6toE5.js} +0 -0
- /package/client/dist/assets/{nav-BElxljIF2.js → nav-BRJBxaGt2.js} +0 -0
- /package/client/dist/assets/{nav-COu2E_-L.js → nav-CAGKv3_F.js} +0 -0
- /package/client/dist/assets/{nav-BXO7PJJG2.js → nav-CNskRJKQ2.js} +0 -0
- /package/client/dist/assets/{nav-CW9pxWfC2.js → nav-DY93irBL.js} +0 -0
- /package/client/dist/assets/{nav-CXHUA4uf.js → nav-DhjvYgqt.js} +0 -0
- /package/client/dist/assets/{nav-DdHF5VWJ.js → nav-Gb-r4wop.js} +0 -0
- /package/client/dist/assets/{nav-C8kOuGh8.js → nav-TvumAFD22.js} +0 -0
- /package/client/dist/assets/{objective-c-DZY9Aqxd.js → objective-c-FvmIjYaQ.js} +0 -0
- /package/client/dist/assets/{pascal-BVHLXoor.js → pascal-DrH0SRf2.js} +0 -0
- /package/client/dist/assets/{pascaligo-XdG_6u3k.js → pascaligo-D-ptJ9y-.js} +0 -0
- /package/client/dist/assets/{perl-b9QV0BcD.js → perl-oz_6vUea.js} +0 -0
- /package/client/dist/assets/{pgsql-Du5FDOgT.js → pgsql-DTj74zXo.js} +0 -0
- /package/client/dist/assets/{php-WJD0z2Z_.js → php-nr791fC2.js} +0 -0
- /package/client/dist/assets/{pla-CbciTf2w.js → pla-CopQ2nXW.js} +0 -0
- /package/client/dist/assets/{postiats-C1QxmvVq.js → postiats-43DmfD33.js} +0 -0
- /package/client/dist/assets/{powerquery-BEYDhPLZ.js → powerquery-D3hlyOfw.js} +0 -0
- /package/client/dist/assets/{powershell-CfaYw4XL.js → powershell-DmHpPYUd.js} +0 -0
- /package/client/dist/assets/{protobuf-pwZEDOYa.js → protobuf-C531GsRP.js} +0 -0
- /package/client/dist/assets/{pug-5ftqSPVe.js → pug-Z5eAx3Zn.js} +0 -0
- /package/client/dist/assets/{qsharp-uI6qZMq4.js → qsharp-DkqhCAOL.js} +0 -0
- /package/client/dist/assets/{r-BK54P1EG.js → r-BwWrilGY.js} +0 -0
- /package/client/dist/assets/{redis-DI0yd7kN.js → redis-ClamHrr6.js} +0 -0
- /package/client/dist/assets/{redshift-Dov26eyI.js → redshift-DT7zqm-g.js} +0 -0
- /package/client/dist/assets/{restructuredtext-QqJ_1dC-.js → restructuredtext-BYgofb2h.js} +0 -0
- /package/client/dist/assets/{ruby-5WjveeVb.js → ruby-DezsRK8O.js} +0 -0
- /package/client/dist/assets/{rust-BzVSfqFH.js → rust-DdL9SqIa.js} +0 -0
- /package/client/dist/assets/{sb-DMIUfT-3.js → sb-CcwsVR0C.js} +0 -0
- /package/client/dist/assets/{scala-CSKA7lqt.js → scala-DHpiXF5c.js} +0 -0
- /package/client/dist/assets/{scheme-CojOP2Qc.js → scheme-BeGwcela.js} +0 -0
- /package/client/dist/assets/{scss-DoBZGJG6.js → scss-gp-XZpBa.js} +0 -0
- /package/client/dist/assets/{settings-1w1O5Og82.js → settings-B9ilOSYO.js} +0 -0
- /package/client/dist/assets/{settings-Jc46vUhd.js → settings-BqlWHRHA.js} +0 -0
- /package/client/dist/assets/{settings-BSihkr0e.js → settings-D8dlqt4d.js} +0 -0
- /package/client/dist/assets/{settings-BiDOB3hV2.js → settings-DAZqjX2a2.js} +0 -0
- /package/client/dist/assets/{settings-DNL68KTE.js → settings-DRh39v1S2.js} +0 -0
- /package/client/dist/assets/{settings-BoubJhDP2.js → settings-Mj1OJbfd2.js} +0 -0
- /package/client/dist/assets/{settings-CB-EZ_W8.js → settings-lRReaSYm.js} +0 -0
- /package/client/dist/assets/{setup-D84y3wx-.js → setup-CGZjy2IF2.js} +0 -0
- /package/client/dist/assets/{setup-BuQNKztt2.js → setup-CXa0Sx16.js} +0 -0
- /package/client/dist/assets/{setup-BwMovM9z2.js → setup-D2ktKKMF2.js} +0 -0
- /package/client/dist/assets/{setup-DU0ULX8q2.js → setup-DG2H7ha5.js} +0 -0
- /package/client/dist/assets/{setup-BXpw07r-.js → setup-DK5bHDUq2.js} +0 -0
- /package/client/dist/assets/{setup-7J8TjG4O.js → setup-DrWlIQTZ.js} +0 -0
- /package/client/dist/assets/{setup-BiduSX9d.js → setup-rzHUVgAu.js} +0 -0
- /package/client/dist/assets/{shell-YOaE4udl.js → shell-CC2rA5mh.js} +0 -0
- /package/client/dist/assets/{solidity-l3jSyVLu.js → solidity-BEEn4gHE.js} +0 -0
- /package/client/dist/assets/{sophia-BhSGTaQJ.js → sophia-CRfGWb83.js} +0 -0
- /package/client/dist/assets/{sparql-qhk6QD9w.js → sparql-D_Lu-MrJ.js} +0 -0
- /package/client/dist/assets/{specs-CWtKcVDC.js → specs-BcyxaCwf2.js} +0 -0
- /package/client/dist/assets/{specs-DTplt2XM.js → specs-C1q9geAi.js} +0 -0
- /package/client/dist/assets/{specs-PozUNhqb.js → specs-CLZKysq-2.js} +0 -0
- /package/client/dist/assets/{specs-C9Sd7BhH2.js → specs-DZMS9o54.js} +0 -0
- /package/client/dist/assets/{specs-D2clrt2c2.js → specs-Dm6zUI-R.js} +0 -0
- /package/client/dist/assets/{specs-CBDvEYKv.js → specs-V3TvhKLX.js} +0 -0
- /package/client/dist/assets/{specs-CIPr9reA2.js → specs-dV3Mq5Mu2.js} +0 -0
- /package/client/dist/assets/{sql-DoO3y21-.js → sql-NEE52Syq.js} +0 -0
- /package/client/dist/assets/{st-ChZAY8oG.js → st-DbInun42.js} +0 -0
- /package/client/dist/assets/{swift-D290Tr7_.js → swift-Bxkupp3x.js} +0 -0
- /package/client/dist/assets/{systemverilog-DsxzgJ-o.js → systemverilog-Bz4Y3fRF.js} +0 -0
- /package/client/dist/assets/{tcl-BKDUHAAR.js → tcl-DISqw1ZD.js} +0 -0
- /package/client/dist/assets/{terminal-De2Brd23.js → terminal-BZiIu3rf.js} +0 -0
- /package/client/dist/assets/{terminal-cqfd3EDV.js → terminal-C2NAd7BW2.js} +0 -0
- /package/client/dist/assets/{terminal-WSAvHXoU.js → terminal-IahE4LW92.js} +0 -0
- /package/client/dist/assets/{terminal-Z7KsDM_n.js → terminal-QpXZU2Bn2.js} +0 -0
- /package/client/dist/assets/{terminal-xGbCZJHg.js → terminal-ScjyXNxQ.js} +0 -0
- /package/client/dist/assets/{terminal-BRm03iFA2.js → terminal-d7GadXbN.js} +0 -0
- /package/client/dist/assets/{terminal-DxQWCqSD2.js → terminal-tITa81iz.js} +0 -0
- /package/client/dist/assets/{twig-UpZQaM8G.js → twig-De2hgUGE.js} +0 -0
- /package/client/dist/assets/{typespec-DzaKvN8i.js → typespec-B8J7ngcE.js} +0 -0
- /package/client/dist/assets/{vb-CZpbb7tk.js → vb-DV3o63ZY.js} +0 -0
- /package/client/dist/assets/{wgsl-CNt3OIvl.js → wgsl-DpFanUEy.js} +0 -0
|
@@ -38,7 +38,7 @@ exports.isPrDecisionAction = isPrDecisionAction;
|
|
|
38
38
|
exports.executePrDecision = executePrDecision;
|
|
39
39
|
/**
|
|
40
40
|
* Execute a user's ask-first PR decision (safe-pr-review-flow) against its
|
|
41
|
-
* authoritative `rail_pr_deliveries` row: the
|
|
41
|
+
* authoritative `rail_pr_deliveries` row: the actions both decision
|
|
42
42
|
* surfaces (the dashboard rail row and the launching agent-chat card) POST to
|
|
43
43
|
* `/rails/pr-decision`.
|
|
44
44
|
*
|
|
@@ -57,14 +57,15 @@ exports.executePrDecision = executePrDecision;
|
|
|
57
57
|
* conflict). Without it, a repo with no GitHub remote wedges
|
|
58
58
|
* forever in retry(local-only)/discard — no way to ACCEPT work.
|
|
59
59
|
*
|
|
60
|
-
* Every mutation rides
|
|
61
|
-
*
|
|
60
|
+
* Every mutation rides a lease-owned compare-and-set (a raced concurrent
|
|
61
|
+
* decision loses with a 409 before effects) and re-broadcasts the durable
|
|
62
62
|
* `rail.pr_state` snapshot so both surfaces converge; agent-chat-originated
|
|
63
63
|
* rows also update their inline decision card in place. Deps are injected
|
|
64
64
|
* (db/git/exec/broadcast/jira/agent-chat) so the whole matrix is unit-testable
|
|
65
65
|
* without git/gh/net — the route in rails-router validates and delegates here.
|
|
66
66
|
*/
|
|
67
67
|
const path = __importStar(require("path"));
|
|
68
|
+
const fs = __importStar(require("fs"));
|
|
68
69
|
const artifact_registry_1 = require("./artifact-registry");
|
|
69
70
|
const worktree_manager_1 = require("./worktree-manager");
|
|
70
71
|
const pr_publisher_1 = require("./pr-publisher");
|
|
@@ -78,10 +79,26 @@ const rail_worktrees_store_1 = require("./rail-worktrees-store");
|
|
|
78
79
|
const ticket_store_1 = require("./ticket-store");
|
|
79
80
|
const workspace_resolution_1 = require("./workspace-resolution");
|
|
80
81
|
const agent_chat_registry_1 = require("./agent-chat-registry");
|
|
81
|
-
|
|
82
|
+
const ids_1 = require("./ids");
|
|
83
|
+
const repo_lock_1 = require("./repo-lock");
|
|
84
|
+
const rail_pr_ticket_effects_1 = require("./rail-pr-ticket-effects");
|
|
85
|
+
const pr_lifecycle_1 = require("./pr-lifecycle");
|
|
86
|
+
const rail_pr_recovery_git_1 = require("./rail-pr-recovery-git");
|
|
87
|
+
exports.PR_DECISION_ACTIONS = ['create-pr', 'publish', 'discard', 'dismiss', 'poll-merge', 'reopen', 'merge-local', 'acknowledge-no-changes', 'recover-and-retry'];
|
|
88
|
+
function safetyArchiveRecorder(deps, row) {
|
|
89
|
+
return (archive) => {
|
|
90
|
+
if (!(0, rail_pr_store_1.appendPrDeliverySafetyArchive)(deps.db, row.id, archive)) {
|
|
91
|
+
throw new Error(`delivery ${row.id} disappeared while recording safety archive ${archive}`);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
82
95
|
function isPrDecisionAction(v) {
|
|
83
96
|
return typeof v === 'string' && exports.PR_DECISION_ACTIONS.includes(v);
|
|
84
97
|
}
|
|
98
|
+
// Action handlers keep using one finalization helper, but the operation lease
|
|
99
|
+
// must be absent from every emitted snapshot. Calls made while a lease is held
|
|
100
|
+
// are deferred until executePrDecision's finally releases that exact token.
|
|
101
|
+
const deferredFinalizations = new Set();
|
|
85
102
|
function staleDecision(current) {
|
|
86
103
|
return { status: 409, body: { error: 'stale_decision', current } };
|
|
87
104
|
}
|
|
@@ -101,21 +118,36 @@ function ghFailed(r) {
|
|
|
101
118
|
function actionAllowed(action, row) {
|
|
102
119
|
switch (action) {
|
|
103
120
|
case 'create-pr':
|
|
104
|
-
return row.decision === 'on_review' ||
|
|
121
|
+
return row.decision === 'on_review' ||
|
|
122
|
+
(row.decision === 'pr_failed' && (row.delivery_outcome === 'retryable_failure' || row.delivery_outcome === 'unknown')) ||
|
|
105
123
|
(row.decision === 'pr_draft' && row.pr_url === null);
|
|
106
124
|
case 'publish':
|
|
107
125
|
return row.decision === 'pr_draft' && row.pr_url !== null;
|
|
108
126
|
case 'discard':
|
|
109
127
|
return row.decision === 'on_review' || row.decision === 'pr_draft' ||
|
|
110
|
-
row.decision === 'pr_ready' || row.decision === '
|
|
128
|
+
row.decision === 'pr_ready' || row.decision === 'pr_closed' || row.decision === 'no_changes' ||
|
|
129
|
+
row.decision === 'implementation_failed' ||
|
|
111
130
|
row.decision === 'pr_failed';
|
|
131
|
+
case 'dismiss':
|
|
132
|
+
return row.is_continuation === 1 && row.decision !== 'building' &&
|
|
133
|
+
row.decision !== 'merged' && row.decision !== 'discarded' && row.decision !== 'superseded';
|
|
112
134
|
case 'poll-merge':
|
|
113
|
-
return (row.decision === 'pr_draft' || row.decision === 'pr_ready') && row.pr_url !== null;
|
|
135
|
+
return (row.decision === 'pr_draft' || row.decision === 'pr_ready' || row.decision === 'pr_closed') && row.pr_url !== null;
|
|
136
|
+
case 'reopen':
|
|
137
|
+
return row.decision === 'pr_closed' && row.pr_url !== null;
|
|
114
138
|
case 'merge-local':
|
|
115
139
|
// Remote-less acceptance ONLY: once a real PR exists (pr_url), GitHub is
|
|
116
140
|
// the merge authority — merging under an open PR would leave it dangling.
|
|
117
141
|
return row.pr_url === null &&
|
|
118
142
|
(row.decision === 'on_review' || row.decision === 'pr_failed' || row.decision === 'pr_draft');
|
|
143
|
+
case 'acknowledge-no-changes':
|
|
144
|
+
return row.decision === 'no_changes' && row.is_continuation !== 1;
|
|
145
|
+
case 'recover-and-retry':
|
|
146
|
+
return row.decision === 'pr_failed' && row.delivery_outcome === 'blocked' &&
|
|
147
|
+
(row.status_code === 'settlement_interrupted' || row.status_code === 'recovery_unavailable') &&
|
|
148
|
+
row.is_continuation === 1 &&
|
|
149
|
+
(row.implementation_outcome === 'succeeded' || row.implementation_outcome === 'partially_succeeded') &&
|
|
150
|
+
row.pr_url !== null && row.branch !== null;
|
|
119
151
|
}
|
|
120
152
|
}
|
|
121
153
|
async function executePrDecision(deps, input) {
|
|
@@ -128,12 +160,44 @@ async function executePrDecision(deps, input) {
|
|
|
128
160
|
return staleDecision(row.decision);
|
|
129
161
|
if (!actionAllowed(input.action, row))
|
|
130
162
|
return illegalAction(row.decision);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
163
|
+
// Claim before any git/GitHub/cleanup/ticket effect. The visible decision is
|
|
164
|
+
// unchanged while the winner works, but a second surface cannot start.
|
|
165
|
+
const operationToken = (0, ids_1.newId)();
|
|
166
|
+
if (!(0, rail_pr_store_1.claimPrDeliveryOperation)(deps.db, row.id, row.decision, input.action, operationToken)) {
|
|
167
|
+
const current = (0, rail_pr_store_1.getPrDelivery)(deps.db, row.id);
|
|
168
|
+
if (!current || current.decision !== input.expectedDecision) {
|
|
169
|
+
return staleDecision(current?.decision ?? row.decision);
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
status: 409,
|
|
173
|
+
body: { error: 'operation_in_progress', current: current.decision, operation: current.operation },
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const claimedRow = (0, rail_pr_store_1.getPrDelivery)(deps.db, row.id);
|
|
177
|
+
if (!claimedRow || claimedRow.operation_token !== operationToken) {
|
|
178
|
+
return { status: 409, body: { error: 'operation_in_progress', current: claimedRow?.decision ?? row.decision } };
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
switch (input.action) {
|
|
182
|
+
case 'create-pr': return await runCreatePr(deps, claimedRow);
|
|
183
|
+
case 'publish': return await runPublish(deps, claimedRow);
|
|
184
|
+
case 'discard': return await runDiscard(deps, claimedRow);
|
|
185
|
+
case 'dismiss': return await runDismiss(deps, claimedRow);
|
|
186
|
+
case 'poll-merge': return await runPollMerge(deps, claimedRow);
|
|
187
|
+
case 'reopen': return await runReopen(deps, claimedRow);
|
|
188
|
+
case 'merge-local': return await runMergeLocal(deps, claimedRow);
|
|
189
|
+
case 'acknowledge-no-changes': return await runAcknowledgeNoChanges(deps, claimedRow);
|
|
190
|
+
case 'recover-and-retry': return await runRecoverAndRetry(deps, claimedRow);
|
|
191
|
+
}
|
|
192
|
+
return illegalAction(row.decision);
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
try {
|
|
196
|
+
(0, rail_pr_store_1.releasePrDeliveryOperation)(deps.db, row.id, operationToken);
|
|
197
|
+
}
|
|
198
|
+
catch { /* durable state remains authoritative */ }
|
|
199
|
+
if (deferredFinalizations.delete(row.id))
|
|
200
|
+
finalizeTransition(deps, row.id);
|
|
137
201
|
}
|
|
138
202
|
}
|
|
139
203
|
/**
|
|
@@ -141,11 +205,30 @@ async function executePrDecision(deps, input) {
|
|
|
141
205
|
* between the pre-check and here — surface the same 409 with the fresh state.
|
|
142
206
|
*/
|
|
143
207
|
function casTransition(deps, row, next, patch = {}) {
|
|
144
|
-
if ((0, rail_pr_store_1.
|
|
208
|
+
if (row.operation_token && (0, rail_pr_store_1.transitionClaimedDecision)(deps.db, row.id, row.decision, next, row.operation_token, patch))
|
|
145
209
|
return null;
|
|
146
210
|
const current = (0, rail_pr_store_1.getPrDelivery)(deps.db, row.id);
|
|
147
211
|
return staleDecision(current?.decision ?? row.decision);
|
|
148
212
|
}
|
|
213
|
+
function casTransitionWithTicketEffect(deps, row, next, patch, effect) {
|
|
214
|
+
if (row.operation_token &&
|
|
215
|
+
(0, rail_pr_ticket_effects_1.transitionClaimedDecisionWithTicketEffect)(deps.db, row.id, row.decision, next, row.operation_token, patch, effect))
|
|
216
|
+
return null;
|
|
217
|
+
const current = (0, rail_pr_store_1.getPrDelivery)(deps.db, row.id);
|
|
218
|
+
return staleDecision(current?.decision ?? row.decision);
|
|
219
|
+
}
|
|
220
|
+
function applyTerminalTicketEffect(deps, row, terminalDecision, cleanupWarnings) {
|
|
221
|
+
const result = (0, rail_pr_ticket_effects_1.applyRailPrTicketEffect)(deps, row.id);
|
|
222
|
+
if (result.ok)
|
|
223
|
+
return;
|
|
224
|
+
cleanupWarnings.push(`ticket status update pending: ${result.error ?? 'unknown ticket-store error'}`);
|
|
225
|
+
if (!row.operation_token)
|
|
226
|
+
return;
|
|
227
|
+
(0, rail_pr_store_1.transitionClaimedDecision)(deps.db, row.id, terminalDecision, terminalDecision, row.operation_token, {
|
|
228
|
+
statusCode: 'cleanup_incomplete',
|
|
229
|
+
cleanupWarnings,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
149
232
|
/**
|
|
150
233
|
* Post-transition fan-out: re-broadcast the durable rail.pr_state snapshot
|
|
151
234
|
* (both surfaces converge on it) and, for agent-chat-originated launches,
|
|
@@ -156,6 +239,10 @@ function finalizeTransition(deps, id) {
|
|
|
156
239
|
if (!row)
|
|
157
240
|
return undefined;
|
|
158
241
|
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
242
|
+
if (row.operation_token) {
|
|
243
|
+
deferredFinalizations.add(id);
|
|
244
|
+
return snap;
|
|
245
|
+
}
|
|
159
246
|
deps.broadcast((0, rail_pr_store_1.toRailPrStateMessage)(deps.project.id, snap));
|
|
160
247
|
if (row.origin_conversation_id) {
|
|
161
248
|
const agent = (deps.agentChat ?? agent_chat_registry_1.getAgentChatManager)();
|
|
@@ -174,45 +261,893 @@ function batchWorktreeRoot(slug) {
|
|
|
174
261
|
// Mirrors rail-isolated-launch's worktreesRoot — derivable, never stored.
|
|
175
262
|
return path.join((0, artifact_registry_1.resolveHome)(), '.specrails', 'projects', slug, 'worktrees');
|
|
176
263
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
264
|
+
/** A legacy record's `succeeded` bit meant delivery eligibility. New records
|
|
265
|
+
* state that eligibility directly; blocked/no-change units are never swept as
|
|
266
|
+
* a side effect of delivering another unit in the same batch. */
|
|
267
|
+
function unitWasDelivered(unit) {
|
|
268
|
+
return unit.deliveryOutcome === undefined ? unit.succeeded : unit.deliveryOutcome === 'ready';
|
|
269
|
+
}
|
|
270
|
+
/** Branch deletion is ownership-based, never name-derived. Legacy rows without
|
|
271
|
+
* ownership evidence degrade to preservation. A multi-unit assembled head is
|
|
272
|
+
* owned when it is distinct from every recorded unit branch. */
|
|
273
|
+
function ownedDeliveryBranches(row, snap, cleanupWarnings) {
|
|
274
|
+
const unknownOwnership = row.is_continuation !== 1
|
|
275
|
+
? snap.branches.filter((unit) => unitWasDelivered(unit) && unit.branchOwnership === undefined)
|
|
276
|
+
: [];
|
|
277
|
+
if (cleanupWarnings && unknownOwnership.length > 0) {
|
|
278
|
+
cleanupWarnings.push(`branch cleanup preserved ${unknownOwnership.length} legacy ${unknownOwnership.length === 1 ? 'branch' : 'branches'} because ownership was not recorded`);
|
|
279
|
+
}
|
|
280
|
+
const owned = new Set(snap.branches
|
|
281
|
+
.filter((unit) => unit.branchOwnership === 'created' && unitWasDelivered(unit))
|
|
282
|
+
.map((unit) => unit.branch));
|
|
283
|
+
if (row.is_continuation !== 1 && snap.branches.length > 1 && row.branch &&
|
|
284
|
+
!snap.branches.some((unit) => unit.branch === row.branch))
|
|
285
|
+
owned.add(row.branch);
|
|
286
|
+
return owned;
|
|
287
|
+
}
|
|
288
|
+
function immutableHeadForOwnedBranch(row, snap, branch) {
|
|
289
|
+
if (branch === row.branch && row.delivery_sha && COMMIT_SHA_RE.test(row.delivery_sha)) {
|
|
290
|
+
return row.delivery_sha.toLowerCase();
|
|
291
|
+
}
|
|
292
|
+
const unitHeads = new Set(snap.branches
|
|
293
|
+
.filter((unit) => unitWasDelivered(unit) && unit.branch === branch && unit.finalSha && COMMIT_SHA_RE.test(unit.finalSha))
|
|
294
|
+
.map((unit) => unit.finalSha.toLowerCase()));
|
|
295
|
+
return unitHeads.size === 1 ? [...unitHeads][0] : null;
|
|
296
|
+
}
|
|
297
|
+
async function deleteOwnedBranchesIfUnchanged(deps, row, snap, cleanupWarnings, protectedBranches = new Set()) {
|
|
298
|
+
for (const branch of ownedDeliveryBranches(row, snap, cleanupWarnings)) {
|
|
299
|
+
if (!branch || branch === row.base_branch)
|
|
300
|
+
continue;
|
|
301
|
+
// A failed release leaves the linked worktree mounted for inspection. Do
|
|
302
|
+
// not even attempt to delete its checked-out branch: preserving the files
|
|
303
|
+
// while erasing their durable ref would make the recovery story depend on
|
|
304
|
+
// Git's incidental checked-out-branch rejection.
|
|
305
|
+
if (protectedBranches.has(branch)) {
|
|
306
|
+
cleanupWarnings.push(`branch ${branch}: retained with its worktree for inspection`);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
const expectedHead = immutableHeadForOwnedBranch(row, snap, branch);
|
|
311
|
+
if (!expectedHead) {
|
|
312
|
+
cleanupWarnings.push(`branch ${branch}: retained because no unambiguous immutable delivered HEAD was recorded`);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const observed = await deps.git.run(['rev-parse', '--verify', `refs/heads/${branch}`], deps.project.path);
|
|
316
|
+
const observedHead = observed.code === 0 ? observed.stdout.trim().toLowerCase() : '';
|
|
317
|
+
if (!COMMIT_SHA_RE.test(observedHead) || observedHead !== expectedHead) {
|
|
318
|
+
cleanupWarnings.push(`branch ${branch}: retained because its current tip no longer matches delivered HEAD ${expectedHead.slice(0, 12)}`);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const deleted = await deps.git.run(['branch', '-D', branch], deps.project.path);
|
|
322
|
+
if (deleted.code !== 0) {
|
|
323
|
+
cleanupWarnings.push(`branch ${branch}: ${(deleted.stderr.trim() || deleted.stdout.trim()).split('\n')[0] || `exit ${deleted.code}`}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
cleanupWarnings.push(`branch ${branch}: ${err instanceof Error ? err.message : String(err)}`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function releasableWorktreeIds(deps, snap) {
|
|
332
|
+
const preservedBranches = new Set(snap.branches.filter((unit) => !unitWasDelivered(unit)).map((unit) => unit.branch));
|
|
333
|
+
return snap.worktreeIds.filter((id) => {
|
|
334
|
+
const wt = (0, rail_worktrees_store_1.getRailWorktree)(deps.db, id);
|
|
335
|
+
return !wt || !preservedBranches.has(wt.branch);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function mergedEvidenceDetail(observation) {
|
|
339
|
+
return observation.includesExpectedSha === null
|
|
340
|
+
? 'GitHub did not return enough commit evidence to prove the previous PR included the verified implementation commit'
|
|
341
|
+
: 'the previous PR merged without the verified implementation commit';
|
|
342
|
+
}
|
|
343
|
+
async function rerouteFromStalePr(deps, row, detail, exactWasPushed) {
|
|
344
|
+
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
345
|
+
const cleanupWarnings = await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
346
|
+
db: deps.db, git: deps.git, repoDir: deps.project.path,
|
|
347
|
+
worktreeIds: releasableWorktreeIds(deps, snap),
|
|
348
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(snap.branches),
|
|
349
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(snap.branches),
|
|
350
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
351
|
+
});
|
|
352
|
+
const partial = row.implementation_outcome === 'partially_succeeded';
|
|
353
|
+
const preserved = row.delivery_sha ? 'the preserved exact commit' : 'the preserved recorded branch';
|
|
354
|
+
const conflict = casTransition(deps, row, 'on_review', {
|
|
355
|
+
prUrl: null,
|
|
356
|
+
prNumber: null,
|
|
357
|
+
prState: exactWasPushed ? 'pushed' : 'local-only',
|
|
358
|
+
deliveryOutcome: partial ? 'partial' : 'ready',
|
|
359
|
+
statusCode: cleanupWarnings.length > 0 ? 'cleanup_incomplete' : partial ? 'partial_success' : 'ready_for_review',
|
|
360
|
+
statusDetail: `${detail}; create a new draft PR from ${preserved}`,
|
|
361
|
+
cleanupWarnings,
|
|
362
|
+
// The replacement PR belongs to this generation. Per-unit branch ownership
|
|
363
|
+
// remains unchanged so a borrowed/pre-existing ref is still never deleted.
|
|
364
|
+
isContinuation: false,
|
|
365
|
+
});
|
|
366
|
+
if (conflict)
|
|
367
|
+
return conflict;
|
|
368
|
+
const after = finalizeTransition(deps, row.id);
|
|
369
|
+
return {
|
|
370
|
+
status: 200,
|
|
371
|
+
body: {
|
|
372
|
+
ok: true,
|
|
373
|
+
decision: 'on_review',
|
|
374
|
+
prUrl: null,
|
|
375
|
+
prState: after?.prState ?? (exactWasPushed ? 'pushed' : 'local-only'),
|
|
376
|
+
rerouted: true,
|
|
377
|
+
detail,
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
async function settleObservedExistingPr(deps, row, observation, pushed) {
|
|
382
|
+
const next = observation.state === 'MERGED' || observation.isDraft === false ? 'pr_ready' : 'pr_draft';
|
|
383
|
+
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
384
|
+
const cleanupWarnings = await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
385
|
+
db: deps.db, git: deps.git, repoDir: deps.project.path,
|
|
386
|
+
worktreeIds: releasableWorktreeIds(deps, snap),
|
|
387
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(snap.branches),
|
|
388
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(snap.branches),
|
|
389
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
390
|
+
});
|
|
391
|
+
const conflict = casTransition(deps, row, next, {
|
|
392
|
+
prState: 'pr-created',
|
|
393
|
+
deliveryOutcome: 'delivered',
|
|
394
|
+
statusCode: cleanupWarnings.length > 0 ? 'cleanup_incomplete' : next === 'pr_ready' ? 'pr_ready' : 'existing_pr_updated',
|
|
395
|
+
statusDetail: null,
|
|
396
|
+
cleanupWarnings,
|
|
397
|
+
});
|
|
398
|
+
if (conflict)
|
|
399
|
+
return conflict;
|
|
400
|
+
await releaseDeliveredRecoveryLineage(deps, row, row.delivery_sha);
|
|
401
|
+
const after = finalizeTransition(deps, row.id);
|
|
402
|
+
return {
|
|
403
|
+
status: 200,
|
|
404
|
+
body: {
|
|
405
|
+
ok: true,
|
|
406
|
+
decision: next,
|
|
407
|
+
prUrl: after?.prUrl ?? row.pr_url,
|
|
408
|
+
prState: 'pr-created',
|
|
409
|
+
deliveryVerified: true,
|
|
410
|
+
verifiedSha: row.delivery_sha,
|
|
411
|
+
remoteHeadSha: observation.headRefOid,
|
|
412
|
+
pushed,
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
async function settleObservedClosedPr(deps, row, observation) {
|
|
417
|
+
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
418
|
+
const cleanupWarnings = await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
419
|
+
db: deps.db, git: deps.git, repoDir: deps.project.path,
|
|
420
|
+
worktreeIds: releasableWorktreeIds(deps, snap),
|
|
421
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(snap.branches),
|
|
422
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(snap.branches),
|
|
423
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
424
|
+
});
|
|
425
|
+
const conflict = casTransition(deps, row, 'pr_closed', {
|
|
426
|
+
prState: 'pr-created',
|
|
427
|
+
deliveryOutcome: 'delivered',
|
|
428
|
+
statusCode: cleanupWarnings.length > 0 ? 'cleanup_incomplete' : 'pr_closed',
|
|
429
|
+
statusDetail: null,
|
|
430
|
+
cleanupWarnings,
|
|
431
|
+
});
|
|
432
|
+
if (conflict)
|
|
433
|
+
return conflict;
|
|
434
|
+
await releaseDeliveredRecoveryLineage(deps, row, row.delivery_sha);
|
|
435
|
+
const after = finalizeTransition(deps, row.id);
|
|
436
|
+
return {
|
|
437
|
+
status: 200,
|
|
438
|
+
body: {
|
|
439
|
+
ok: true,
|
|
440
|
+
decision: 'pr_closed',
|
|
441
|
+
closed: true,
|
|
442
|
+
merged: false,
|
|
443
|
+
prUrl: after?.prUrl ?? row.pr_url,
|
|
444
|
+
prState: 'pr-created',
|
|
445
|
+
deliveryVerified: true,
|
|
446
|
+
verifiedSha: row.delivery_sha,
|
|
447
|
+
remoteHeadSha: observation.headRefOid,
|
|
448
|
+
pushed: false,
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function persistRetryablePrObservationFailure(deps, row, detail) {
|
|
453
|
+
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
454
|
+
deliveryOutcome: 'retryable_failure',
|
|
455
|
+
statusCode: 'push_failed',
|
|
456
|
+
statusDetail: detail,
|
|
457
|
+
});
|
|
458
|
+
if (conflict)
|
|
459
|
+
return conflict;
|
|
460
|
+
finalizeTransition(deps, row.id);
|
|
461
|
+
return { status: 200, body: { ok: true, decision: 'pr_failed', prUrl: row.pr_url, detail } };
|
|
462
|
+
}
|
|
463
|
+
function persistMovedPrHead(deps, row, detail) {
|
|
464
|
+
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
465
|
+
deliveryOutcome: 'blocked',
|
|
466
|
+
statusCode: 'branch_verification_failed',
|
|
467
|
+
statusDetail: detail,
|
|
468
|
+
});
|
|
469
|
+
if (conflict)
|
|
470
|
+
return conflict;
|
|
471
|
+
finalizeTransition(deps, row.id);
|
|
472
|
+
return { status: 200, body: { ok: true, decision: 'pr_failed', prUrl: row.pr_url, detail } };
|
|
473
|
+
}
|
|
474
|
+
function persistRecoveryBlocked(deps, row, detail, deliverySha) {
|
|
475
|
+
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
476
|
+
deliveryOutcome: 'blocked',
|
|
477
|
+
statusCode: 'recovery_unavailable',
|
|
478
|
+
statusDetail: detail,
|
|
479
|
+
...(deliverySha !== undefined ? { deliverySha } : {}),
|
|
480
|
+
isContinuation: true,
|
|
481
|
+
});
|
|
482
|
+
if (conflict)
|
|
483
|
+
return conflict;
|
|
484
|
+
finalizeTransition(deps, row.id);
|
|
485
|
+
return {
|
|
486
|
+
status: 200,
|
|
487
|
+
body: {
|
|
488
|
+
ok: true,
|
|
489
|
+
decision: 'pr_failed',
|
|
490
|
+
prUrl: row.pr_url,
|
|
491
|
+
recoveryUnavailable: true,
|
|
492
|
+
detail,
|
|
493
|
+
},
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function persistProtectedRecoveryRetry(deps, row, snap, matchingUnitIndexes, runId, candidateSha, detail) {
|
|
497
|
+
const recoveredIndexes = new Set(matchingUnitIndexes);
|
|
498
|
+
const recoveredBranches = snap.branches.map((unit, index) => recoveredIndexes.has(index)
|
|
499
|
+
? {
|
|
500
|
+
...unit,
|
|
501
|
+
runId,
|
|
502
|
+
branch: row.branch,
|
|
503
|
+
succeeded: true,
|
|
504
|
+
implementationOutcome: 'succeeded',
|
|
505
|
+
deliveryOutcome: 'ready',
|
|
506
|
+
finalSha: candidateSha,
|
|
507
|
+
changed: unit.changed ?? (unit.initialSha ? unit.initialSha.toLowerCase() !== candidateSha.toLowerCase() : true),
|
|
508
|
+
failureCode: null,
|
|
509
|
+
branchOwnership: 'borrowed-pr',
|
|
510
|
+
}
|
|
511
|
+
: unit);
|
|
512
|
+
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
513
|
+
branches: recoveredBranches,
|
|
514
|
+
deliverySha: candidateSha,
|
|
515
|
+
deliveryOutcome: 'retryable_failure',
|
|
516
|
+
statusCode: 'settlement_interrupted',
|
|
517
|
+
statusDetail: detail,
|
|
518
|
+
isContinuation: true,
|
|
519
|
+
});
|
|
520
|
+
if (conflict)
|
|
521
|
+
return conflict;
|
|
522
|
+
finalizeTransition(deps, row.id);
|
|
523
|
+
return {
|
|
524
|
+
status: 200,
|
|
525
|
+
body: {
|
|
526
|
+
ok: true,
|
|
527
|
+
decision: 'pr_failed',
|
|
528
|
+
prUrl: row.pr_url,
|
|
529
|
+
recovered: true,
|
|
530
|
+
detail,
|
|
531
|
+
},
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
async function exactRefSha(deps, cwd, ref) {
|
|
183
535
|
try {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
536
|
+
const result = await deps.git.run(['rev-parse', '--verify', ref], cwd);
|
|
537
|
+
const sha = result.code === 0 ? result.stdout.trim() : '';
|
|
538
|
+
return COMMIT_SHA_RE.test(sha) ? sha : null;
|
|
187
539
|
}
|
|
188
540
|
catch {
|
|
189
|
-
|
|
541
|
+
return null;
|
|
190
542
|
}
|
|
191
|
-
|
|
543
|
+
}
|
|
544
|
+
async function isFastForwardCandidate(deps, baselineSha, candidateSha) {
|
|
545
|
+
if (baselineSha === candidateSha)
|
|
546
|
+
return true;
|
|
547
|
+
try {
|
|
548
|
+
return (await deps.git.run(['merge-base', '--is-ancestor', baselineSha, candidateSha], deps.project.path)).code === 0;
|
|
549
|
+
}
|
|
550
|
+
catch {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
async function releaseDeliveredRecoveryLineage(deps, row, deliveredSha) {
|
|
555
|
+
if (!deliveredSha || !COMMIT_SHA_RE.test(deliveredSha))
|
|
556
|
+
return;
|
|
557
|
+
const currentProtection = await (0, rail_pr_recovery_git_1.inspectRecoveryCommitProtection)(deps.git, deps.project.path, row.id);
|
|
558
|
+
if (currentProtection.kind === 'present' &&
|
|
559
|
+
currentProtection.sha.toLowerCase() === deliveredSha.toLowerCase()) {
|
|
560
|
+
await (0, rail_pr_recovery_git_1.releaseRecoveryCommit)(deps.git, deps.project.path, row.id, deliveredSha);
|
|
561
|
+
}
|
|
562
|
+
const visited = new Set([row.id]);
|
|
563
|
+
let predecessorId = row.supersedes_delivery_id;
|
|
564
|
+
for (let depth = 0; predecessorId && depth < 32 && !visited.has(predecessorId); depth++) {
|
|
565
|
+
visited.add(predecessorId);
|
|
566
|
+
const predecessor = (0, rail_pr_store_1.getPrDelivery)(deps.db, predecessorId);
|
|
567
|
+
if (!predecessor)
|
|
568
|
+
break;
|
|
569
|
+
if (predecessor.decision !== 'discarded' && predecessor.decision !== 'superseded')
|
|
570
|
+
break;
|
|
571
|
+
const protection = await (0, rail_pr_recovery_git_1.inspectRecoveryCommitProtection)(deps.git, deps.project.path, predecessor.id);
|
|
572
|
+
if (protection.kind === 'present' && await isFastForwardCandidate(deps, protection.sha, deliveredSha)) {
|
|
573
|
+
await (0, rail_pr_recovery_git_1.releaseRecoveryCommit)(deps.git, deps.project.path, predecessor.id, protection.sha);
|
|
574
|
+
}
|
|
575
|
+
predecessorId = predecessor.supersedes_delivery_id;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function parseRegisteredGitWorktrees(stdout) {
|
|
579
|
+
const worktrees = [];
|
|
580
|
+
let current = null;
|
|
581
|
+
const finish = () => {
|
|
582
|
+
if (current)
|
|
583
|
+
worktrees.push(current);
|
|
584
|
+
current = null;
|
|
585
|
+
};
|
|
586
|
+
for (const field of stdout.split('\0')) {
|
|
587
|
+
if (field === '') {
|
|
588
|
+
finish();
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
if (field.startsWith('worktree ')) {
|
|
592
|
+
finish();
|
|
593
|
+
current = { worktreePath: field.slice('worktree '.length), head: null, branch: null };
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
if (!current)
|
|
597
|
+
continue;
|
|
598
|
+
if (field.startsWith('HEAD '))
|
|
599
|
+
current.head = field.slice('HEAD '.length);
|
|
600
|
+
if (field.startsWith('branch '))
|
|
601
|
+
current.branch = field.slice('branch '.length);
|
|
602
|
+
}
|
|
603
|
+
finish();
|
|
604
|
+
return worktrees;
|
|
605
|
+
}
|
|
606
|
+
/** Authenticate a ledger path as a live, non-symlink worktree registered by
|
|
607
|
+
* this exact repository. The main checkout and ordinary directories fail
|
|
608
|
+
* closed. Callers repeat this immediately before staging to close the useful
|
|
609
|
+
* path-replacement window between inspection and mutation. */
|
|
610
|
+
async function authenticateRecoveryWorktree(deps, ledgerPath, expectedBranch, expectedHead) {
|
|
611
|
+
if (!path.isAbsolute(ledgerPath)) {
|
|
612
|
+
return { ok: false, detail: 'the recorded worktree path is not absolute' };
|
|
613
|
+
}
|
|
614
|
+
let realPath;
|
|
615
|
+
let projectRealPath;
|
|
616
|
+
try {
|
|
617
|
+
const ledgerStat = fs.lstatSync(ledgerPath);
|
|
618
|
+
if (ledgerStat.isSymbolicLink()) {
|
|
619
|
+
return { ok: false, detail: 'the recorded worktree path is a symbolic link' };
|
|
620
|
+
}
|
|
621
|
+
if (!ledgerStat.isDirectory()) {
|
|
622
|
+
return { ok: false, detail: 'the recorded worktree path is not a directory' };
|
|
623
|
+
}
|
|
624
|
+
realPath = fs.realpathSync(ledgerPath);
|
|
625
|
+
projectRealPath = fs.realpathSync(deps.project.path);
|
|
626
|
+
if (!fs.statSync(realPath).isDirectory()) {
|
|
627
|
+
return { ok: false, detail: 'the canonical worktree path is not a directory' };
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
catch {
|
|
631
|
+
return { ok: false, detail: 'the recorded worktree path could not be resolved safely' };
|
|
632
|
+
}
|
|
633
|
+
if (realPath === projectRealPath) {
|
|
634
|
+
return { ok: false, detail: 'the recorded worktree path resolves to the main project checkout' };
|
|
635
|
+
}
|
|
636
|
+
let listed;
|
|
637
|
+
try {
|
|
638
|
+
listed = await deps.git.run(['worktree', 'list', '--porcelain', '-z'], deps.project.path);
|
|
639
|
+
}
|
|
640
|
+
catch {
|
|
641
|
+
return { ok: false, detail: 'Git worktree registration could not be verified' };
|
|
642
|
+
}
|
|
643
|
+
if (listed.code !== 0) {
|
|
644
|
+
return { ok: false, detail: 'Git worktree registration could not be verified' };
|
|
645
|
+
}
|
|
646
|
+
const matches = parseRegisteredGitWorktrees(listed.stdout).filter((registered) => {
|
|
647
|
+
try {
|
|
648
|
+
return fs.realpathSync(registered.worktreePath) === realPath;
|
|
649
|
+
}
|
|
650
|
+
catch {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
if (matches.length !== 1) {
|
|
655
|
+
return { ok: false, detail: 'the recorded path is not uniquely registered as a Git worktree of this project' };
|
|
656
|
+
}
|
|
657
|
+
const registered = matches[0];
|
|
658
|
+
if (registered.branch !== `refs/heads/${expectedBranch}`) {
|
|
659
|
+
return { ok: false, detail: 'the registered Git worktree is not on the recorded delivery branch' };
|
|
660
|
+
}
|
|
661
|
+
if (!registered.head || !COMMIT_SHA_RE.test(registered.head)) {
|
|
662
|
+
return { ok: false, detail: 'the registered Git worktree has no verifiable commit identity' };
|
|
663
|
+
}
|
|
664
|
+
if (expectedHead && registered.head.toLowerCase() !== expectedHead.toLowerCase()) {
|
|
665
|
+
return { ok: false, detail: 'the registered Git worktree changed commits before staging' };
|
|
666
|
+
}
|
|
667
|
+
return { ok: true, realPath, head: registered.head };
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Explicit recovery for a legacy successful continuation whose automatic
|
|
671
|
+
* causal scan could not freeze a commit. Unlike Checkout, this operates only
|
|
672
|
+
* on the delivery-owned isolated worktree/branch and never changes the user's
|
|
673
|
+
* main checkout. The user's confirmation authorizes adopting already-committed
|
|
674
|
+
* progress on that exact branch, but only as a non-force fast-forward of the
|
|
675
|
+
* live PR head.
|
|
676
|
+
*/
|
|
677
|
+
async function runRecoverAndRetry(deps, row) {
|
|
678
|
+
if (!row.pr_url || !row.branch || !row.operation_token)
|
|
679
|
+
return illegalAction(row.decision);
|
|
680
|
+
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
681
|
+
const runIds = [...new Set(snap.runIds.filter((runId) => typeof runId === 'string' && runId.length > 0))];
|
|
682
|
+
if (runIds.length !== 1) {
|
|
683
|
+
return persistRecoveryBlocked(deps, row, `Commit & retry push requires exactly one recorded implementation run; found ${runIds.length}. No local evidence was changed.`);
|
|
684
|
+
}
|
|
685
|
+
const runId = runIds[0];
|
|
686
|
+
const matchingUnitIndexes = snap.branches
|
|
687
|
+
.map((branch, index) => branch.branch === row.branch && branch.runId === runId ? index : -1)
|
|
688
|
+
.filter((index) => index >= 0);
|
|
689
|
+
if (matchingUnitIndexes.length === 0) {
|
|
690
|
+
return persistRecoveryBlocked(deps, row, 'Commit & retry push could not prove an exact recorded unit for this run and PR branch. No local evidence was changed.');
|
|
691
|
+
}
|
|
692
|
+
const matchingUnits = matchingUnitIndexes.map((index) => snap.branches[index]);
|
|
693
|
+
const recordedFinalValues = matchingUnits.map((unit) => unit.finalSha);
|
|
694
|
+
const hasAnyRecordedFinal = recordedFinalValues.some((sha) => sha != null);
|
|
695
|
+
const recordedFinalShas = [...new Set(recordedFinalValues
|
|
696
|
+
.filter((sha) => typeof sha === 'string' && COMMIT_SHA_RE.test(sha))
|
|
697
|
+
.map((sha) => sha.toLowerCase()))];
|
|
698
|
+
const recordedFinalEvidenceUnsafe = hasAnyRecordedFinal && (recordedFinalValues.some((sha) => typeof sha !== 'string' || !COMMIT_SHA_RE.test(sha)) ||
|
|
699
|
+
recordedFinalShas.length !== 1);
|
|
700
|
+
// Durable final evidence is one sufficient ownership proof, not a veto over
|
|
701
|
+
// the independent exact run-marker proof. Incomplete/disagreeing migrated
|
|
702
|
+
// unit fields are ignored here; a unique causal commit may still recover the
|
|
703
|
+
// result without adopting any of those disputed SHAs.
|
|
704
|
+
const recordedFinalSha = recordedFinalEvidenceUnsafe ? null : recordedFinalShas[0] ?? null;
|
|
705
|
+
let discovery = null;
|
|
706
|
+
const discoverCandidate = async () => {
|
|
707
|
+
if (!discovery) {
|
|
708
|
+
discovery = await (0, rail_pr_recovery_git_1.discoverRunMarkedCommit)(deps.git, deps.project.path, runId);
|
|
709
|
+
}
|
|
710
|
+
return discovery;
|
|
711
|
+
};
|
|
712
|
+
const ownedWorktrees = snap.worktreeIds
|
|
713
|
+
.map((worktreeId) => (0, rail_worktrees_store_1.getRailWorktree)(deps.db, worktreeId))
|
|
714
|
+
.filter((worktree) => Boolean(worktree && worktree.branch === row.branch && worktree.run_id === runId));
|
|
715
|
+
const presentWorktrees = ownedWorktrees.filter((worktree) => {
|
|
716
|
+
try {
|
|
717
|
+
fs.lstatSync(worktree.worktree_path);
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
catch {
|
|
721
|
+
return false;
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
const worktree = presentWorktrees[0] ?? null;
|
|
725
|
+
let preprotectedCandidateSha = null;
|
|
726
|
+
let preprotectedCandidateSource = null;
|
|
727
|
+
// Discover and pin an exact object before any network dependency, even when
|
|
728
|
+
// a ledger path still exists. A recreated/unsafe/dirty path must not hide an
|
|
729
|
+
// older run-owned orphan or leave it exposed to Git GC.
|
|
730
|
+
{
|
|
731
|
+
if (recordedFinalSha && await commitObjectExists(deps, recordedFinalSha)) {
|
|
732
|
+
preprotectedCandidateSha = recordedFinalSha;
|
|
733
|
+
preprotectedCandidateSource = 'recorded-final';
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
const found = await discoverCandidate();
|
|
737
|
+
if (found.kind === 'ambiguous') {
|
|
738
|
+
return persistRecoveryBlocked(deps, row, `Git found ${found.count} different run-marked commits. No ambiguous object, branch, or worktree was changed.`);
|
|
739
|
+
}
|
|
740
|
+
if (found.kind === 'scan_failed') {
|
|
741
|
+
return persistRecoveryBlocked(deps, row, `${found.detail}. No branch, worktree, or object was changed.`);
|
|
742
|
+
}
|
|
743
|
+
if (found.kind === 'unique') {
|
|
744
|
+
preprotectedCandidateSha = found.sha;
|
|
745
|
+
preprotectedCandidateSource = 'run-marker';
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (preprotectedCandidateSha) {
|
|
749
|
+
const protection = await (0, rail_pr_recovery_git_1.protectRecoveryCommit)(deps.git, deps.project.path, row.id, preprotectedCandidateSha);
|
|
750
|
+
if (!protection.ok) {
|
|
751
|
+
return persistRecoveryBlocked(deps, row, `${protection.detail}. The candidate object and every user-visible branch were left unchanged.`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (presentWorktrees.length > 1) {
|
|
756
|
+
return persistRecoveryBlocked(deps, row, 'Multiple live worktrees claim this run and branch, so Specrails refused to choose one. Every local result remains intact.', preprotectedCandidateSha);
|
|
757
|
+
}
|
|
758
|
+
const observed = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, preprotectedCandidateSha);
|
|
759
|
+
if (!observed.ok) {
|
|
760
|
+
if (preprotectedCandidateSha) {
|
|
761
|
+
if (worktree) {
|
|
762
|
+
return persistRecoveryBlocked(deps, row, `Protected an exact run-owned commit, but a live worktree also exists and the PR could not be observed: ${observed.detail}. Both local results were preserved and neither was selected or pushed.`, preprotectedCandidateSha);
|
|
763
|
+
}
|
|
764
|
+
const durablyProvenNoChange = row.implementation_outcome === 'succeeded' &&
|
|
765
|
+
matchingUnitIndexes.length === snap.branches.length &&
|
|
766
|
+
matchingUnits.every((unit) => (unit.changed === false &&
|
|
767
|
+
unit.initialSha?.toLowerCase() === preprotectedCandidateSha.toLowerCase() &&
|
|
768
|
+
unit.finalSha?.toLowerCase() === preprotectedCandidateSha.toLowerCase()));
|
|
769
|
+
const detail = `Recovered and protected the exact run-owned commit, but the recorded PR could not be observed: ${observed.detail}; retry will revalidate before any push.`;
|
|
770
|
+
if (durablyProvenNoChange) {
|
|
771
|
+
return persistRecoveryBlocked(deps, row, detail, preprotectedCandidateSha);
|
|
772
|
+
}
|
|
773
|
+
return persistProtectedRecoveryRetry(deps, row, snap, matchingUnitIndexes, runId, preprotectedCandidateSha, detail);
|
|
774
|
+
}
|
|
775
|
+
return persistRecoveryBlocked(deps, row, `The existing PR could not be verified before local recovery: ${observed.detail}. No local evidence was changed.`);
|
|
776
|
+
}
|
|
777
|
+
if (!(0, pr_lifecycle_1.isExactOpenPr)(observed, row.branch, row.base_branch) || !observed.headRefOid) {
|
|
778
|
+
if (preprotectedCandidateSha) {
|
|
779
|
+
if (worktree) {
|
|
780
|
+
return persistRecoveryBlocked(deps, row, 'A protected run-owned commit and a live worktree both exist while the recorded PR lifecycle changed. Specrails preserved both and refused to choose or push either automatically.', preprotectedCandidateSha);
|
|
781
|
+
}
|
|
782
|
+
const frozen = persistProtectedRecoveryRetry(deps, row, snap, matchingUnitIndexes, runId, preprotectedCandidateSha, 'Protected the exact run-owned commit; revalidating the changed PR lifecycle before any push.');
|
|
783
|
+
if (frozen.status !== 200 || frozen.body.decision !== 'pr_failed')
|
|
784
|
+
return frozen;
|
|
785
|
+
const recoveredRow = (0, rail_pr_store_1.getPrDelivery)(deps.db, row.id);
|
|
786
|
+
if (!recoveredRow || recoveredRow.operation_token !== row.operation_token) {
|
|
787
|
+
return staleDecision(recoveredRow?.decision ?? row.decision);
|
|
788
|
+
}
|
|
789
|
+
return retryExistingPrFollowupPush(deps, recoveredRow);
|
|
790
|
+
}
|
|
791
|
+
return persistRecoveryBlocked(deps, row, 'The recorded PR is no longer an exact open head/base recovery target. No local evidence was changed.');
|
|
792
|
+
}
|
|
793
|
+
const baselineSha = observed.headRefOid;
|
|
794
|
+
// Ensure the live remote baseline object is available for the ancestry proof
|
|
795
|
+
// without advancing any local branch or touching the main checkout.
|
|
796
|
+
if (!(await commitObjectExists(deps, baselineSha))) {
|
|
797
|
+
try {
|
|
798
|
+
await deps.git.run(['fetch', 'origin', `refs/heads/${row.branch}`], deps.project.path);
|
|
799
|
+
}
|
|
800
|
+
catch { /* the exact object check below remains authoritative */ }
|
|
801
|
+
}
|
|
802
|
+
if (!(await commitObjectExists(deps, baselineSha))) {
|
|
803
|
+
return persistRecoveryBlocked(deps, row, 'The live PR head object is unavailable locally, so fast-forward recovery cannot be proven. No local evidence was changed.', preprotectedCandidateSha);
|
|
804
|
+
}
|
|
805
|
+
let candidateSha = preprotectedCandidateSha;
|
|
806
|
+
let candidateOwned = preprotectedCandidateSha !== null;
|
|
807
|
+
let candidateSource = preprotectedCandidateSource ?? 'baseline';
|
|
808
|
+
let committed = false;
|
|
809
|
+
if (worktree) {
|
|
810
|
+
const authenticated = await authenticateRecoveryWorktree(deps, worktree.worktree_path, row.branch);
|
|
811
|
+
if (!authenticated.ok) {
|
|
812
|
+
return persistRecoveryBlocked(deps, row, `The preserved path at ${worktree.worktree_path} could not be authenticated safely: ${authenticated.detail}. Nothing was staged, pushed, or removed.`, preprotectedCandidateSha);
|
|
813
|
+
}
|
|
814
|
+
const authenticatedPath = authenticated.realPath;
|
|
815
|
+
const [actualBranch, worktreeHead, branchHead] = await Promise.all([
|
|
816
|
+
deps.git.run(['rev-parse', '--abbrev-ref', 'HEAD'], authenticatedPath).catch(() => ({ code: 1, stdout: '', stderr: '' })),
|
|
817
|
+
exactRefSha(deps, authenticatedPath, 'HEAD'),
|
|
818
|
+
exactRefSha(deps, deps.project.path, `refs/heads/${row.branch}`),
|
|
819
|
+
]);
|
|
820
|
+
if (actualBranch.code !== 0 || actualBranch.stdout.trim() !== row.branch ||
|
|
821
|
+
!worktreeHead || !branchHead || worktreeHead !== branchHead ||
|
|
822
|
+
authenticated.head.toLowerCase() !== worktreeHead.toLowerCase()) {
|
|
823
|
+
return persistRecoveryBlocked(deps, row, `The preserved worktree at ${worktree.worktree_path} is not on the exact recorded branch/HEAD. It was left untouched.`, preprotectedCandidateSha);
|
|
824
|
+
}
|
|
825
|
+
if (preprotectedCandidateSha &&
|
|
826
|
+
worktreeHead.toLowerCase() !== preprotectedCandidateSha.toLowerCase()) {
|
|
827
|
+
return persistRecoveryBlocked(deps, row, `A protected run-owned commit and a different live worktree result both exist. Specrails preserved both and refused to choose or bundle them automatically. Inspect ${worktree.worktree_path} before retrying or discarding either result.`, preprotectedCandidateSha);
|
|
828
|
+
}
|
|
829
|
+
if (!(await isFastForwardCandidate(deps, baselineSha, worktreeHead))) {
|
|
830
|
+
return persistRecoveryBlocked(deps, row, `The preserved branch diverges from the live PR head. The worktree at ${worktree.worktree_path} was left untouched.`, preprotectedCandidateSha);
|
|
831
|
+
}
|
|
832
|
+
let skipWorktreeCommit = false;
|
|
833
|
+
if (worktreeHead === baselineSha) {
|
|
834
|
+
candidateOwned = true;
|
|
835
|
+
candidateSource = 'baseline';
|
|
836
|
+
}
|
|
837
|
+
else if (recordedFinalSha && worktreeHead.toLowerCase() === recordedFinalSha) {
|
|
838
|
+
candidateOwned = true;
|
|
839
|
+
candidateSource = 'recorded-final';
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
const found = await discoverCandidate();
|
|
843
|
+
if (found.kind === 'unique' && found.sha === worktreeHead.toLowerCase()) {
|
|
844
|
+
candidateOwned = true;
|
|
845
|
+
candidateSource = 'run-marker';
|
|
846
|
+
}
|
|
847
|
+
else if (found.kind === 'unique') {
|
|
848
|
+
// A later/unrelated checked-out tip must not be bundled into the
|
|
849
|
+
// recovered result. Preserve it untouched and use only the exact
|
|
850
|
+
// run-owned object discovered independently.
|
|
851
|
+
candidateSha = found.sha;
|
|
852
|
+
candidateOwned = true;
|
|
853
|
+
candidateSource = 'run-marker';
|
|
854
|
+
skipWorktreeCommit = true;
|
|
855
|
+
}
|
|
856
|
+
else {
|
|
857
|
+
const reason = found.kind === 'ambiguous'
|
|
858
|
+
? `Git found ${found.count} run-marked commits, so no unique worktree baseline could be chosen.`
|
|
859
|
+
: found.kind === 'scan_failed'
|
|
860
|
+
? `${found.detail}.`
|
|
861
|
+
: 'The preserved worktree branch advanced beyond every delivery-owned commit.';
|
|
862
|
+
return persistRecoveryBlocked(deps, row, `${reason} The worktree at ${worktree.worktree_path} was left untouched.`);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (!skipWorktreeCommit) {
|
|
866
|
+
deps.assertAdmission?.();
|
|
867
|
+
const reauthenticated = await authenticateRecoveryWorktree(deps, worktree.worktree_path, row.branch, worktreeHead);
|
|
868
|
+
if (!reauthenticated.ok || reauthenticated.realPath !== authenticatedPath) {
|
|
869
|
+
const detail = reauthenticated.ok
|
|
870
|
+
? 'the canonical worktree path changed before staging'
|
|
871
|
+
: reauthenticated.detail;
|
|
872
|
+
return persistRecoveryBlocked(deps, row, `The preserved path at ${worktree.worktree_path} failed final authentication: ${detail}. Nothing was staged, pushed, or removed.`);
|
|
873
|
+
}
|
|
874
|
+
deps.assertAdmission?.();
|
|
875
|
+
const overlayExcludes = [...new Set(matchingUnits.flatMap((unit) => unit.overlayExcludes ?? []))];
|
|
876
|
+
const commit = await (0, worktree_manager_1.commitWorktreeAndVerify)(deps.git, reauthenticated.realPath, `specrails: recovered follow-up (run ${runId})`, overlayExcludes);
|
|
877
|
+
if (!commit.clean) {
|
|
878
|
+
return persistRecoveryBlocked(deps, row, `The preserved worktree could not be committed safely: ${commit.error ?? (commit.dirty.join(', ') || 'deliverable changes remain')}. It was left intact at ${worktree.worktree_path}.`);
|
|
879
|
+
}
|
|
880
|
+
committed = commit.committed;
|
|
881
|
+
const [afterBranch, afterHead, afterBranchHead] = await Promise.all([
|
|
882
|
+
deps.git.run(['rev-parse', '--abbrev-ref', 'HEAD'], reauthenticated.realPath).catch(() => ({ code: 1, stdout: '', stderr: '' })),
|
|
883
|
+
exactRefSha(deps, reauthenticated.realPath, 'HEAD'),
|
|
884
|
+
exactRefSha(deps, deps.project.path, `refs/heads/${row.branch}`),
|
|
885
|
+
]);
|
|
886
|
+
if (afterBranch.code !== 0 || afterBranch.stdout.trim() !== row.branch ||
|
|
887
|
+
!afterHead || afterHead !== afterBranchHead) {
|
|
888
|
+
return persistRecoveryBlocked(deps, row, `The recovery commit exists, but final branch verification failed. It remains preserved at ${worktree.worktree_path}.`);
|
|
889
|
+
}
|
|
890
|
+
candidateSha = afterHead;
|
|
891
|
+
if (committed) {
|
|
892
|
+
candidateOwned = true;
|
|
893
|
+
candidateSource = 'worktree';
|
|
894
|
+
}
|
|
895
|
+
if (candidateSource === 'baseline' && recordedFinalSha && afterHead.toLowerCase() === recordedFinalSha) {
|
|
896
|
+
candidateSource = 'recorded-final';
|
|
897
|
+
}
|
|
898
|
+
candidateOwned = candidateOwned || committed || candidateSource !== 'baseline' || afterHead === baselineSha;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
candidateSha ??= await exactRefSha(deps, deps.project.path, `refs/heads/${row.branch}`);
|
|
903
|
+
}
|
|
904
|
+
// A consistent durable final SHA outranks a mutable branch name. This also
|
|
905
|
+
// lets another checkout recover an object whose branch was later reset.
|
|
906
|
+
if (!committed && recordedFinalSha &&
|
|
907
|
+
await commitObjectExists(deps, recordedFinalSha) &&
|
|
908
|
+
(!candidateOwned || candidateSha === baselineSha)) {
|
|
909
|
+
candidateSha = recordedFinalSha;
|
|
910
|
+
candidateOwned = true;
|
|
911
|
+
candidateSource = 'recorded-final';
|
|
912
|
+
}
|
|
913
|
+
// Before claiming absence, inspect the same complete causal surface as
|
|
914
|
+
// startup. A unique run-marked object may survive after both the worktree and
|
|
915
|
+
// visible branch were removed.
|
|
916
|
+
const baselineHasDurableFinalProof = candidateSha === baselineSha && recordedFinalSha === baselineSha;
|
|
917
|
+
if (!candidateSha || (candidateSha === baselineSha && !baselineHasDurableFinalProof) || !candidateOwned) {
|
|
918
|
+
const found = await discoverCandidate();
|
|
919
|
+
if (found.kind === 'ambiguous') {
|
|
920
|
+
return persistRecoveryBlocked(deps, row, `Git found ${found.count} different run-marked commits. No ambiguous object, branch, or worktree was changed.`);
|
|
921
|
+
}
|
|
922
|
+
if (found.kind === 'scan_failed') {
|
|
923
|
+
return persistRecoveryBlocked(deps, row, `${found.detail}. No branch, worktree, or object was changed.`);
|
|
924
|
+
}
|
|
925
|
+
if (found.kind === 'unique') {
|
|
926
|
+
candidateSha = found.sha;
|
|
927
|
+
candidateOwned = true;
|
|
928
|
+
candidateSource = 'run-marker';
|
|
929
|
+
}
|
|
930
|
+
else if (candidateSha && candidateSha !== baselineSha && !candidateOwned) {
|
|
931
|
+
return persistRecoveryBlocked(deps, row, 'The recorded local branch advanced beyond the run-owned result. The later branch tip was preserved and was not committed or pushed.');
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
if (!candidateSha || !(await commitObjectExists(deps, candidateSha))) {
|
|
935
|
+
return persistRecoveryBlocked(deps, row, 'No delivery-owned commit is available in this clone’s refs, reflogs, worktrees, or unreachable objects. The result may still exist on the computer where the run executed; nothing here was changed or removed.');
|
|
936
|
+
}
|
|
937
|
+
if (candidateSha === baselineSha) {
|
|
938
|
+
const provesNoChanges = row.implementation_outcome === 'succeeded' &&
|
|
939
|
+
matchingUnitIndexes.length === snap.branches.length &&
|
|
940
|
+
matchingUnits.every((unit) => (unit.changed === false &&
|
|
941
|
+
unit.initialSha?.toLowerCase() === baselineSha.toLowerCase() &&
|
|
942
|
+
unit.finalSha?.toLowerCase() === baselineSha.toLowerCase()));
|
|
943
|
+
if (provesNoChanges) {
|
|
944
|
+
const noChangeIndexes = new Set(matchingUnitIndexes);
|
|
945
|
+
const noChangeBranches = snap.branches.map((unit, index) => noChangeIndexes.has(index)
|
|
946
|
+
? {
|
|
947
|
+
...unit,
|
|
948
|
+
succeeded: true,
|
|
949
|
+
implementationOutcome: 'succeeded',
|
|
950
|
+
deliveryOutcome: 'no_changes',
|
|
951
|
+
initialSha: baselineSha,
|
|
952
|
+
finalSha: baselineSha,
|
|
953
|
+
changed: false,
|
|
954
|
+
failureCode: null,
|
|
955
|
+
}
|
|
956
|
+
: unit);
|
|
957
|
+
const conflict = casTransition(deps, row, 'no_changes', {
|
|
958
|
+
branches: noChangeBranches,
|
|
959
|
+
deliverySha: baselineSha,
|
|
960
|
+
deliveryOutcome: 'no_changes',
|
|
961
|
+
statusCode: 'no_changes',
|
|
962
|
+
statusDetail: null,
|
|
963
|
+
isContinuation: true,
|
|
964
|
+
});
|
|
965
|
+
if (conflict)
|
|
966
|
+
return conflict;
|
|
967
|
+
await releaseDeliveredRecoveryLineage(deps, row, baselineSha);
|
|
968
|
+
finalizeTransition(deps, row.id);
|
|
969
|
+
return {
|
|
970
|
+
status: 200,
|
|
971
|
+
body: {
|
|
972
|
+
ok: true,
|
|
973
|
+
decision: 'no_changes',
|
|
974
|
+
prUrl: row.pr_url,
|
|
975
|
+
noChanges: true,
|
|
976
|
+
deliveryVerified: true,
|
|
977
|
+
verifiedSha: baselineSha,
|
|
978
|
+
pushed: false,
|
|
979
|
+
},
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
const alreadyDelivered = recordedFinalSha === baselineSha || candidateSource === 'run-marker';
|
|
983
|
+
if (!alreadyDelivered) {
|
|
984
|
+
return persistRecoveryBlocked(deps, row, 'This clone contains only the current PR head and no additional run-owned result. The original execution computer may still retain its worktree or orphan commit; nothing here was changed or removed.');
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
else {
|
|
988
|
+
const protection = preprotectedCandidateSha &&
|
|
989
|
+
preprotectedCandidateSha.toLowerCase() !== candidateSha.toLowerCase()
|
|
990
|
+
? await (0, rail_pr_recovery_git_1.advanceRecoveryCommitProtection)(deps.git, deps.project.path, row.id, preprotectedCandidateSha, candidateSha)
|
|
991
|
+
: await (0, rail_pr_recovery_git_1.protectRecoveryCommit)(deps.git, deps.project.path, row.id, candidateSha);
|
|
992
|
+
if (!protection.ok) {
|
|
993
|
+
return persistRecoveryBlocked(deps, row, `${protection.detail}. The candidate object and every user-visible branch were left unchanged.`, preprotectedCandidateSha);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
if (!(await isFastForwardCandidate(deps, baselineSha, candidateSha))) {
|
|
997
|
+
return persistRecoveryBlocked(deps, row, 'The exact run-owned recovery commit is not a fast-forward of the live PR head. It remains protected locally and nothing was pushed or removed.', candidateSha);
|
|
998
|
+
}
|
|
999
|
+
const recoveredIndexes = new Set(matchingUnitIndexes);
|
|
1000
|
+
const recoveredBranches = snap.branches.map((unit, index) => recoveredIndexes.has(index)
|
|
1001
|
+
? {
|
|
1002
|
+
...unit,
|
|
1003
|
+
runId,
|
|
1004
|
+
branch: row.branch,
|
|
1005
|
+
succeeded: true,
|
|
1006
|
+
implementationOutcome: 'succeeded',
|
|
1007
|
+
deliveryOutcome: 'ready',
|
|
1008
|
+
// Equality with the live PR head can mean the exact run commit was
|
|
1009
|
+
// already delivered; it is not no-change evidence. Preserve a durable
|
|
1010
|
+
// initial SHA when available and infer the observed baseline only for
|
|
1011
|
+
// a still-missing descendant. The proven no-change branch returned
|
|
1012
|
+
// above before reaching this mapping.
|
|
1013
|
+
initialSha: unit.initialSha ?? (candidateSha !== baselineSha ? baselineSha : null),
|
|
1014
|
+
finalSha: candidateSha,
|
|
1015
|
+
changed: true,
|
|
1016
|
+
failureCode: null,
|
|
1017
|
+
branchOwnership: 'borrowed-pr',
|
|
1018
|
+
...(worktree ? { worktreePath: worktree.worktree_path } : {}),
|
|
1019
|
+
}
|
|
1020
|
+
: unit);
|
|
1021
|
+
// Freeze before the network mutation. A crash after this write leaves a
|
|
1022
|
+
// normal immutable Retry push card; a crash before it leaves the run-marked
|
|
1023
|
+
// commit discoverable by startup recovery.
|
|
1024
|
+
if (!(0, rail_pr_store_1.transitionClaimedDecision)(deps.db, row.id, row.decision, 'pr_failed', row.operation_token, {
|
|
1025
|
+
branches: recoveredBranches,
|
|
1026
|
+
deliverySha: candidateSha,
|
|
1027
|
+
deliveryOutcome: 'retryable_failure',
|
|
1028
|
+
statusCode: 'settlement_interrupted',
|
|
1029
|
+
statusDetail: candidateSource === 'worktree'
|
|
1030
|
+
? `Committed the preserved worktree as ${candidateSha.slice(0, 8)}; validating the exact PR before push.`
|
|
1031
|
+
: candidateSource === 'run-marker'
|
|
1032
|
+
? `Protected the unique run-owned commit ${candidateSha.slice(0, 8)}; validating the exact PR before push.`
|
|
1033
|
+
: `Recovered the durable final commit ${candidateSha.slice(0, 8)}; validating the exact PR before push.`,
|
|
1034
|
+
isContinuation: true,
|
|
1035
|
+
})) {
|
|
1036
|
+
const current = (0, rail_pr_store_1.getPrDelivery)(deps.db, row.id);
|
|
1037
|
+
return staleDecision(current?.decision ?? row.decision);
|
|
1038
|
+
}
|
|
1039
|
+
if (worktree)
|
|
1040
|
+
(0, rail_worktrees_store_1.updateRailWorktreeState)(deps.db, worktree.id, 'built');
|
|
1041
|
+
const recoveredRow = (0, rail_pr_store_1.getPrDelivery)(deps.db, row.id);
|
|
1042
|
+
if (!recoveredRow || recoveredRow.operation_token !== row.operation_token) {
|
|
1043
|
+
return staleDecision(recoveredRow?.decision ?? row.decision);
|
|
1044
|
+
}
|
|
1045
|
+
deps.assertAdmission?.();
|
|
1046
|
+
return retryExistingPrFollowupPush(deps, recoveredRow);
|
|
192
1047
|
}
|
|
193
1048
|
async function retryExistingPrFollowupPush(deps, row) {
|
|
194
1049
|
if (!row.branch || !row.pr_url)
|
|
195
1050
|
return { status: 502, body: { error: 'push_failed', detail: 'missing PR branch/url' } };
|
|
1051
|
+
if (!row.delivery_sha) {
|
|
1052
|
+
const detail = 'missing verified delivery SHA; refusing to resolve a mutable branch for retry';
|
|
1053
|
+
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
1054
|
+
deliveryOutcome: 'blocked',
|
|
1055
|
+
statusCode: 'branch_verification_failed',
|
|
1056
|
+
statusDetail: detail,
|
|
1057
|
+
});
|
|
1058
|
+
if (conflict)
|
|
1059
|
+
return conflict;
|
|
1060
|
+
finalizeTransition(deps, row.id);
|
|
1061
|
+
return { status: 409, body: { error: 'missing_verified_sha', decision: 'pr_failed', prUrl: row.pr_url, detail } };
|
|
1062
|
+
}
|
|
1063
|
+
const beforePush = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, row.delivery_sha);
|
|
1064
|
+
if (!beforePush.ok) {
|
|
1065
|
+
return persistRetryablePrObservationFailure(deps, row, `could not confirm the existing PR is open before retry: ${beforePush.detail}`);
|
|
1066
|
+
}
|
|
1067
|
+
if (!(0, pr_lifecycle_1.isExactOpenPr)(beforePush, row.branch, row.base_branch)) {
|
|
1068
|
+
const identityMatches = (0, pr_lifecycle_1.matchesRecordedPrIdentity)(beforePush, row.branch, row.base_branch);
|
|
1069
|
+
if (beforePush.state === 'MERGED' && identityMatches && beforePush.includesExpectedSha === true) {
|
|
1070
|
+
return settleMergedPr(deps, row);
|
|
1071
|
+
}
|
|
1072
|
+
if (beforePush.state === 'MERGED') {
|
|
1073
|
+
return rerouteFromStalePr(deps, row, identityMatches ? mergedEvidenceDetail(beforePush) : 'the previous PR merged after its recorded head/base identity changed', false);
|
|
1074
|
+
}
|
|
1075
|
+
if (beforePush.state === 'CLOSED') {
|
|
1076
|
+
if (identityMatches && beforePush.includesExpectedSha === true) {
|
|
1077
|
+
return settleObservedClosedPr(deps, row, beforePush);
|
|
1078
|
+
}
|
|
1079
|
+
return rerouteFromStalePr(deps, row, 'the previous PR closed before this implementation was delivered', false);
|
|
1080
|
+
}
|
|
1081
|
+
return rerouteFromStalePr(deps, row, 'the existing open PR no longer matches its recorded head/base identity', false);
|
|
1082
|
+
}
|
|
1083
|
+
if (beforePush.includesExpectedSha === true) {
|
|
1084
|
+
return settleObservedExistingPr(deps, row, beforePush, false);
|
|
1085
|
+
}
|
|
1086
|
+
if (!beforePush.headRefOid) {
|
|
1087
|
+
return persistRetryablePrObservationFailure(deps, row, 'the open PR did not expose a verifiable head commit; Retry push will revalidate before mutation');
|
|
1088
|
+
}
|
|
1089
|
+
if (!(await commitObjectExists(deps, beforePush.headRefOid))) {
|
|
1090
|
+
try {
|
|
1091
|
+
await deps.git.run(['fetch', 'origin', `refs/heads/${row.branch}`], deps.project.path);
|
|
1092
|
+
}
|
|
1093
|
+
catch { /* the immutable object check below remains authoritative */ }
|
|
1094
|
+
}
|
|
1095
|
+
if (!(await commitObjectExists(deps, beforePush.headRefOid))) {
|
|
1096
|
+
return persistRetryablePrObservationFailure(deps, row, 'the live PR head object is unavailable locally; Retry push will revalidate before mutation');
|
|
1097
|
+
}
|
|
1098
|
+
if (!(await isFastForwardCandidate(deps, beforePush.headRefOid, row.delivery_sha))) {
|
|
1099
|
+
const detail = 'the exact delivery commit is not a fast-forward of the live PR head; it was not pushed';
|
|
1100
|
+
return row.is_continuation === 1
|
|
1101
|
+
? persistRecoveryBlocked(deps, row, `${detail} and remains protected`, row.delivery_sha)
|
|
1102
|
+
: persistMovedPrHead(deps, row, detail);
|
|
1103
|
+
}
|
|
1104
|
+
const remote = await (0, pr_lifecycle_1.verifyPushRemoteForPr)(deps.exec, deps.project.path, row.pr_url);
|
|
1105
|
+
if (!remote.ok) {
|
|
1106
|
+
return persistRetryablePrObservationFailure(deps, row, `refusing to push until the PR repository and origin are proven identical: ${remote.detail}`);
|
|
1107
|
+
}
|
|
196
1108
|
const pushed = await (0, pr_publisher_1.pushBranch)(deps.exec, {
|
|
197
1109
|
repoDir: deps.project.path,
|
|
198
1110
|
branch: row.branch,
|
|
199
1111
|
baseBranch: row.base_branch,
|
|
1112
|
+
remote: remote.pushTarget,
|
|
1113
|
+
sourceSha: row.delivery_sha,
|
|
200
1114
|
});
|
|
201
1115
|
if (pushed.state === 'local-only') {
|
|
202
|
-
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
1116
|
+
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
1117
|
+
prState: 'local-only',
|
|
1118
|
+
deliveryOutcome: 'retryable_failure',
|
|
1119
|
+
statusCode: 'push_failed',
|
|
1120
|
+
statusDetail: pushed.reason,
|
|
1121
|
+
});
|
|
203
1122
|
if (conflict)
|
|
204
1123
|
return conflict;
|
|
205
1124
|
finalizeTransition(deps, row.id);
|
|
206
1125
|
return { status: 200, body: { ok: true, decision: 'pr_failed', prUrl: row.pr_url, detail: pushed.reason } };
|
|
207
1126
|
}
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
1127
|
+
const afterPush = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, row.delivery_sha);
|
|
1128
|
+
if (!afterPush.ok) {
|
|
1129
|
+
return persistRetryablePrObservationFailure(deps, row, `exact commit was pushed, but the PR lifecycle could not be confirmed: ${afterPush.detail}`);
|
|
1130
|
+
}
|
|
1131
|
+
if ((0, pr_lifecycle_1.isExactOpenPr)(afterPush, row.branch, row.base_branch)) {
|
|
1132
|
+
if (afterPush.includesExpectedSha !== true) {
|
|
1133
|
+
return persistRetryablePrObservationFailure(deps, row, 'the exact push completed, but the PR does not yet expose the verified commit as its head; Retry push remains safe and uses the preserved SHA');
|
|
1134
|
+
}
|
|
1135
|
+
return settleObservedExistingPr(deps, row, afterPush, true);
|
|
1136
|
+
}
|
|
1137
|
+
const identityMatches = (0, pr_lifecycle_1.matchesRecordedPrIdentity)(afterPush, row.branch, row.base_branch);
|
|
1138
|
+
if (afterPush.state === 'MERGED' && identityMatches && afterPush.includesExpectedSha === true) {
|
|
1139
|
+
return settleMergedPr(deps, row);
|
|
1140
|
+
}
|
|
1141
|
+
if (afterPush.state === 'MERGED') {
|
|
1142
|
+
return rerouteFromStalePr(deps, row, identityMatches ? mergedEvidenceDetail(afterPush) : 'the previous PR merged after its recorded head/base identity changed', true);
|
|
1143
|
+
}
|
|
1144
|
+
if (afterPush.state === 'CLOSED') {
|
|
1145
|
+
if (identityMatches && afterPush.includesExpectedSha === true) {
|
|
1146
|
+
return settleObservedClosedPr(deps, row, afterPush);
|
|
1147
|
+
}
|
|
1148
|
+
return rerouteFromStalePr(deps, row, 'the previous PR closed before this implementation was delivered', true);
|
|
1149
|
+
}
|
|
1150
|
+
return rerouteFromStalePr(deps, row, 'the existing open PR no longer matches its recorded head/base identity after the exact push', true);
|
|
216
1151
|
}
|
|
217
1152
|
/**
|
|
218
1153
|
* Load the PR's ticket data (title/labels/description) from the ticket store,
|
|
@@ -254,63 +1189,77 @@ async function branchExists(deps, branch) {
|
|
|
254
1189
|
const r = await deps.git.run(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], deps.project.path);
|
|
255
1190
|
return r.code === 0;
|
|
256
1191
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
* rail_worktrees ledger (newest first) for ANY other branch a rail allocated
|
|
262
|
-
* for the same ticket that still exists AND has commits ahead of the base —
|
|
263
|
-
* that branch is the real carrier of the work. Null when nothing recoverable.
|
|
264
|
-
*/
|
|
265
|
-
async function findRecoverableBranch(deps, unit, baseBranch) {
|
|
266
|
-
let candidates = [];
|
|
1192
|
+
const COMMIT_SHA_RE = /^[0-9a-f]{40,64}$/i;
|
|
1193
|
+
async function commitObjectExists(deps, sha) {
|
|
1194
|
+
if (!COMMIT_SHA_RE.test(sha))
|
|
1195
|
+
return false;
|
|
267
1196
|
try {
|
|
268
|
-
|
|
1197
|
+
return (await deps.git.run(['cat-file', '-e', `${sha}^{commit}`], deps.project.path)).code === 0;
|
|
269
1198
|
}
|
|
270
1199
|
catch {
|
|
271
|
-
return
|
|
1200
|
+
return false;
|
|
272
1201
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
1202
|
+
}
|
|
1203
|
+
/** Resolve a legacy mutable ref once into an immutable object. New settlement
|
|
1204
|
+
* rows already carry finalSha and never take this compatibility path. */
|
|
1205
|
+
async function captureBranchSha(deps, branch) {
|
|
1206
|
+
try {
|
|
1207
|
+
const result = await deps.git.run(['rev-parse', '--verify', `refs/heads/${branch}`], deps.project.path);
|
|
1208
|
+
const sha = result.code === 0 ? result.stdout.trim() : '';
|
|
1209
|
+
return COMMIT_SHA_RE.test(sha) ? sha : null;
|
|
1210
|
+
}
|
|
1211
|
+
catch {
|
|
1212
|
+
return null;
|
|
282
1213
|
}
|
|
283
|
-
return null;
|
|
284
1214
|
}
|
|
285
1215
|
async function runCreatePr(deps, row) {
|
|
286
1216
|
if (row.decision === 'pr_failed' && row.pr_url && row.branch) {
|
|
287
1217
|
return retryExistingPrFollowupPush(deps, row);
|
|
288
1218
|
}
|
|
289
1219
|
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
290
|
-
//
|
|
291
|
-
//
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
// and persist the substitution on the row; unrecoverable → honest pr_failed.
|
|
1220
|
+
// Resolve every deliverable unit to an immutable object. New rows carry the
|
|
1221
|
+
// verified final SHA from settlement; legacy rows may capture their recorded
|
|
1222
|
+
// ref once. Never substitute another historical branch merely because it
|
|
1223
|
+
// belongs to the same ticket.
|
|
295
1224
|
let effectiveBranches = snap.branches;
|
|
296
|
-
let
|
|
297
|
-
|
|
1225
|
+
let branchEvidenceCaptured = false;
|
|
1226
|
+
const singleDeliverable = snap.branches.filter((unit) => unit.succeeded).length === 1;
|
|
1227
|
+
const frozenSingleSha = singleDeliverable && row.delivery_sha && COMMIT_SHA_RE.test(row.delivery_sha) &&
|
|
1228
|
+
await commitObjectExists(deps, row.delivery_sha)
|
|
1229
|
+
? row.delivery_sha
|
|
1230
|
+
: null;
|
|
1231
|
+
for (let index = 0; index < snap.branches.length; index++) {
|
|
1232
|
+
const unit = snap.branches[index];
|
|
298
1233
|
if (!unit.succeeded)
|
|
299
1234
|
continue;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
1235
|
+
// A detached/stale single-unit delivery already has authoritative immutable
|
|
1236
|
+
// evidence. Prefer it over both legacy unit gaps and a branch ref that may
|
|
1237
|
+
// have advanced while the card waited for the user's decision.
|
|
1238
|
+
let sourceSha = frozenSingleSha ?? (unit.finalSha && COMMIT_SHA_RE.test(unit.finalSha) ? unit.finalSha : null);
|
|
1239
|
+
if (sourceSha) {
|
|
1240
|
+
if (!(await commitObjectExists(deps, sourceSha)))
|
|
1241
|
+
sourceSha = null;
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
sourceSha = await captureBranchSha(deps, unit.branch);
|
|
1245
|
+
if (sourceSha && !(await commitObjectExists(deps, sourceSha)))
|
|
1246
|
+
sourceSha = null;
|
|
1247
|
+
}
|
|
1248
|
+
if (!sourceSha) {
|
|
1249
|
+
const detail = `the verified commit for branch '${unit.branch}' (ticket #${unit.ticketId}) is unavailable; refusing to deliver a mutable or unrelated ref`;
|
|
1250
|
+
const conflict = casTransition(deps, row, 'pr_failed', {
|
|
1251
|
+
deliveryOutcome: 'blocked', statusCode: 'branch_verification_failed', statusDetail: detail,
|
|
1252
|
+
});
|
|
306
1253
|
if (conflict)
|
|
307
1254
|
return conflict;
|
|
308
1255
|
finalizeTransition(deps, row.id);
|
|
309
1256
|
return { status: 200, body: { ok: true, decision: 'pr_failed', detail } };
|
|
310
1257
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
1258
|
+
if (unit.finalSha !== sourceSha)
|
|
1259
|
+
branchEvidenceCaptured = true;
|
|
1260
|
+
effectiveBranches = effectiveBranches.map((branch, branchIndex) => branchIndex === index
|
|
1261
|
+
? { ...branch, finalSha: sourceSha }
|
|
1262
|
+
: branch);
|
|
314
1263
|
}
|
|
315
1264
|
// Succeeded COVERED tickets for the PR title/body: a single unit covers every
|
|
316
1265
|
// launch ticket (scope='all'), per-ticket units cover exactly their own.
|
|
@@ -322,16 +1271,7 @@ async function runCreatePr(deps, row) {
|
|
|
322
1271
|
// The batch name is derived ONLY for multi-unit deliveries — the single-ticket
|
|
323
1272
|
// path delivers straight from its unit branch and must never even compute one.
|
|
324
1273
|
const batchPreferred = succeededUnits.length > 1 ? (0, pr_naming_1.batchBranchNameFor)(ticketData) : null;
|
|
325
|
-
// Retry hazard: deliverRailAsPr assembles with `worktree add -b` (no -B) and a
|
|
326
|
-
// prior degraded delivery KEEPS the batch branch — so a retry would die on
|
|
327
|
-
// "branch already exists". Defensively drop the stale batch branch first
|
|
328
|
-
// (batch deliveries only). HARD GUARDS: NEVER a branch present in the row's
|
|
329
|
-
// unit records (deleting one would destroy the commits about to be delivered)
|
|
330
|
-
// and NEVER the integration branch; a missing branch is tolerated.
|
|
331
1274
|
const unitBranches = new Set(effectiveBranches.map((b) => b.branch));
|
|
332
|
-
if (batchPreferred && batchPreferred !== row.base_branch && !unitBranches.has(batchPreferred)) {
|
|
333
|
-
await deps.git.run(['branch', '-D', batchPreferred], deps.project.path).catch(() => { });
|
|
334
|
-
}
|
|
335
1275
|
// Per-ticket covering branch for the body's honest Tests digest: per-ticket
|
|
336
1276
|
// units map 1:1; a single 'all'-scope unit covers every launch ticket.
|
|
337
1277
|
const branchFor = (ticketId) => {
|
|
@@ -358,38 +1298,75 @@ async function runCreatePr(deps, row) {
|
|
|
358
1298
|
});
|
|
359
1299
|
let next;
|
|
360
1300
|
// Underlying git/gh failure detail for a degraded or failed delivery —
|
|
361
|
-
// relayed on the response
|
|
362
|
-
// of a bare "retry". Never persisted (the durable columns stay state-only).
|
|
1301
|
+
// relayed on the response and persisted as bounded secondary diagnostics.
|
|
363
1302
|
let detail = null;
|
|
364
1303
|
const patch = {};
|
|
365
|
-
|
|
366
|
-
// actually carries the commits — the next retry/discard works from reality.
|
|
367
|
-
if (branchesRecovered)
|
|
1304
|
+
if (branchEvidenceCaptured)
|
|
368
1305
|
patch.branches = effectiveBranches;
|
|
369
1306
|
try {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
1307
|
+
// A degraded multi-unit attempt already owns an assembled batch branch.
|
|
1308
|
+
// Retry that exact head so exact head/base PR discovery remains idempotent;
|
|
1309
|
+
// never `branch -D` a merely name-matching ref, which could destroy a user's
|
|
1310
|
+
// unrelated or subsequently edited local branch.
|
|
1311
|
+
let degradedBatchSha = null;
|
|
1312
|
+
if (batchPreferred && row.branch && row.pr_url === null &&
|
|
1313
|
+
(row.pr_state === 'pushed' || row.pr_state === 'local-only') &&
|
|
1314
|
+
row.branch !== row.base_branch && !unitBranches.has(row.branch)) {
|
|
1315
|
+
if (row.delivery_sha && await commitObjectExists(deps, row.delivery_sha)) {
|
|
1316
|
+
degradedBatchSha = row.delivery_sha;
|
|
1317
|
+
}
|
|
1318
|
+
else {
|
|
1319
|
+
degradedBatchSha = await captureBranchSha(deps, row.branch);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
const result = degradedBatchSha
|
|
1323
|
+
? {
|
|
1324
|
+
state: 'delivered',
|
|
1325
|
+
branch: row.branch,
|
|
1326
|
+
pr: await (0, pr_publisher_1.publishDraftPr)(deps.exec, {
|
|
1327
|
+
repoDir: deps.project.path,
|
|
1328
|
+
branch: row.branch,
|
|
1329
|
+
baseBranch: row.base_branch,
|
|
1330
|
+
title,
|
|
1331
|
+
body,
|
|
1332
|
+
sourceSha: degradedBatchSha,
|
|
1333
|
+
}),
|
|
1334
|
+
ticketIds: succeededTicketIds,
|
|
1335
|
+
}
|
|
1336
|
+
: await (0, rail_pr_delivery_1.deliverRailAsPr)(deps.git, deps.exec, {
|
|
1337
|
+
baseRepo: deps.project.path,
|
|
1338
|
+
integrationBranch: row.base_branch,
|
|
1339
|
+
railKey: row.rail_key,
|
|
1340
|
+
batchBranch: batchPreferred ?? undefined,
|
|
1341
|
+
batchWorktreeRoot: batchWorktreeRoot(deps.project.slug),
|
|
1342
|
+
branches: effectiveBranches.map((unit) => ({
|
|
1343
|
+
...unit,
|
|
1344
|
+
sourceSha: unit.finalSha ?? undefined,
|
|
1345
|
+
})),
|
|
1346
|
+
title,
|
|
1347
|
+
body,
|
|
1348
|
+
});
|
|
380
1349
|
if (result.state === 'delivered') {
|
|
381
|
-
next = 'pr_draft';
|
|
1350
|
+
next = result.pr.state === 'pr-created' && result.pr.isDraft === false ? 'pr_ready' : 'pr_draft';
|
|
382
1351
|
patch.branch = result.branch;
|
|
383
1352
|
patch.prState = result.pr.state;
|
|
1353
|
+
const resultSha = degradedBatchSha
|
|
1354
|
+
?? (succeededUnits.length === 1 ? succeededUnits[0].finalSha ?? null : await captureBranchSha(deps, result.branch));
|
|
1355
|
+
if (resultSha && await commitObjectExists(deps, resultSha))
|
|
1356
|
+
patch.deliverySha = resultSha;
|
|
384
1357
|
if (result.pr.state === 'pr-created' && result.pr.prUrl) {
|
|
385
1358
|
patch.prUrl = result.pr.prUrl;
|
|
386
1359
|
patch.prNumber = parsePrNumber(result.pr.prUrl);
|
|
1360
|
+
patch.deliveryOutcome = 'delivered';
|
|
1361
|
+
patch.statusCode = next === 'pr_ready' ? 'pr_ready' : 'pr_draft_ready';
|
|
387
1362
|
}
|
|
388
1363
|
else {
|
|
389
1364
|
// Degraded (pushed / local-only): no PR exists — only retry or discard.
|
|
390
1365
|
patch.prUrl = null;
|
|
391
1366
|
patch.prNumber = null;
|
|
392
1367
|
detail = result.pr.reason ?? null;
|
|
1368
|
+
patch.deliveryOutcome = 'retryable_failure';
|
|
1369
|
+
patch.statusCode = result.pr.state === 'local-only' ? 'push_failed' : 'delivery_failed';
|
|
393
1370
|
}
|
|
394
1371
|
}
|
|
395
1372
|
else {
|
|
@@ -397,6 +1374,11 @@ async function runCreatePr(deps, row) {
|
|
|
397
1374
|
// succeeded unit, but a wedged row must not 500) → retryable failure.
|
|
398
1375
|
next = 'pr_failed';
|
|
399
1376
|
detail = result.reason;
|
|
1377
|
+
const retryable = !result.reason.startsWith('merge-conflict:') &&
|
|
1378
|
+
!result.reason.startsWith('batch-branch-collision:') &&
|
|
1379
|
+
result.reason !== 'missing-batch-branch' && result.state === 'assembly-failed';
|
|
1380
|
+
patch.deliveryOutcome = retryable ? 'retryable_failure' : 'blocked';
|
|
1381
|
+
patch.statusCode = 'delivery_failed';
|
|
400
1382
|
}
|
|
401
1383
|
}
|
|
402
1384
|
catch (err) {
|
|
@@ -405,12 +1387,26 @@ async function runCreatePr(deps, row) {
|
|
|
405
1387
|
console.error('[rail-pr-decision] create-pr delivery failed:', err);
|
|
406
1388
|
next = 'pr_failed';
|
|
407
1389
|
detail = err instanceof Error ? err.message : String(err);
|
|
1390
|
+
patch.deliveryOutcome = 'blocked';
|
|
1391
|
+
patch.statusCode = 'delivery_failed';
|
|
1392
|
+
}
|
|
1393
|
+
if (detail)
|
|
1394
|
+
patch.statusDetail = detail;
|
|
1395
|
+
if ((next === 'pr_draft' || next === 'pr_ready') && patch.prUrl) {
|
|
1396
|
+
patch.cleanupWarnings = await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
1397
|
+
db: deps.db, git: deps.git, repoDir: deps.project.path, worktreeIds: releasableWorktreeIds(deps, snap),
|
|
1398
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(effectiveBranches),
|
|
1399
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(effectiveBranches),
|
|
1400
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
1401
|
+
});
|
|
1402
|
+
if (patch.cleanupWarnings.length > 0)
|
|
1403
|
+
patch.statusCode = 'cleanup_incomplete';
|
|
408
1404
|
}
|
|
409
1405
|
const conflict = casTransition(deps, row, next, patch);
|
|
410
1406
|
if (conflict)
|
|
411
1407
|
return conflict;
|
|
412
|
-
if (next === 'pr_draft' && patch.prUrl) {
|
|
413
|
-
await (
|
|
1408
|
+
if ((next === 'pr_draft' || next === 'pr_ready') && patch.prUrl) {
|
|
1409
|
+
await releaseDeliveredRecoveryLineage(deps, row, patch.deliverySha ?? row.delivery_sha);
|
|
414
1410
|
}
|
|
415
1411
|
const after = finalizeTransition(deps, row.id);
|
|
416
1412
|
// Tickets stay on_review — a draft PR is still awaiting the engineer's merge.
|
|
@@ -426,164 +1422,480 @@ async function runCreatePr(deps, row) {
|
|
|
426
1422
|
};
|
|
427
1423
|
}
|
|
428
1424
|
async function runPublish(deps, row) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
1425
|
+
if (!row.delivery_sha || !row.branch) {
|
|
1426
|
+
return persistMovedPrHead(deps, row, 'the draft PR has no immutable delivery SHA/head identity; refusing to mutate unverifiable review state');
|
|
1427
|
+
}
|
|
1428
|
+
const beforePublish = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, row.delivery_sha);
|
|
1429
|
+
if (!beforePublish.ok) {
|
|
1430
|
+
return { status: 502, body: { error: 'gh_failed', detail: beforePublish.detail } };
|
|
1431
|
+
}
|
|
1432
|
+
if (!(0, pr_lifecycle_1.matchesRecordedPrIdentity)(beforePublish, row.branch, row.base_branch)) {
|
|
1433
|
+
return rerouteFromStalePr(deps, row, `the recorded PR is ${beforePublish.state.toLowerCase()} but no longer matches its original head/base identity`, beforePublish.includesExpectedSha === true);
|
|
1434
|
+
}
|
|
1435
|
+
if (beforePublish.state === 'MERGED') {
|
|
1436
|
+
return beforePublish.includesExpectedSha === true
|
|
1437
|
+
? settleMergedPr(deps, row)
|
|
1438
|
+
: rerouteFromStalePr(deps, row, mergedEvidenceDetail(beforePublish), false);
|
|
1439
|
+
}
|
|
1440
|
+
if (beforePublish.state === 'CLOSED') {
|
|
1441
|
+
return beforePublish.includesExpectedSha === true
|
|
1442
|
+
? settleObservedClosedPr(deps, row, beforePublish)
|
|
1443
|
+
: rerouteFromStalePr(deps, row, 'the draft PR closed without the verified implementation commit', false);
|
|
1444
|
+
}
|
|
1445
|
+
if (beforePublish.includesExpectedSha !== true) {
|
|
1446
|
+
return persistRetryablePrObservationFailure(deps, row, 'the draft PR no longer exposes the verified implementation commit; Retry push is available and will use the preserved exact SHA');
|
|
1447
|
+
}
|
|
1448
|
+
if (beforePublish.isDraft === false) {
|
|
1449
|
+
return settleObservedExistingPr(deps, row, beforePublish, false);
|
|
1450
|
+
}
|
|
1451
|
+
let r;
|
|
1452
|
+
try {
|
|
1453
|
+
r = await deps.exec.run('gh', ['pr', 'ready', row.pr_url], deps.project.path);
|
|
1454
|
+
}
|
|
1455
|
+
catch (err) {
|
|
1456
|
+
r = { code: 1, stdout: '', stderr: err instanceof Error ? err.message : String(err) };
|
|
1457
|
+
}
|
|
1458
|
+
// `gh pr ready` is externally mutating and may return an ambiguous error.
|
|
1459
|
+
// Re-observe exact remote truth in every case before changing the ledger.
|
|
1460
|
+
const afterPublish = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, row.delivery_sha);
|
|
1461
|
+
if (!afterPublish.ok) {
|
|
1462
|
+
if (r.code !== 0)
|
|
1463
|
+
return ghFailed(r);
|
|
1464
|
+
return { status: 502, body: { error: 'gh_failed', detail: `PR readiness could not be verified: ${afterPublish.detail}` } };
|
|
1465
|
+
}
|
|
1466
|
+
if (!(0, pr_lifecycle_1.matchesRecordedPrIdentity)(afterPublish, row.branch, row.base_branch)) {
|
|
1467
|
+
return rerouteFromStalePr(deps, row, `the PR identity changed while publishing it for review (${afterPublish.state.toLowerCase()})`, afterPublish.includesExpectedSha === true);
|
|
1468
|
+
}
|
|
1469
|
+
if (afterPublish.state === 'MERGED') {
|
|
1470
|
+
return afterPublish.includesExpectedSha === true
|
|
1471
|
+
? settleMergedPr(deps, row)
|
|
1472
|
+
: rerouteFromStalePr(deps, row, mergedEvidenceDetail(afterPublish), false);
|
|
1473
|
+
}
|
|
1474
|
+
if (afterPublish.state === 'CLOSED') {
|
|
1475
|
+
return afterPublish.includesExpectedSha === true
|
|
1476
|
+
? settleObservedClosedPr(deps, row, afterPublish)
|
|
1477
|
+
: rerouteFromStalePr(deps, row, 'the PR closed without the verified implementation commit while being published', false);
|
|
1478
|
+
}
|
|
1479
|
+
if (afterPublish.includesExpectedSha !== true) {
|
|
1480
|
+
return persistRetryablePrObservationFailure(deps, row, 'the PR no longer exposes the verified implementation commit after publishing; Retry push is available');
|
|
1481
|
+
}
|
|
1482
|
+
if (afterPublish.isDraft) {
|
|
1483
|
+
if (r.code !== 0)
|
|
1484
|
+
return ghFailed(r);
|
|
1485
|
+
return { status: 502, body: { error: 'gh_failed', detail: 'PR remained a draft after publishing' } };
|
|
1486
|
+
}
|
|
1487
|
+
return settleObservedExistingPr(deps, row, afterPublish, false);
|
|
439
1488
|
}
|
|
440
|
-
async function runDiscard(deps, row) {
|
|
1489
|
+
async function runDiscard(deps, row, opts = { removeNeedsReview: true }) {
|
|
441
1490
|
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
442
1491
|
const implementationFailed = row.decision === 'implementation_failed';
|
|
443
|
-
//
|
|
444
|
-
//
|
|
445
|
-
//
|
|
446
|
-
//
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
//
|
|
450
|
-
|
|
1492
|
+
// PR lifecycle ownership and head-ref ownership are separate. Startup repairs
|
|
1493
|
+
// historical continuation rows before admission opens; only that durable bit
|
|
1494
|
+
// borrows the PR/ticket lifecycle. Per-unit ownership below independently
|
|
1495
|
+
// prevents deletion of borrowed/pre-existing head refs for fresh replacements.
|
|
1496
|
+
const preserveExternalReview = row.is_continuation === 1;
|
|
1497
|
+
const cleanupWarnings = [];
|
|
1498
|
+
// A continuation borrows an existing PR/head. Discarding its local iteration
|
|
1499
|
+
// may remove Specrails' worktree, but never closes or deletes borrowed review
|
|
1500
|
+
// state. A fresh PR is closed without GitHub's unleased --delete-branch: its
|
|
1501
|
+
// remote head may have advanced since the card was rendered.
|
|
1502
|
+
if (row.pr_url && !implementationFailed && !preserveExternalReview) {
|
|
451
1503
|
try {
|
|
452
|
-
const r = await deps.exec.run('gh', ['pr', 'close', row.pr_url
|
|
1504
|
+
const r = await deps.exec.run('gh', ['pr', 'close', row.pr_url], deps.project.path);
|
|
453
1505
|
if (r.code !== 0) {
|
|
454
|
-
|
|
1506
|
+
const detail = (r.stderr.trim() || r.stdout.trim()).split('\n')[0] || `exit ${r.code}`;
|
|
1507
|
+
cleanupWarnings.push(`PR close ${row.pr_url}: ${detail}`);
|
|
1508
|
+
console.warn(`[rail-pr-decision] gh pr close failed (continuing discard): ${detail}`);
|
|
455
1509
|
}
|
|
456
1510
|
}
|
|
457
1511
|
catch (err) {
|
|
1512
|
+
cleanupWarnings.push(`PR close ${row.pr_url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
458
1513
|
console.warn('[rail-pr-decision] gh pr close threw (continuing discard):', err);
|
|
459
1514
|
}
|
|
460
1515
|
}
|
|
461
|
-
// 2.
|
|
462
|
-
//
|
|
463
|
-
//
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
1516
|
+
// 2. Release only worktrees whose live tracked/untracked/ignored state and
|
|
1517
|
+
// exact HEAD/ref still match durable settlement evidence. Explicit
|
|
1518
|
+
// discard is not permission to contradict the confirmation copy by
|
|
1519
|
+
// force-removing subsequently changed local work. Authenticated overlays
|
|
1520
|
+
// take the same lossless quarantine path as automatic settlement.
|
|
1521
|
+
const deleteOwnedBranches = !implementationFailed && !preserveExternalReview;
|
|
1522
|
+
const skippedNeedsReview = opts.removeNeedsReview === true
|
|
1523
|
+
? []
|
|
1524
|
+
: snap.worktreeIds
|
|
1525
|
+
.map((wtId) => (0, rail_worktrees_store_1.getRailWorktree)(deps.db, wtId))
|
|
1526
|
+
.filter((wt) => wt?.merge_state === 'needs-review');
|
|
1527
|
+
for (const worktree of skippedNeedsReview) {
|
|
1528
|
+
cleanupWarnings.push(`worktree ${worktree.worktree_path}: preserved for inspection because it already requires review`);
|
|
1529
|
+
}
|
|
1530
|
+
const skippedIds = new Set(skippedNeedsReview.map((wt) => wt.id));
|
|
1531
|
+
const worktreeIds = snap.worktreeIds.filter((wtId) => !skippedIds.has(wtId));
|
|
1532
|
+
cleanupWarnings.push(...await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
1533
|
+
db: deps.db,
|
|
1534
|
+
git: deps.git,
|
|
1535
|
+
repoDir: deps.project.path,
|
|
1536
|
+
worktreeIds,
|
|
1537
|
+
state: 'failed',
|
|
1538
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(snap.branches),
|
|
1539
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(snap.branches),
|
|
1540
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
1541
|
+
}));
|
|
1542
|
+
const retainedWorktreeBranches = new Set(snap.worktreeIds
|
|
1543
|
+
.map((wtId) => (0, rail_worktrees_store_1.getRailWorktree)(deps.db, wtId))
|
|
1544
|
+
.filter((wt) => Boolean(wt && (wt.merge_state === 'needs-review' || fs.existsSync(wt.worktree_path))))
|
|
1545
|
+
.map((wt) => wt.branch));
|
|
1546
|
+
// 3. Delete only branches this delivery durably records as created, and only
|
|
1547
|
+
// while their live tips still equal the immutable delivered commits.
|
|
1548
|
+
// Later user/collaborator commits are retained with a cleanup warning.
|
|
1549
|
+
if (deleteOwnedBranches) {
|
|
1550
|
+
await deleteOwnedBranchesIfUnchanged(deps, row, snap, cleanupWarnings, retainedWorktreeBranches);
|
|
1551
|
+
}
|
|
1552
|
+
// Explicit Discard local result is also the only authority (besides proven
|
|
1553
|
+
// delivery) to release a pinned orphan. A crash can occur after the atomic
|
|
1554
|
+
// ref creation but before delivery_sha is written, so recover that ownership
|
|
1555
|
+
// only from this delivery's exact durable final SHA or run-marker evidence.
|
|
1556
|
+
if (opts.removeNeedsReview === true) {
|
|
1557
|
+
let recoverySha = row.delivery_sha && COMMIT_SHA_RE.test(row.delivery_sha)
|
|
1558
|
+
? row.delivery_sha.toLowerCase()
|
|
1559
|
+
: null;
|
|
1560
|
+
if (!recoverySha && row.is_continuation === 1 &&
|
|
1561
|
+
(row.status_code === 'settlement_interrupted' || row.status_code === 'recovery_unavailable')) {
|
|
1562
|
+
const protection = await (0, rail_pr_recovery_git_1.inspectRecoveryCommitProtection)(deps.git, deps.project.path, row.id);
|
|
1563
|
+
if (protection.kind === 'present') {
|
|
1564
|
+
const durableFinalShas = [...new Set(snap.branches
|
|
1565
|
+
.map((unit) => unit.finalSha)
|
|
1566
|
+
.filter((sha) => typeof sha === 'string' && COMMIT_SHA_RE.test(sha))
|
|
1567
|
+
.map((sha) => sha.toLowerCase()))];
|
|
1568
|
+
const runIds = [...new Set(snap.runIds.filter(Boolean))];
|
|
1569
|
+
const exactDurableFinal = durableFinalShas.length === 1 && durableFinalShas[0] === protection.sha;
|
|
1570
|
+
const exactRunMarker = runIds.length === 1 && await (0, rail_pr_recovery_git_1.commitCarriesRunMarker)(deps.git, deps.project.path, protection.sha, runIds[0]);
|
|
1571
|
+
if (exactDurableFinal || exactRunMarker) {
|
|
1572
|
+
recoverySha = protection.sha;
|
|
1573
|
+
}
|
|
1574
|
+
else {
|
|
1575
|
+
cleanupWarnings.push(`recovery ref ${protection.ref}: preserved because its commit could not be proven to belong to this delivery`);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
else if (protection.kind === 'unreadable') {
|
|
1579
|
+
cleanupWarnings.push(`recovery ref ${protection.ref}: preserved because its exact commit could not be read safely`);
|
|
1580
|
+
}
|
|
475
1581
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
continue;
|
|
1582
|
+
if (recoverySha && !await (0, rail_pr_recovery_git_1.releaseRecoveryCommit)(deps.git, deps.project.path, row.id, recoverySha)) {
|
|
1583
|
+
cleanupWarnings.push('the delivery recovery ref changed or could not be removed; it was preserved for inspection');
|
|
479
1584
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
1585
|
+
}
|
|
1586
|
+
const terminalPatch = {
|
|
1587
|
+
deliveryOutcome: 'not_started',
|
|
1588
|
+
statusCode: cleanupWarnings.length > 0 ? 'cleanup_incomplete' : 'discarded',
|
|
1589
|
+
cleanupWarnings,
|
|
1590
|
+
};
|
|
1591
|
+
const conflict = preserveExternalReview
|
|
1592
|
+
? casTransition(deps, row, 'discarded', terminalPatch)
|
|
1593
|
+
: casTransitionWithTicketEffect(deps, row, 'discarded', terminalPatch, {
|
|
1594
|
+
deliveryId: row.id,
|
|
1595
|
+
ticketIds: snap.ticketIds,
|
|
1596
|
+
targetStatus: 'todo',
|
|
1597
|
+
// The dashboard labels discard-from-no_changes as Refine. Jira must
|
|
1598
|
+
// mirror that truthful backlog return and never apply discardStatus.
|
|
1599
|
+
jiraAction: row.decision === 'no_changes' ? 'refine' : 'discard',
|
|
1600
|
+
prUrl: null,
|
|
1601
|
+
});
|
|
1602
|
+
if (conflict)
|
|
1603
|
+
return conflict;
|
|
1604
|
+
if (!preserveExternalReview)
|
|
1605
|
+
applyTerminalTicketEffect(deps, row, 'discarded', cleanupWarnings);
|
|
1606
|
+
finalizeTransition(deps, row.id);
|
|
1607
|
+
return {
|
|
1608
|
+
status: 200,
|
|
1609
|
+
body: {
|
|
1610
|
+
ok: true,
|
|
1611
|
+
decision: 'discarded',
|
|
1612
|
+
...(cleanupWarnings.length > 0 ? { cleanupWarnings } : {}),
|
|
1613
|
+
...(preserveExternalReview ? { preservedBorrowedReview: true, preservedExternalReview: true } : {}),
|
|
1614
|
+
},
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
async function runDismiss(deps, row) {
|
|
1618
|
+
// Legality restricts dismiss to a clean/retryable continuation. Reuse the
|
|
1619
|
+
// ownership-safe discard path; its external PR, head and tickets are borrowed.
|
|
1620
|
+
return runDiscard(deps, row, { removeNeedsReview: false });
|
|
1621
|
+
}
|
|
1622
|
+
async function runAcknowledgeNoChanges(deps, row) {
|
|
1623
|
+
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
1624
|
+
const cleanupWarnings = await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
1625
|
+
db: deps.db,
|
|
1626
|
+
git: deps.git,
|
|
1627
|
+
repoDir: deps.project.path,
|
|
1628
|
+
worktreeIds: snap.worktreeIds,
|
|
1629
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(snap.branches),
|
|
1630
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(snap.branches),
|
|
1631
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
1632
|
+
});
|
|
1633
|
+
// A fresh no-change branch is disposable only while Git still proves that it
|
|
1634
|
+
// has no commits ahead of the integration base. If the user added work after
|
|
1635
|
+
// settlement, preserve it and disclose the incomplete cleanup.
|
|
1636
|
+
for (const branch of ownedDeliveryBranches(row, snap, cleanupWarnings)) {
|
|
1637
|
+
if (!branch || branch === row.base_branch)
|
|
1638
|
+
continue;
|
|
1639
|
+
try {
|
|
1640
|
+
const ahead = await deps.git.run(['rev-list', '--count', `${row.base_branch}..${branch}`], deps.project.path);
|
|
1641
|
+
if (ahead.code !== 0 || Number.parseInt(ahead.stdout.trim(), 10) !== 0) {
|
|
1642
|
+
cleanupWarnings.push(`branch ${branch}: retained because no-change cleanup could not prove it has zero commits ahead of ${row.base_branch}`);
|
|
1643
|
+
continue;
|
|
495
1644
|
}
|
|
496
|
-
|
|
497
|
-
|
|
1645
|
+
const deleted = await deps.git.run(['branch', '-d', branch], deps.project.path);
|
|
1646
|
+
if (deleted.code !== 0) {
|
|
1647
|
+
cleanupWarnings.push(`branch ${branch}: ${(deleted.stderr.trim() || deleted.stdout.trim()).split('\n')[0] || `exit ${deleted.code}`}`);
|
|
498
1648
|
}
|
|
499
1649
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
continue;
|
|
503
|
-
await deps.git.run(['branch', '-D', branch], deps.project.path).catch(() => { });
|
|
1650
|
+
catch (err) {
|
|
1651
|
+
cleanupWarnings.push(`branch ${branch}: ${err instanceof Error ? err.message : String(err)}`);
|
|
504
1652
|
}
|
|
505
1653
|
}
|
|
506
|
-
const conflict =
|
|
1654
|
+
const conflict = casTransitionWithTicketEffect(deps, row, 'completed', {
|
|
1655
|
+
deliveryOutcome: 'no_changes',
|
|
1656
|
+
statusCode: cleanupWarnings.length > 0 ? 'cleanup_incomplete' : 'no_changes',
|
|
1657
|
+
cleanupWarnings,
|
|
1658
|
+
}, {
|
|
1659
|
+
deliveryId: row.id,
|
|
1660
|
+
ticketIds: snap.ticketIds,
|
|
1661
|
+
targetStatus: 'done',
|
|
1662
|
+
jiraAction: 'completed',
|
|
1663
|
+
prUrl: null,
|
|
1664
|
+
});
|
|
507
1665
|
if (conflict)
|
|
508
1666
|
return conflict;
|
|
1667
|
+
applyTerminalTicketEffect(deps, row, 'completed', cleanupWarnings);
|
|
509
1668
|
finalizeTransition(deps, row.id);
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
|
|
1669
|
+
return {
|
|
1670
|
+
status: 200,
|
|
1671
|
+
body: {
|
|
1672
|
+
ok: true,
|
|
1673
|
+
decision: 'completed',
|
|
1674
|
+
noChanges: true,
|
|
1675
|
+
...(cleanupWarnings.length > 0 ? { cleanupWarnings } : {}),
|
|
1676
|
+
},
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
async function settleMergedPr(deps, row) {
|
|
1680
|
+
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
1681
|
+
const cleanupWarnings = await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
1682
|
+
db: deps.db, git: deps.git, repoDir: deps.project.path,
|
|
1683
|
+
worktreeIds: releasableWorktreeIds(deps, snap), state: 'merged',
|
|
1684
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(snap.branches),
|
|
1685
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(snap.branches),
|
|
1686
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
1687
|
+
});
|
|
1688
|
+
await deleteOwnedBranchesIfUnchanged(deps, row, snap, cleanupWarnings);
|
|
1689
|
+
const conflict = casTransitionWithTicketEffect(deps, row, 'merged', {
|
|
1690
|
+
deliveryOutcome: 'delivered',
|
|
1691
|
+
statusCode: cleanupWarnings.length > 0 ? 'cleanup_incomplete' : 'merged',
|
|
1692
|
+
statusDetail: null,
|
|
1693
|
+
cleanupWarnings,
|
|
1694
|
+
}, {
|
|
1695
|
+
deliveryId: row.id,
|
|
1696
|
+
ticketIds: snap.ticketIds,
|
|
1697
|
+
targetStatus: 'done',
|
|
1698
|
+
jiraAction: 'merged',
|
|
1699
|
+
prUrl: row.pr_url,
|
|
1700
|
+
});
|
|
1701
|
+
if (conflict)
|
|
1702
|
+
return conflict;
|
|
1703
|
+
await releaseDeliveredRecoveryLineage(deps, row, row.delivery_sha);
|
|
1704
|
+
applyTerminalTicketEffect(deps, row, 'merged', cleanupWarnings);
|
|
1705
|
+
finalizeTransition(deps, row.id);
|
|
1706
|
+
return {
|
|
1707
|
+
status: 200,
|
|
1708
|
+
body: {
|
|
1709
|
+
ok: true,
|
|
1710
|
+
decision: 'merged',
|
|
1711
|
+
merged: true,
|
|
1712
|
+
prUrl: row.pr_url,
|
|
1713
|
+
...(row.delivery_sha ? {
|
|
1714
|
+
deliveryVerified: true,
|
|
1715
|
+
verifiedSha: row.delivery_sha,
|
|
1716
|
+
pushed: false,
|
|
1717
|
+
} : {}),
|
|
1718
|
+
},
|
|
1719
|
+
};
|
|
520
1720
|
}
|
|
521
1721
|
async function runPollMerge(deps, row) {
|
|
522
|
-
const
|
|
523
|
-
if (
|
|
524
|
-
return
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
1722
|
+
const observed = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, row.delivery_sha);
|
|
1723
|
+
if (!observed.ok)
|
|
1724
|
+
return { status: 502, body: { error: 'gh_failed', detail: observed.detail } };
|
|
1725
|
+
const { state, isDraft } = observed;
|
|
1726
|
+
if (!row.branch) {
|
|
1727
|
+
return persistMovedPrHead(deps, row, `the ${state.toLowerCase()} PR has no recorded delivery branch; refusing to infer recoverable work`);
|
|
528
1728
|
}
|
|
529
|
-
|
|
530
|
-
|
|
1729
|
+
if (!row.delivery_sha) {
|
|
1730
|
+
// A legacy OPEN row cannot be retried without an immutable object. Once the
|
|
1731
|
+
// attached PR is terminal, however, keeping that stale URL would strand the
|
|
1732
|
+
// only recorded branch behind Discard. Detach it so Create PR can perform
|
|
1733
|
+
// the existing one-time legacy ref capture, without claiming any delivery.
|
|
1734
|
+
if (state === 'CLOSED' || state === 'MERGED') {
|
|
1735
|
+
return rerouteFromStalePr(deps, row, `the previous PR is ${state.toLowerCase()} and this legacy delivery has no persisted verified SHA`, false);
|
|
1736
|
+
}
|
|
1737
|
+
return persistMovedPrHead(deps, row, 'the open PR has no persisted verified delivery SHA; refusing to infer delivery from a mutable branch');
|
|
531
1738
|
}
|
|
532
|
-
if (
|
|
533
|
-
|
|
534
|
-
return { status: 200, body: { ok: true, decision: row.decision, merged: false } };
|
|
1739
|
+
if (!(0, pr_lifecycle_1.matchesRecordedPrIdentity)(observed, row.branch, row.base_branch)) {
|
|
1740
|
+
return rerouteFromStalePr(deps, row, `the recorded PR is ${state.toLowerCase()} but no longer matches its original head/base identity`, observed.includesExpectedSha === true);
|
|
535
1741
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
branchSet.add(row.branch);
|
|
540
|
-
const succeededUnits = snap.branches.filter((b) => b.succeeded);
|
|
541
|
-
if (succeededUnits.length > 1) {
|
|
542
|
-
try {
|
|
543
|
-
branchSet.add((0, pr_naming_1.batchBranchNameFor)(loadPrTicketData(deps, succeededUnits.map((b) => b.ticketId))));
|
|
1742
|
+
if (state === 'CLOSED') {
|
|
1743
|
+
if (observed.includesExpectedSha !== true) {
|
|
1744
|
+
return rerouteFromStalePr(deps, row, 'the previous PR closed without the verified implementation commit', false);
|
|
544
1745
|
}
|
|
545
|
-
|
|
546
|
-
|
|
1746
|
+
return settleObservedClosedPr(deps, row, observed);
|
|
1747
|
+
}
|
|
1748
|
+
if (state === 'OPEN') {
|
|
1749
|
+
if (observed.includesExpectedSha !== true) {
|
|
1750
|
+
const detail = 'the open PR no longer exposes the verified implementation commit; Retry push is available and will use the preserved exact SHA';
|
|
1751
|
+
const result = persistRetryablePrObservationFailure(deps, row, detail);
|
|
1752
|
+
return {
|
|
1753
|
+
...result,
|
|
1754
|
+
body: {
|
|
1755
|
+
...result.body,
|
|
1756
|
+
deliveryVerified: false,
|
|
1757
|
+
verifiedSha: row.delivery_sha,
|
|
1758
|
+
remoteHeadSha: observed.headRefOid,
|
|
1759
|
+
},
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
// A successful reopen can be observed even if the explicit action lost its
|
|
1763
|
+
// follow-up `gh view` response. Polling heals pr_closed from remote truth.
|
|
1764
|
+
if (row.decision === 'pr_closed') {
|
|
1765
|
+
const next = isDraft ? 'pr_draft' : 'pr_ready';
|
|
1766
|
+
const conflict = casTransition(deps, row, next, {
|
|
1767
|
+
deliveryOutcome: 'delivered', statusCode: isDraft ? 'pr_draft_ready' : 'pr_ready',
|
|
1768
|
+
});
|
|
1769
|
+
if (conflict)
|
|
1770
|
+
return conflict;
|
|
1771
|
+
finalizeTransition(deps, row.id);
|
|
1772
|
+
return {
|
|
1773
|
+
status: 200,
|
|
1774
|
+
body: {
|
|
1775
|
+
ok: true,
|
|
1776
|
+
decision: next,
|
|
1777
|
+
merged: false,
|
|
1778
|
+
reopened: true,
|
|
1779
|
+
prUrl: row.pr_url,
|
|
1780
|
+
deliveryVerified: true,
|
|
1781
|
+
verifiedSha: row.delivery_sha,
|
|
1782
|
+
remoteHeadSha: observed.headRefOid,
|
|
1783
|
+
pushed: false,
|
|
1784
|
+
},
|
|
1785
|
+
};
|
|
547
1786
|
}
|
|
1787
|
+
return {
|
|
1788
|
+
status: 200,
|
|
1789
|
+
body: {
|
|
1790
|
+
ok: true,
|
|
1791
|
+
decision: row.decision,
|
|
1792
|
+
merged: false,
|
|
1793
|
+
deliveryVerified: true,
|
|
1794
|
+
verifiedSha: row.delivery_sha,
|
|
1795
|
+
remoteHeadSha: observed.headRefOid,
|
|
1796
|
+
pushed: false,
|
|
1797
|
+
},
|
|
1798
|
+
};
|
|
548
1799
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
if (!branch || branch === row.base_branch)
|
|
552
|
-
continue;
|
|
553
|
-
await deps.git.run(['branch', '-D', branch], deps.project.path).catch(() => { });
|
|
1800
|
+
if (state !== 'MERGED') {
|
|
1801
|
+
return { status: 502, body: { error: 'gh_failed', detail: `unexpected PR state: ${state}` } };
|
|
554
1802
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
1803
|
+
// A PR can merge just before a continuation push; GitHub may then accept a
|
|
1804
|
+
// later update to the head branch even though that object was never part of
|
|
1805
|
+
// the merge. Never move tickets to Done from state=MERGED alone.
|
|
1806
|
+
if (observed.includesExpectedSha !== true) {
|
|
1807
|
+
return rerouteFromStalePr(deps, row, mergedEvidenceDetail(observed), false);
|
|
1808
|
+
}
|
|
1809
|
+
return settleMergedPr(deps, row);
|
|
1810
|
+
}
|
|
1811
|
+
async function runReopen(deps, row) {
|
|
1812
|
+
if (!row.delivery_sha || !row.branch) {
|
|
1813
|
+
return rerouteFromStalePr(deps, row, 'the closed PR cannot be reopened safely because its immutable delivery SHA/head identity is unavailable', false);
|
|
1814
|
+
}
|
|
1815
|
+
const beforeReopen = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, row.delivery_sha);
|
|
1816
|
+
if (!beforeReopen.ok) {
|
|
1817
|
+
return { status: 502, body: { error: 'gh_failed', detail: beforeReopen.detail } };
|
|
1818
|
+
}
|
|
1819
|
+
if (!(0, pr_lifecycle_1.matchesRecordedPrIdentity)(beforeReopen, row.branch, row.base_branch) ||
|
|
1820
|
+
beforeReopen.includesExpectedSha !== true) {
|
|
1821
|
+
return rerouteFromStalePr(deps, row, 'the closed PR no longer proves the recorded head/base and verified implementation commit', false);
|
|
1822
|
+
}
|
|
1823
|
+
if (beforeReopen.state === 'MERGED')
|
|
1824
|
+
return settleMergedPr(deps, row);
|
|
1825
|
+
if (beforeReopen.state === 'OPEN') {
|
|
1826
|
+
const next = beforeReopen.isDraft ? 'pr_draft' : 'pr_ready';
|
|
1827
|
+
const conflict = casTransition(deps, row, next, {
|
|
1828
|
+
deliveryOutcome: 'delivered', statusCode: beforeReopen.isDraft ? 'pr_draft_ready' : 'pr_ready',
|
|
1829
|
+
statusDetail: null,
|
|
1830
|
+
});
|
|
1831
|
+
if (conflict)
|
|
1832
|
+
return conflict;
|
|
1833
|
+
finalizeTransition(deps, row.id);
|
|
1834
|
+
return {
|
|
1835
|
+
status: 200,
|
|
1836
|
+
body: {
|
|
1837
|
+
ok: true, decision: next, reopened: true, prUrl: row.pr_url,
|
|
1838
|
+
deliveryVerified: true, verifiedSha: row.delivery_sha,
|
|
1839
|
+
remoteHeadSha: beforeReopen.headRefOid, pushed: false,
|
|
1840
|
+
},
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
let reopened;
|
|
560
1844
|
try {
|
|
561
|
-
deps.
|
|
1845
|
+
reopened = await deps.exec.run('gh', ['pr', 'reopen', row.pr_url], deps.project.path);
|
|
562
1846
|
}
|
|
563
1847
|
catch (err) {
|
|
564
|
-
|
|
1848
|
+
reopened = { code: 1, stdout: '', stderr: err instanceof Error ? err.message : String(err) };
|
|
1849
|
+
}
|
|
1850
|
+
const observed = await (0, pr_lifecycle_1.observePrLifecycle)(deps.exec, deps.project.path, row.pr_url, row.delivery_sha);
|
|
1851
|
+
if (!observed.ok) {
|
|
1852
|
+
if (reopened.code !== 0)
|
|
1853
|
+
return ghFailed(reopened);
|
|
1854
|
+
return { status: 502, body: { error: 'gh_failed', detail: observed.detail } };
|
|
1855
|
+
}
|
|
1856
|
+
const identityMatches = (0, pr_lifecycle_1.matchesRecordedPrIdentity)(observed, row.branch, row.base_branch);
|
|
1857
|
+
if (observed.state === 'MERGED') {
|
|
1858
|
+
if (identityMatches && observed.includesExpectedSha === true)
|
|
1859
|
+
return settleMergedPr(deps, row);
|
|
1860
|
+
return rerouteFromStalePr(deps, row, identityMatches ? mergedEvidenceDetail(observed) : 'the PR identity changed while it was being reopened', false);
|
|
1861
|
+
}
|
|
1862
|
+
if (observed.state === 'CLOSED') {
|
|
1863
|
+
if (!identityMatches || observed.includesExpectedSha !== true) {
|
|
1864
|
+
return rerouteFromStalePr(deps, row, 'the PR remained closed without proving the recorded head/base and verified implementation commit', false);
|
|
1865
|
+
}
|
|
1866
|
+
if (reopened.code !== 0)
|
|
1867
|
+
return ghFailed(reopened);
|
|
1868
|
+
return { status: 502, body: { error: 'gh_failed', detail: 'PR remained closed after reopen' } };
|
|
565
1869
|
}
|
|
566
|
-
|
|
1870
|
+
if (!identityMatches || observed.includesExpectedSha !== true) {
|
|
1871
|
+
return rerouteFromStalePr(deps, row, 'the reopened PR no longer proves the recorded head/base and verified implementation commit', true);
|
|
1872
|
+
}
|
|
1873
|
+
const next = observed.isDraft ? 'pr_draft' : 'pr_ready';
|
|
1874
|
+
const conflict = casTransition(deps, row, next, {
|
|
1875
|
+
deliveryOutcome: 'delivered', statusCode: observed.isDraft ? 'pr_draft_ready' : 'pr_ready',
|
|
1876
|
+
statusDetail: null,
|
|
1877
|
+
});
|
|
1878
|
+
if (conflict)
|
|
1879
|
+
return conflict;
|
|
1880
|
+
finalizeTransition(deps, row.id);
|
|
1881
|
+
return {
|
|
1882
|
+
status: 200,
|
|
1883
|
+
body: {
|
|
1884
|
+
ok: true, decision: next, reopened: true, prUrl: row.pr_url,
|
|
1885
|
+
deliveryVerified: true, verifiedSha: row.delivery_sha,
|
|
1886
|
+
remoteHeadSha: observed.headRefOid, pushed: false,
|
|
1887
|
+
},
|
|
1888
|
+
};
|
|
567
1889
|
}
|
|
568
|
-
/**
|
|
569
|
-
* Remote-less acceptance: merge the delivery's branches into the integration
|
|
570
|
-
* branch DIRECTLY in the user's checkout. This is the one decision that touches
|
|
571
|
-
* the user's working tree, so it is triple-guarded and transactional-ish:
|
|
572
|
-
*
|
|
573
|
-
* - The checkout must have the integration branch checked out (a branch can
|
|
574
|
-
* only be checked out in one worktree — merging via a temp worktree is
|
|
575
|
-
* impossible while the user holds it) → 409 `merge_local_blocked` otherwise.
|
|
576
|
-
* - The working tree must be CLEAN → 409 `merge_local_blocked` otherwise.
|
|
577
|
-
* - Merge = the assembled head when one exists (row.branch), else each
|
|
578
|
-
* succeeded unit branch sequentially, `--no-ff --no-edit`. Any conflict →
|
|
579
|
-
* `merge --abort` + 502 `merge_failed`, NO transition (retry or discard).
|
|
580
|
-
*
|
|
581
|
-
* Success mirrors poll-merge's MERGED arm: decision → merged (prUrl stays
|
|
582
|
-
* null), worktrees/branches swept, tickets → done, Jira onRailMerged(null).
|
|
583
|
-
*/
|
|
584
1890
|
async function runMergeLocal(deps, row) {
|
|
1891
|
+
return (0, repo_lock_1.withRepoLock)(deps.project.path, () => runMergeLocalLocked(deps, row));
|
|
1892
|
+
}
|
|
1893
|
+
async function runMergeLocalLocked(deps, row) {
|
|
1894
|
+
deps.assertAdmission?.();
|
|
585
1895
|
const snap = (0, rail_pr_store_1.toPrDeliverySnapshot)(row);
|
|
586
|
-
|
|
1896
|
+
const cleanupWarnings = [];
|
|
1897
|
+
// Snapshot the checkout the user authorized. The same three invariants are
|
|
1898
|
+
// revalidated immediately before the one final fast-forward.
|
|
587
1899
|
const head = await deps.git.run(['rev-parse', '--abbrev-ref', 'HEAD'], deps.project.path);
|
|
588
1900
|
const currentBranch = head.code === 0 ? head.stdout.trim() : '';
|
|
589
1901
|
if (currentBranch !== row.base_branch) {
|
|
@@ -596,78 +1908,165 @@ async function runMergeLocal(deps, row) {
|
|
|
596
1908
|
if (status.code !== 0 || status.stdout.trim() !== '') {
|
|
597
1909
|
return { status: 409, body: { error: 'merge_local_blocked', reason: 'dirty', base: row.base_branch } };
|
|
598
1910
|
}
|
|
599
|
-
|
|
600
|
-
|
|
1911
|
+
const startingHead = await deps.git.run(['rev-parse', '--verify', 'HEAD'], deps.project.path);
|
|
1912
|
+
const startingSha = startingHead.code === 0 ? startingHead.stdout.trim() : '';
|
|
1913
|
+
if (!/^[0-9a-f]{40,64}$/i.test(startingSha)) {
|
|
1914
|
+
return { status: 409, body: { error: 'merge_local_blocked', reason: 'unresolved_head', base: row.base_branch } };
|
|
1915
|
+
}
|
|
1916
|
+
// What to merge: immutable object ids only. The assembled head carries every
|
|
1917
|
+
// unit already; without one, merge each settled unit's exact final SHA.
|
|
601
1918
|
let toMerge;
|
|
602
|
-
|
|
603
|
-
|
|
1919
|
+
let deliveryHeadSha = null;
|
|
1920
|
+
if (row.delivery_sha && await commitObjectExists(deps, row.delivery_sha)) {
|
|
1921
|
+
deliveryHeadSha = row.delivery_sha;
|
|
1922
|
+
}
|
|
1923
|
+
else if (row.branch) {
|
|
1924
|
+
deliveryHeadSha = await captureBranchSha(deps, row.branch);
|
|
1925
|
+
}
|
|
1926
|
+
if (deliveryHeadSha) {
|
|
1927
|
+
toMerge = [deliveryHeadSha];
|
|
604
1928
|
}
|
|
605
1929
|
else {
|
|
606
1930
|
toMerge = [];
|
|
607
1931
|
for (const unit of snap.branches.filter((b) => b.succeeded)) {
|
|
608
|
-
let
|
|
609
|
-
if (
|
|
610
|
-
|
|
611
|
-
|
|
1932
|
+
let sourceSha = unit.finalSha && COMMIT_SHA_RE.test(unit.finalSha) ? unit.finalSha : null;
|
|
1933
|
+
if (sourceSha) {
|
|
1934
|
+
if (!(await commitObjectExists(deps, sourceSha)))
|
|
1935
|
+
sourceSha = null;
|
|
1936
|
+
}
|
|
1937
|
+
else {
|
|
1938
|
+
sourceSha = await captureBranchSha(deps, unit.branch);
|
|
1939
|
+
}
|
|
1940
|
+
if (!sourceSha) {
|
|
612
1941
|
return {
|
|
613
1942
|
status: 502,
|
|
614
|
-
body: { error: 'merge_failed', detail: `
|
|
1943
|
+
body: { error: 'merge_failed', detail: `verified commit for '${unit.branch}' (ticket #${unit.ticketId}) is unavailable` },
|
|
615
1944
|
};
|
|
616
1945
|
}
|
|
617
|
-
toMerge.push(
|
|
1946
|
+
toMerge.push(sourceSha);
|
|
618
1947
|
}
|
|
619
1948
|
}
|
|
620
1949
|
if (toMerge.length === 0) {
|
|
621
1950
|
return { status: 502, body: { error: 'merge_failed', detail: 'no succeeded branch to merge' } };
|
|
622
1951
|
}
|
|
1952
|
+
// Assemble every merge away from the user's checkout. A conflict can only
|
|
1953
|
+
// dirty this disposable detached worktree, never the integration branch.
|
|
1954
|
+
const safeId = row.id.replace(/[^A-Za-z0-9-]/g, '').slice(0, 64) || 'delivery';
|
|
1955
|
+
const assemblyPath = path.join(deps.assemblyRoot ?? batchWorktreeRoot(deps.project.slug), `local-merge-${safeId}-${(0, ids_1.newId)()}`);
|
|
1956
|
+
const added = await deps.git.run(['worktree', 'add', '--detach', assemblyPath, startingSha], deps.project.path);
|
|
1957
|
+
if (added.code !== 0) {
|
|
1958
|
+
const detail = (added.stderr.trim() || added.stdout.trim()).split('\n')[0] || `exit ${added.code}`;
|
|
1959
|
+
return { status: 502, body: { error: 'merge_failed', detail: `creating isolated assembly: ${detail}` } };
|
|
1960
|
+
}
|
|
1961
|
+
const removeAssembly = async () => {
|
|
1962
|
+
try {
|
|
1963
|
+
const removed = await deps.git.run(['worktree', 'remove', '--force', assemblyPath], deps.project.path);
|
|
1964
|
+
if (removed.code !== 0) {
|
|
1965
|
+
cleanupWarnings.push(`assembly worktree ${assemblyPath}: ${(removed.stderr.trim() || removed.stdout.trim()).split('\n')[0] || `exit ${removed.code}`}`);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
catch (err) {
|
|
1969
|
+
cleanupWarnings.push(`assembly worktree ${assemblyPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
const persistAssemblyFailure = (detail) => {
|
|
1973
|
+
const conflict = casTransition(deps, row, row.decision, {
|
|
1974
|
+
deliveryOutcome: 'blocked', statusCode: 'delivery_failed', statusDetail: detail, cleanupWarnings,
|
|
1975
|
+
});
|
|
1976
|
+
if (conflict)
|
|
1977
|
+
return conflict;
|
|
1978
|
+
finalizeTransition(deps, row.id);
|
|
1979
|
+
return null;
|
|
1980
|
+
};
|
|
623
1981
|
for (const branch of toMerge) {
|
|
624
|
-
const r = await deps.git.run(['merge', '--no-ff', '--no-edit', branch],
|
|
1982
|
+
const r = await deps.git.run(['merge', '--no-ff', '--no-edit', branch], assemblyPath);
|
|
625
1983
|
if (r.code !== 0) {
|
|
626
|
-
|
|
1984
|
+
try {
|
|
1985
|
+
const aborted = await deps.git.run(['merge', '--abort'], assemblyPath);
|
|
1986
|
+
if (aborted.code !== 0)
|
|
1987
|
+
cleanupWarnings.push(`assembly abort ${branch}: exit ${aborted.code}`);
|
|
1988
|
+
}
|
|
1989
|
+
catch (err) {
|
|
1990
|
+
cleanupWarnings.push(`assembly abort ${branch}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1991
|
+
}
|
|
1992
|
+
await removeAssembly();
|
|
627
1993
|
const detail = (r.stderr.trim() || r.stdout.trim()).split('\n')[0] || `exit ${r.code}`;
|
|
1994
|
+
const conflict = persistAssemblyFailure(`merging '${branch}': ${detail}`);
|
|
1995
|
+
if (conflict)
|
|
1996
|
+
return conflict;
|
|
628
1997
|
return { status: 502, body: { error: 'merge_failed', detail: `merging '${branch}': ${detail}` } };
|
|
629
1998
|
}
|
|
630
1999
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
2000
|
+
const assembled = await deps.git.run(['rev-parse', '--verify', 'HEAD'], assemblyPath);
|
|
2001
|
+
const assembledSha = assembled.code === 0 ? assembled.stdout.trim() : '';
|
|
2002
|
+
if (!/^[0-9a-f]{40,64}$/i.test(assembledSha)) {
|
|
2003
|
+
await removeAssembly();
|
|
2004
|
+
const detail = 'isolated assembly produced no verifiable HEAD';
|
|
2005
|
+
const conflict = persistAssemblyFailure(detail);
|
|
2006
|
+
if (conflict)
|
|
2007
|
+
return conflict;
|
|
2008
|
+
return { status: 502, body: { error: 'merge_failed', detail } };
|
|
2009
|
+
}
|
|
2010
|
+
const [finalBranch, finalStatus, finalHead] = await Promise.all([
|
|
2011
|
+
deps.git.run(['rev-parse', '--abbrev-ref', 'HEAD'], deps.project.path),
|
|
2012
|
+
deps.git.run(['status', '--porcelain'], deps.project.path),
|
|
2013
|
+
deps.git.run(['rev-parse', '--verify', 'HEAD'], deps.project.path),
|
|
2014
|
+
]);
|
|
2015
|
+
const changedReason = finalBranch.code !== 0 || finalBranch.stdout.trim() !== row.base_branch
|
|
2016
|
+
? 'wrong_branch'
|
|
2017
|
+
: finalStatus.code !== 0 || finalStatus.stdout.trim() !== ''
|
|
2018
|
+
? 'dirty'
|
|
2019
|
+
: finalHead.code !== 0 || finalHead.stdout.trim() !== startingSha
|
|
2020
|
+
? 'head_changed'
|
|
2021
|
+
: null;
|
|
2022
|
+
if (changedReason) {
|
|
2023
|
+
await removeAssembly();
|
|
2024
|
+
if (cleanupWarnings.length > 0) {
|
|
2025
|
+
const conflict = casTransition(deps, row, row.decision, { cleanupWarnings });
|
|
2026
|
+
if (conflict)
|
|
2027
|
+
return conflict;
|
|
2028
|
+
finalizeTransition(deps, row.id);
|
|
651
2029
|
}
|
|
652
|
-
|
|
653
|
-
(0, rail_worktrees_store_1.updateRailWorktreeState)(deps.db, wt.id, 'merged');
|
|
2030
|
+
return { status: 409, body: { error: 'merge_local_blocked', reason: changedReason, base: row.base_branch } };
|
|
654
2031
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
2032
|
+
const advanced = await deps.git.run(['merge', '--ff-only', assembledSha], deps.project.path);
|
|
2033
|
+
if (advanced.code !== 0) {
|
|
2034
|
+
await removeAssembly();
|
|
2035
|
+
const detail = (advanced.stderr.trim() || advanced.stdout.trim()).split('\n')[0] || `exit ${advanced.code}`;
|
|
2036
|
+
const conflict = persistAssemblyFailure(`advancing '${row.base_branch}': ${detail}`);
|
|
2037
|
+
if (conflict)
|
|
2038
|
+
return conflict;
|
|
2039
|
+
return { status: 502, body: { error: 'merge_failed', detail: `advancing '${row.base_branch}': ${detail}` } };
|
|
659
2040
|
}
|
|
660
|
-
|
|
2041
|
+
await removeAssembly();
|
|
2042
|
+
// Post-advance sweep: the work now lives on
|
|
2043
|
+
// the integration branch, so the launch's worktrees + branches are spent.
|
|
2044
|
+
cleanupWarnings.push(...await (0, rail_worktree_release_1.releaseRailWorktrees)({
|
|
2045
|
+
db: deps.db,
|
|
2046
|
+
git: deps.git,
|
|
2047
|
+
repoDir: deps.project.path,
|
|
2048
|
+
worktreeIds: releasableWorktreeIds(deps, snap),
|
|
2049
|
+
state: 'merged',
|
|
2050
|
+
expectedHeadByBranch: (0, rail_worktree_release_1.durableBranchHeads)(snap.branches),
|
|
2051
|
+
overlayEvidenceByBranch: (0, rail_worktree_release_1.durableOverlayCleanupEvidence)(snap.branches),
|
|
2052
|
+
onSafetyArchive: safetyArchiveRecorder(deps, row),
|
|
2053
|
+
}));
|
|
2054
|
+
await deleteOwnedBranchesIfUnchanged(deps, row, snap, cleanupWarnings);
|
|
2055
|
+
const conflict = casTransitionWithTicketEffect(deps, row, 'merged', {
|
|
2056
|
+
deliveryOutcome: 'delivered',
|
|
2057
|
+
statusCode: cleanupWarnings.length > 0 ? 'cleanup_incomplete' : 'merged',
|
|
2058
|
+
cleanupWarnings,
|
|
2059
|
+
}, {
|
|
2060
|
+
deliveryId: row.id,
|
|
2061
|
+
ticketIds: snap.ticketIds,
|
|
2062
|
+
targetStatus: 'done',
|
|
2063
|
+
jiraAction: 'merged',
|
|
2064
|
+
prUrl: null,
|
|
2065
|
+
});
|
|
661
2066
|
if (conflict)
|
|
662
2067
|
return conflict;
|
|
2068
|
+
applyTerminalTicketEffect(deps, row, 'merged', cleanupWarnings);
|
|
663
2069
|
finalizeTransition(deps, row.id);
|
|
664
|
-
const changed = applyTicketTransition(deps, snap.ticketIds, 'done');
|
|
665
|
-
try {
|
|
666
|
-
deps.jiraSyncManager?.onRailMerged(changed, row.id, null);
|
|
667
|
-
}
|
|
668
|
-
catch (err) {
|
|
669
|
-
console.error('[rail-pr-decision] jira onRailMerged (local) failed:', err);
|
|
670
|
-
}
|
|
671
2070
|
return { status: 200, body: { ok: true, decision: 'merged', merged: true, local: true } };
|
|
672
2071
|
}
|
|
673
2072
|
function resolveTicketFile(deps) {
|
|
@@ -676,44 +2075,3 @@ function resolveTicketFile(deps) {
|
|
|
676
2075
|
const exec = (0, workspace_resolution_1.resolveProjectExecution)({ slug: deps.project.slug, path: deps.project.path });
|
|
677
2076
|
return exec.relocated ? exec.ticketsPath : (0, ticket_store_1.resolveTicketStoragePath)(deps.project.path);
|
|
678
2077
|
}
|
|
679
|
-
/**
|
|
680
|
-
* Move the launch's on_review tickets to `todo` (discard) or `done` (merged),
|
|
681
|
-
* broadcasting ticket_updated per changed spec — mirroring onLoopRunFinished's
|
|
682
|
-
* revert style in project-registry. ONLY tickets still parked at on_review move
|
|
683
|
-
* (a manually re-triaged spec is respected). Best-effort: a ticket-store
|
|
684
|
-
* failure is logged, never fatal (the decision row already transitioned).
|
|
685
|
-
*/
|
|
686
|
-
function applyTicketTransition(deps, ticketIds, to) {
|
|
687
|
-
const changed = [];
|
|
688
|
-
if (ticketIds.length === 0)
|
|
689
|
-
return changed;
|
|
690
|
-
try {
|
|
691
|
-
const ticketFile = resolveTicketFile(deps);
|
|
692
|
-
const now = new Date().toISOString();
|
|
693
|
-
const store = (0, ticket_store_1.mutateStore)(ticketFile, (s) => {
|
|
694
|
-
for (const tid of ticketIds) {
|
|
695
|
-
const ticket = s.tickets[String(tid)];
|
|
696
|
-
if (!ticket || ticket.status !== 'on_review')
|
|
697
|
-
continue;
|
|
698
|
-
ticket.status = to;
|
|
699
|
-
ticket.updated_at = now;
|
|
700
|
-
changed.push(tid);
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
for (const tid of changed) {
|
|
704
|
-
const ticket = store.tickets[String(tid)];
|
|
705
|
-
if (!ticket)
|
|
706
|
-
continue;
|
|
707
|
-
deps.broadcast({
|
|
708
|
-
type: 'ticket_updated',
|
|
709
|
-
ticket: ticket,
|
|
710
|
-
projectId: deps.project.id,
|
|
711
|
-
timestamp: ticket.updated_at,
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
catch (err) {
|
|
716
|
-
console.error('[rail-pr-decision] failed to apply ticket transition:', err);
|
|
717
|
-
}
|
|
718
|
-
return changed;
|
|
719
|
-
}
|