@@ -714,17 +714,55 @@ describe('AutomationEngine', () => {
714714 expect ( resumed . error ) . toContain ( "Flow 'vanishing_flow' not found for run" ) ;
715715 } ) ;
716716
717- it ( 'should report a resume whose suspended node was edited away as RUN_NOT_FOUND' , async ( ) => {
717+ // [#28405] Re-judged: a run resumes on the body it started on, so a
718+ // republish that drops its parked node no longer ends it. The
719+ // RUN_NOT_FOUND answer stays for a body that is truly gone: here the
720+ // flow is withdrawn (which forgets every body this process held) and
721+ // a different body registered, with no metadata history attached.
722+ it ( 'should finish a run whose parked node a republish dropped on the body it started on' , async ( ) => {
718723 const captured : { runId ?: unknown } = { } ;
719724 registerPausingNode ( captured ) ;
720- const nodes = [
721- { id : 'start' , type : 'start' , label : 'Start' } ,
722- { id : 'pause' , type : 'pause_node' , label : 'Pause' } ,
723- { id : 'end' , type : 'end' , label : 'End' } ,
725+ const edges = [
726+ { id : 'e1' , source : 'start' , target : 'pause' } ,
727+ { id : 'e2' , source : 'pause' , target : 'end' } ,
724728 ] ;
725729 engine . registerFlow ( 'edited_flow' , {
726730 name : 'edited_flow' , label : 'Edited Flow' , type : 'autolaunched' ,
727- nodes,
731+ nodes : [
732+ { id : 'start' , type : 'start' , label : 'Start' } ,
733+ { id : 'pause' , type : 'pause_node' , label : 'Pause' } ,
734+ { id : 'end' , type : 'end' , label : 'End' } ,
735+ ] ,
736+ edges,
737+ } ) ;
738+
739+ const paused = await engine . execute ( 'edited_flow' ) ;
740+ expect ( paused . status ) . toBe ( 'paused' ) ;
741+ // The author republishes the flow without the node the run is
742+ // parked on.
743+ engine . registerFlow ( 'edited_flow' , {
744+ name : 'edited_flow' , label : 'Edited Flow' , type : 'autolaunched' ,
745+ nodes : [
746+ { id : 'start' , type : 'start' , label : 'Start' } ,
747+ { id : 'end' , type : 'end' , label : 'End' } ,
748+ ] ,
749+ edges : [ { id : 'e1' , source : 'start' , target : 'end' } ] ,
750+ } ) ;
751+
752+ const resumed = await engine . resume ( paused . runId ! ) ;
753+ expect ( resumed . success , JSON . stringify ( resumed ) ) . toBe ( true ) ;
754+ } ) ;
755+
756+ it ( 'should report a resume whose parked node is gone and whose pinned body is unrecoverable as RUN_NOT_FOUND' , async ( ) => {
757+ const captured : { runId ?: unknown } = { } ;
758+ registerPausingNode ( captured ) ;
759+ engine . registerFlow ( 'edited_flow' , {
760+ name : 'edited_flow' , label : 'Edited Flow' , type : 'autolaunched' ,
761+ nodes : [
762+ { id : 'start' , type : 'start' , label : 'Start' } ,
763+ { id : 'pause' , type : 'pause_node' , label : 'Pause' } ,
764+ { id : 'end' , type : 'end' , label : 'End' } ,
765+ ] ,
728766 edges : [
729767 { id : 'e1' , source : 'start' , target : 'pause' } ,
730768 { id : 'e2' , source : 'pause' , target : 'end' } ,
@@ -733,8 +771,10 @@ describe('AutomationEngine', () => {
733771
734772 const paused = await engine . execute ( 'edited_flow' ) ;
735773 expect ( paused . status ) . toBe ( 'paused' ) ;
736- // The author republishes the flow without the node the run is
737- // parked on — the pause can never continue.
774+ // The body the run started on is gone from this process (no
775+ // metadata history is attached), and the one registered now has
776+ // no node the pause can continue from.
777+ engine . withdrawFlow ( 'edited_flow' ) ;
738778 engine . registerFlow ( 'edited_flow' , {
739779 name : 'edited_flow' , label : 'Edited Flow' , type : 'autolaunched' ,
740780 nodes : [
0 commit comments