@@ -8,9 +8,6 @@ mod runner;
88mod verifier;
99
1010pub use engine:: ExecutionEngine ;
11- pub use queue:: ExecutionQueue ;
12- pub use runner:: TaskRunner ;
13- pub use verifier:: InstanceVerifier ;
1411
1512use serde:: { Deserialize , Serialize } ;
1613use std:: collections:: HashMap ;
@@ -78,81 +75,90 @@ pub struct ExecutionResult {
7875 pub error : Option < String > ,
7976}
8077
81- impl ExecutionResult {
82- /// Create a successful result
83- pub fn success (
84- execution_id : & str ,
85- task_id : & str ,
86- agent_stdout : String ,
87- agent_stderr : String ,
88- agent_exit_code : i32 ,
89- agent_duration_ms : u64 ,
90- test_stdout : String ,
91- test_stderr : String ,
92- total_duration_ms : u64 ,
93- ) -> Self {
78+ /// Builder for execution results
79+ #[ derive( Debug , Clone , Default ) ]
80+ pub struct ExecutionResultBuilder {
81+ execution_id : String ,
82+ task_id : String ,
83+ passed : bool ,
84+ agent_stdout : String ,
85+ agent_stderr : String ,
86+ agent_exit_code : i32 ,
87+ agent_duration_ms : u64 ,
88+ test_stdout : String ,
89+ test_stderr : String ,
90+ test_exit_code : i32 ,
91+ total_duration_ms : u64 ,
92+ error : Option < String > ,
93+ }
94+
95+ impl ExecutionResultBuilder {
96+ pub fn new ( execution_id : & str , task_id : & str ) -> Self {
9497 Self {
9598 execution_id : execution_id. to_string ( ) ,
9699 task_id : task_id. to_string ( ) ,
97- passed : true ,
98- agent_stdout,
99- agent_stderr,
100- agent_exit_code,
101- agent_duration_ms,
102- test_stdout,
103- test_stderr,
104- test_exit_code : 0 ,
105- total_duration_ms,
106- error : None ,
100+ ..Default :: default ( )
107101 }
108102 }
109103
110- /// Create a failed result
111- pub fn failure (
112- execution_id : & str ,
113- task_id : & str ,
114- agent_stdout : String ,
115- agent_stderr : String ,
116- agent_exit_code : i32 ,
117- agent_duration_ms : u64 ,
118- test_stdout : String ,
119- test_stderr : String ,
120- test_exit_code : i32 ,
121- total_duration_ms : u64 ,
122- error : Option < String > ,
123- ) -> Self {
124- Self {
125- execution_id : execution_id. to_string ( ) ,
126- task_id : task_id. to_string ( ) ,
127- passed : false ,
128- agent_stdout,
129- agent_stderr,
130- agent_exit_code,
131- agent_duration_ms,
132- test_stdout,
133- test_stderr,
134- test_exit_code,
135- total_duration_ms,
136- error,
104+ pub fn passed ( mut self , passed : bool ) -> Self {
105+ self . passed = passed;
106+ self
107+ }
108+
109+ pub fn agent_output ( mut self , stdout : String , stderr : String , exit_code : i32 ) -> Self {
110+ self . agent_stdout = stdout;
111+ self . agent_stderr = stderr;
112+ self . agent_exit_code = exit_code;
113+ self
114+ }
115+
116+ pub fn agent_duration ( mut self , ms : u64 ) -> Self {
117+ self . agent_duration_ms = ms;
118+ self
119+ }
120+
121+ pub fn test_output ( mut self , stdout : String , stderr : String , exit_code : i32 ) -> Self {
122+ self . test_stdout = stdout;
123+ self . test_stderr = stderr;
124+ self . test_exit_code = exit_code;
125+ self
126+ }
127+
128+ pub fn total_duration ( mut self , ms : u64 ) -> Self {
129+ self . total_duration_ms = ms;
130+ self
131+ }
132+
133+ pub fn error ( mut self , error : String ) -> Self {
134+ self . error = Some ( error) ;
135+ self
136+ }
137+
138+ pub fn build ( self ) -> ExecutionResult {
139+ ExecutionResult {
140+ execution_id : self . execution_id ,
141+ task_id : self . task_id ,
142+ passed : self . passed ,
143+ agent_stdout : self . agent_stdout ,
144+ agent_stderr : self . agent_stderr ,
145+ agent_exit_code : self . agent_exit_code ,
146+ agent_duration_ms : self . agent_duration_ms ,
147+ test_stdout : self . test_stdout ,
148+ test_stderr : self . test_stderr ,
149+ test_exit_code : self . test_exit_code ,
150+ total_duration_ms : self . total_duration_ms ,
151+ error : self . error ,
137152 }
138153 }
154+ }
139155
156+ impl ExecutionResult {
140157 /// Create an error result
141- pub fn error ( execution_id : & str , task_id : & str , error : String ) -> Self {
142- Self {
143- execution_id : execution_id. to_string ( ) ,
144- task_id : task_id. to_string ( ) ,
145- passed : false ,
146- agent_stdout : String :: new ( ) ,
147- agent_stderr : String :: new ( ) ,
148- agent_exit_code : -1 ,
149- agent_duration_ms : 0 ,
150- test_stdout : String :: new ( ) ,
151- test_stderr : String :: new ( ) ,
152- test_exit_code : -1 ,
153- total_duration_ms : 0 ,
154- error : Some ( error) ,
155- }
158+ pub fn error_result ( execution_id : & str , task_id : & str , error : String ) -> Self {
159+ ExecutionResultBuilder :: new ( execution_id, task_id)
160+ . error ( error)
161+ . build ( )
156162 }
157163}
158164
0 commit comments