execution.mojo (1112B)
1 from std.collections import Optional 2 3 4 @fieldwise_init 5 struct ExecutionMeta(Copyable, Movable): 6 var status: String 7 var provider_calls: Int 8 var model: Optional[String] 9 var question_bundle: Optional[String] 10 var degraded_reason: Optional[String] 11 12 13 def execution_meta( 14 status: String, 15 provider_calls: Int, 16 model: Optional[String], 17 question_bundle: Optional[String], 18 degraded_reason: Optional[String], 19 ) raises -> ExecutionMeta: 20 if status != "complete" and status != "degraded" and status != "failed": 21 raise Error("execution status must be complete, degraded or failed") 22 if provider_calls < 0: 23 raise Error("provider call count must be non-negative") 24 if status == "degraded" and not degraded_reason: 25 raise Error("degraded execution requires a reason") 26 return ExecutionMeta( 27 status=String(status), 28 provider_calls=provider_calls, 29 model=model.copy(), 30 question_bundle=question_bundle.copy(), 31 degraded_reason=degraded_reason.copy(), 32 ) 33 34 35 def execution_is_business_outcome() -> Bool: 36 return False