scientific_workflow/runtime/error.rs
1//! Active runtime failures.
2
3use std::path::PathBuf;
4use std::time::Duration;
5
6use thiserror::Error;
7
8/// A failure after an immutable study passed preflight.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum RuntimeError {
12 /// Runtime could not create the required study-wide compute pool.
13 #[error("failed to create the Workflow compute pool with {threads} threads")]
14 ComputePool {
15 /// Exact worker count authored in `wf_configs/study.json`.
16 threads: usize,
17 /// Rayon pool-construction failure.
18 #[source]
19 source: rayon::ThreadPoolBuildError,
20 },
21
22 /// Interactive UI requested cooperative cancellation of the execution.
23 #[error("workflow execution was cancelled by the user")]
24 ExecutionCancelled,
25
26 /// Runtime could not create an inferred execution or replicate scope.
27 #[error("failed to create inferred output scope `{path}`")]
28 OutputScope {
29 /// Intended output location.
30 path: PathBuf,
31 /// Underlying filesystem failure.
32 #[source]
33 source: std::io::Error,
34 },
35
36 /// An execution-unit or program invocation returned an application, process, state,
37 /// observation, or persistence error.
38 #[error("task `{task}` failed: {source}")]
39 Task {
40 /// Inferred task identity.
41 task: String,
42 /// Original task failure.
43 #[source]
44 source: Box<dyn std::error::Error + Send + Sync + 'static>,
45 },
46
47 /// A task invocation panicked. Runtime fails any active member recording
48 /// before reporting this stable task identity.
49 #[error("task `{task}` panicked")]
50 TaskPanicked {
51 /// Inferred task identity.
52 task: String,
53 },
54
55 /// A task exceeded its timeout; execution units stop cooperatively while external
56 /// programs are terminated by Runtime.
57 #[error("task `{task}` exceeded its timeout of {timeout:?}")]
58 TaskTimedOut {
59 /// Inferred task identity.
60 task: String,
61 /// Effective timeout.
62 timeout: Duration,
63 },
64
65 /// A running task stopped because Runtime cancelled it. Execution units stop
66 /// cooperatively while external programs are terminated.
67 #[error("task `{task}` was cancelled")]
68 TaskCancelled {
69 /// Inferred task identity.
70 task: String,
71 },
72
73 /// A phase exceeded its timeout. Its active execution-unit tasks stop cooperatively
74 /// and its active external programs are terminated.
75 #[error("phase `{phase}` exceeded its timeout of {timeout:?}")]
76 PhaseTimedOut {
77 /// Stable phase key.
78 phase: String,
79 /// Effective timeout.
80 timeout: Duration,
81 },
82
83 /// Runtime could not start an operating-system worker thread.
84 #[error("failed to start runtime worker for `{scope}`")]
85 StartWorker {
86 /// Task or replicate identity.
87 scope: String,
88 /// Thread creation failure.
89 #[source]
90 source: std::io::Error,
91 },
92
93 /// A replicate worker panicked.
94 #[error("replicate {index} panicked")]
95 ReplicatePanicked {
96 /// Zero-based replicate index.
97 index: u64,
98 },
99
100 /// A replicate failed under either failure policy.
101 #[error("replicate {index} failed: {source}")]
102 Replicate {
103 /// Zero-based failed replicate index.
104 index: u64,
105 /// Original runtime failure.
106 #[source]
107 source: Box<RuntimeError>,
108 },
109}