escher-execution-engine 0.1.2

Production-ready async execution engine for system commands
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
# Execution Engine API Reference

**Crate**: `cloudops-execution-engine`
**Version**: 0.1.0

Complete API documentation for the Execution Engine module.

---

## Table of Contents

- [Core API]#core-api
  - [ExecutionEngine]#executionengine
  - [ExecutionConfig]#executionconfig
- [Execution Types]#execution-types
  - [ExecutionRequest]#executionrequest
  - [ExecutionPlan]#executionplan
  - [Command]#command
  - [ExecutionStrategy]#executionstrategy
- [Result Types]#result-types
  - [ExecutionResult]#executionresult
  - [PlanExecutionResult]#planexecutionresult
  - [ExecutionStatus]#executionstatus
- [Event System]#event-system
  - [EventHandler]#eventhandler
  - [ExecutionEvent]#executionevent
- [Error Types]#error-types
  - [ExecutionError]#executionerror
  - [ValidationError]#validationerror
- [Metadata Types]#metadata-types

---

## Core API

### ExecutionEngine

Main entry point for command execution.

```rust
pub struct ExecutionEngine {
    config: ExecutionConfig,
    executions: Arc<RwLock<HashMap<Uuid, ExecutionState>>>,
    event_handler: Option<Arc<dyn EventHandler>>,
}
```

#### Constructor

##### `new`

```rust
pub fn new(config: ExecutionConfig) -> Self
```

Create a new execution engine with the given configuration.

**Parameters:**
- `config`: ExecutionConfig - Configuration for the engine

**Returns:** ExecutionEngine instance

**Example:**
```rust
let engine = ExecutionEngine::new(ExecutionConfig::default());
```

##### `with_event_handler`

```rust
pub fn with_event_handler(
    self,
    handler: Arc<dyn EventHandler>
) -> Self
```

Add a custom event handler for real-time updates.

**Parameters:**
- `handler`: Arc<dyn EventHandler> - Event handler implementation

**Returns:** Modified ExecutionEngine instance

**Example:**
```rust
let engine = ExecutionEngine::new(config)
    .with_event_handler(Arc::new(MyEventHandler));
```

#### Execution Methods

##### `execute`

```rust
pub async fn execute(
    &self,
    request: ExecutionRequest
) -> Result<Uuid, ExecutionError>
```

Execute a single command in the background.

**Parameters:**
- `request`: ExecutionRequest - Command execution request

**Returns:**
- `Ok(Uuid)`: Execution ID for tracking
- `Err(ExecutionError)`: Validation or execution error

**Example:**
```rust
let request = ExecutionRequest {
    id: Uuid::new_v4(),
    command: Command::AwsCli {
        service: "ec2".to_string(),
        operation: "describe-instances".to_string(),
        args: vec![],
        profile: Some("prod".to_string()),
        region: Some("us-west-2".to_string()),
    },
    env: HashMap::new(),
    working_dir: None,
    timeout_ms: None,
    metadata: Default::default(),
};

let execution_id = engine.execute(request).await?;
```

##### `execute_plan`

```rust
pub async fn execute_plan(
    &self,
    plan: ExecutionPlan
) -> Result<Uuid, ExecutionError>
```

Execute multiple commands according to a plan (serial, parallel, or dependency-based).

**Parameters:**
- `plan`: ExecutionPlan - Execution plan with multiple commands

**Returns:**
- `Ok(Uuid)`: Plan execution ID for tracking
- `Err(ExecutionError)`: Validation or execution error

**Example:**
```rust
let plan = ExecutionPlan {
    id: Uuid::new_v4(),
    description: "Deploy application".to_string(),
    strategy: ExecutionStrategy::Serial {
        stop_on_error: true,
    },
    commands: vec![request1, request2, request3],
    metadata: Default::default(),
};

let plan_id = engine.execute_plan(plan).await?;
```

#### Query Methods

##### `get_status`

```rust
pub async fn get_status(
    &self,
    execution_id: Uuid
) -> Result<ExecutionStatus, ExecutionError>
```

Get the current status of an execution.

**Parameters:**
- `execution_id`: Uuid - Execution identifier

**Returns:**
- `Ok(ExecutionStatus)`: Current status
- `Err(ExecutionError::NotFound)`: Execution not found

**Example:**
```rust
let status = engine.get_status(execution_id).await?;
if status == ExecutionStatus::Completed {
    println!("Execution completed!");
}
```

##### `get_result`

```rust
pub async fn get_result(
    &self,
    execution_id: Uuid
) -> Result<ExecutionResult, ExecutionError>
```

Get the result of a completed execution.

**Parameters:**
- `execution_id`: Uuid - Execution identifier

**Returns:**
- `Ok(ExecutionResult)`: Execution result with output
- `Err(ExecutionError::NotFound)`: Execution not found
- `Err(ExecutionError)`: Execution not yet completed

**Example:**
```rust
let result = engine.get_result(execution_id).await?;
println!("Exit code: {}", result.exit_code);
println!("Output: {}", result.stdout);
```

##### `list_executions`

```rust
pub async fn list_executions(&self) -> Vec<ExecutionSummary>
```

List all executions tracked by this engine.

**Returns:** Vector of execution summaries

**Example:**
```rust
let executions = engine.list_executions().await;
for exec in executions {
    println!("{}: {:?}", exec.id, exec.status);
}
```

#### Control Methods

##### `cancel`

```rust
pub async fn cancel(
    &self,
    execution_id: Uuid
) -> Result<(), ExecutionError>
```

Cancel a running execution.

**Parameters:**
- `execution_id`: Uuid - Execution identifier

**Returns:**
- `Ok(())`: Cancellation initiated
- `Err(ExecutionError::NotFound)`: Execution not found
- `Err(ExecutionError)`: Execution not running

**Example:**
```rust
engine.cancel(execution_id).await?;
```

#### Log Methods

##### `read_logs`

```rust
pub async fn read_logs(
    &self,
    execution_id: Uuid
) -> Result<String, ExecutionError>
```

Read the complete log file for an execution.

**Parameters:**
- `execution_id`: Uuid - Execution identifier

**Returns:**
- `Ok(String)`: Complete log contents
- `Err(ExecutionError)`: Log file not found or IO error

**Example:**
```rust
let logs = engine.read_logs(execution_id).await?;
println!("Logs:\n{}", logs);
```

##### `get_log_path`

```rust
pub fn get_log_path(&self, execution_id: Uuid) -> PathBuf
```

Get the path to the log file for an execution.

**Parameters:**
- `execution_id`: Uuid - Execution identifier

**Returns:** PathBuf to log file location

**Example:**
```rust
let log_path = engine.get_log_path(execution_id);
println!("Logs at: {:?}", log_path);
```

---

## ExecutionConfig

Configuration for the execution engine.

```rust
pub struct ExecutionConfig {
    pub default_timeout_ms: u64,
    pub max_timeout_ms: u64,
    pub stream_output: bool,
    pub log_dir: Option<PathBuf>,
    pub max_concurrent_executions: usize,
}
```

### Fields

- **`default_timeout_ms`**: Default timeout in milliseconds (default: 120,000 = 2 minutes)
- **`max_timeout_ms`**: Maximum allowed timeout (default: 600,000 = 10 minutes)
- **`stream_output`**: Enable real-time output streaming (default: true)
- **`log_dir`**: Custom log directory (default: None = system temp dir)
- **`max_concurrent_executions`**: Maximum concurrent executions (default: 10)

### Methods

#### `default`

```rust
impl Default for ExecutionConfig {
    fn default() -> Self
}
```

Create configuration with default values.

**Example:**
```rust
let config = ExecutionConfig::default();
```

#### Custom Configuration

```rust
let config = ExecutionConfig {
    default_timeout_ms: 300_000, // 5 minutes
    max_timeout_ms: 1_800_000,   // 30 minutes
    stream_output: true,
    log_dir: Some(PathBuf::from("/var/log/cloudops")),
    max_concurrent_executions: 20,
};
```

---

## Execution Types

### ExecutionRequest

Request to execute a single command.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionRequest {
    pub id: Uuid,
    pub command: Command,
    pub env: HashMap<String, String>,
    pub working_dir: Option<PathBuf>,
    pub timeout_ms: Option<u64>,
    pub metadata: ExecutionMetadata,
}
```

### Fields

- **`id`**: Unique identifier for this request
- **`command`**: Command to execute (see [Command]#command)
- **`env`**: Environment variables (default: empty)
- **`working_dir`**: Working directory (default: current directory)
- **`timeout_ms`**: Timeout in milliseconds (default: uses config default)
- **`output_log_path`**: Optional path to save stdout/stderr output to a file
- **`metadata`**: Metadata for tracking and debugging

#### Methods

##### `validate`

```rust
pub fn validate(&self, config: &ExecutionConfig) -> Result<(), ValidationError>
```

Validate the execution request.

**Returns:**
- `Ok(())`: Request is valid
- `Err(ValidationError)`: Validation failed

---

### ExecutionPlan

Plan for executing multiple commands.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionPlan {
    pub id: Uuid,
    pub description: String,
    pub strategy: ExecutionStrategy,
    pub commands: Vec<ExecutionRequest>,
    pub metadata: ExecutionMetadata,
}
```

### Fields

- **`id`**: Unique identifier for this plan
- **`description`**: Human-readable description
- **`strategy`**: Execution strategy (serial, parallel, etc.)
- **`commands`**: List of commands to execute
- **`metadata`**: Metadata for tracking

---

### Command

Standardized command types.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum Command {
    Script {
        path: PathBuf,
        interpreter: Option<String>,
    },
    Exec {
        program: String,
        args: Vec<String>,
    },
    Shell {
        command: String,
        shell: String,
    },
    AwsCli {
        service: String,
        operation: String,
        args: Vec<String>,
        profile: Option<String>,
        region: Option<String>,
    },
}
```

### Variants

#### `Script`

Execute a script file.

**Fields:**
- `path`: PathBuf - Path to script file
- `interpreter`: Option<String> - Interpreter to use (auto-detected if None)

**Example:**
```rust
Command::Script {
    path: PathBuf::from("/tmp/deploy.sh"),
    interpreter: None,
}
```

**JSON:**
```json
{
  "type": "script",
  "path": "/tmp/deploy.sh",
  "interpreter": null
}
```

#### `Exec`

Execute a command with arguments.

**Fields:**
- `program`: String - Program to execute
- `args`: Vec<String> - Arguments

**Example:**
```rust
Command::Exec {
    program: "python3".to_string(),
    args: vec!["script.py".to_string(), "--input".to_string(), "data.json".to_string()],
}
```

**JSON:**
```json
{
  "type": "exec",
  "program": "python3",
  "args": ["script.py", "--input", "data.json"]
}
```

#### `Shell`

Execute a shell command string.

**Fields:**
- `command`: String - Command string
- `shell`: String - Shell to use (default: "bash")

**Example:**
```rust
Command::Shell {
    command: "aws ec2 describe-instances | jq '.Reservations[]'".to_string(),
    shell: "bash".to_string(),
}
```

**JSON:**
```json
{
  "type": "shell",
  "command": "aws ec2 describe-instances | jq '.Reservations[]'",
  "shell": "bash"
}
```

#### `AwsCli`

Execute AWS CLI command (convenience wrapper).

**Fields:**
- `service`: String - AWS service (e.g., "ec2", "s3")
- `operation`: String - Operation (e.g., "describe-instances")
- `args`: Vec<String> - Additional arguments
- `profile`: Option<String> - AWS profile
- `region`: Option<String> - AWS region

**Example:**
```rust
Command::AwsCli {
    service: "ec2".to_string(),
    operation: "describe-instances".to_string(),
    args: vec!["--region".to_string(), "us-west-2".to_string()],
    profile: Some("production".to_string()),
    region: Some("us-west-2".to_string()),
}
```

**JSON:**
```json
{
  "type": "aws_cli",
  "service": "ec2",
  "operation": "describe-instances",
  "args": ["--region", "us-west-2"],
  "profile": "production",
  "region": "us-west-2"
}
```

#### Methods

##### `validate`

```rust
pub fn validate(&self) -> Result<(), ValidationError>
```

Validate the command.

---

### ExecutionStrategy

Strategy for executing multiple commands.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ExecutionStrategy {
    Serial {
        stop_on_error: bool,
    },
    Parallel {
        max_concurrency: Option<usize>,
    },
    DependencyGraph {
        dependencies: HashMap<usize, Vec<usize>>,
    },
}
```

### Variants

#### `Serial`

Execute commands one by one.

**Fields:**
- `stop_on_error`: bool - Stop on first error (default: true)

**Example:**
```rust
ExecutionStrategy::Serial {
    stop_on_error: true,
}
```

#### `Parallel`

Execute commands concurrently.

**Fields:**
- `max_concurrency`: Option<usize> - Maximum concurrent executions (None = unlimited)

**Example:**
```rust
ExecutionStrategy::Parallel {
    max_concurrency: Some(5),
}
```

#### `DependencyGraph`

Execute based on dependency graph.

**Fields:**
- `dependencies`: HashMap<usize, Vec<usize>> - Map of command index to dependency indices

**Example:**
```rust
// Command 2 depends on commands 0 and 1
ExecutionStrategy::DependencyGraph {
    dependencies: HashMap::from([
        (2, vec![0, 1]),
    ]),
}
```

---

## Result Types

### ExecutionResult

Result of a single command execution.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionResult {
    pub id: Uuid,
    pub status: ExecutionStatus,
    pub exit_code: i32,
    pub stdout: String,
    pub stderr: String,
    pub duration: Duration,
    pub started_at: DateTime<Utc>,
    pub completed_at: Option<DateTime<Utc>>,
    pub log_path: PathBuf,
    pub error: Option<String>,
}
```

### Fields

- **`id`**: Execution request ID
- **`status`**: Final status
- **`exit_code`**: Process exit code
- **`stdout`**: Standard output
- **`stderr`**: Standard error
- **`duration`**: Execution duration
- **`started_at`**: Start timestamp
- **`completed_at`**: Completion timestamp
- **`log_path`**: Path to log file
- **`error`**: Error message if failed

---

### PlanExecutionResult

Result of executing a plan.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PlanExecutionResult {
    pub plan_id: Uuid,
    pub status: ExecutionStatus,
    pub results: Vec<ExecutionResult>,
    pub total_duration: Duration,
    pub stats: ExecutionStats,
}
```

### Fields

- **`plan_id`**: Plan identifier
- **`status`**: Overall status
- **`results`**: Results for each command
- **`total_duration`**: Total execution time
- **`stats`**: Execution statistics

---

### ExecutionStatus

Status of an execution.

```rust
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ExecutionStatus {
    Pending,
    Running,
    Completed,
    Failed,
    Cancelled,
    Timeout,
}
```

### Variants

- **`Pending`**: Execution created but not started
- **`Running`**: Currently executing
- **`Completed`**: Completed successfully
- **`Failed`**: Failed with error
- **`Cancelled`**: Cancelled by user
- **`Timeout`**: Timed out

---

## Event System

### EventHandler

Trait for custom event handlers.

```rust
#[async_trait::async_trait]
pub trait EventHandler: Send + Sync {
    async fn on_event(&self, event: ExecutionEvent);
}
```

### Method

#### `on_event`

```rust
async fn on_event(&self, event: ExecutionEvent)
```

Handle an execution event.

**Parameters:**
- `event`: ExecutionEvent - Event to handle

**Example Implementation:**
```rust
struct MyEventHandler;

#[async_trait]
impl EventHandler for MyEventHandler {
    async fn on_event(&self, event: ExecutionEvent) {
        match event {
            ExecutionEvent::Stdout { execution_id, line } => {
                println!("[{}] {}", execution_id, line);
            }
            ExecutionEvent::Completed { execution_id, result } => {
                println!("Execution {} completed", execution_id);
            }
            _ => {}
        }
    }
}
```

---

### ExecutionEvent

Events emitted during execution.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "event_type", rename_all = "snake_case")]
pub enum ExecutionEvent {
    Started {
        execution_id: Uuid,
        command: String,
        timestamp: DateTime<Utc>,
    },
    Stdout {
        execution_id: Uuid,
        line: String,
        timestamp: DateTime<Utc>,
    },
    Stderr {
        execution_id: Uuid,
        line: String,
        timestamp: DateTime<Utc>,
    },
    Completed {
        execution_id: Uuid,
        result: ExecutionResult,
        timestamp: DateTime<Utc>,
    },
    Failed {
        execution_id: Uuid,
        error: String,
        timestamp: DateTime<Utc>,
    },
    Cancelled {
        execution_id: Uuid,
        timestamp: DateTime<Utc>,
    },
    Progress {
        plan_id: Uuid,
        completed: usize,
        total: usize,
        current_command: Option<String>,
        timestamp: DateTime<Utc>,
    },
}
```

### Variants

- **`Started`**: Execution started
- **`Stdout`**: Line of stdout output
- **`Stderr`**: Line of stderr output
- **`Completed`**: Execution completed
- **`Failed`**: Execution failed
- **`Cancelled`**: Execution cancelled
- **`Progress`**: Progress update for plans

---

## Error Types

### ExecutionError

Main error type for execution operations.

```rust
#[derive(Debug, thiserror::Error)]
pub enum ExecutionError {
    #[error("Validation error: {0}")]
    Validation(#[from] ValidationError),

    #[error("Execution not found: {0}")]
    NotFound(Uuid),

    #[error("Execution timeout after {0}ms")]
    Timeout(u64),

    #[error("Execution cancelled")]
    Cancelled,

    #[error("Command failed with exit code {0}")]
    CommandFailed(i32),

    #[error("Process spawn failed: {0}")]
    SpawnFailed(String),

    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Serialization error: {0}")]
    Serialization(#[from] serde_json::Error),
}
```

---

### ValidationError

Validation error types.

```rust
#[derive(Debug, thiserror::Error)]
pub enum ValidationError {
    #[error("Invalid command format: {0}")]
    InvalidCommand(String),

    #[error("Script file not found: {0}")]
    ScriptNotFound(PathBuf),

    #[error("Timeout exceeds maximum allowed: {0}ms > {1}ms")]
    TimeoutTooLarge(u64, u64),

    #[error("Invalid working directory: {0}")]
    InvalidWorkingDir(PathBuf),

    #[error("Missing required field: {0}")]
    MissingField(String),

    #[error("Invalid execution plan: {0}")]
    InvalidPlan(String),
}
```

---

## Metadata Types

### ExecutionMetadata

Metadata for tracking and debugging.

```rust
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ExecutionMetadata {
    pub source: Option<String>,
    pub conversation_id: Option<Uuid>,
    pub tags: HashMap<String, String>,
}
```

### Fields

- **`source`**: Source of request (e.g., "server", "ui", "test")
- **`conversation_id`**: Related conversation ID
- **`tags`**: Custom tags

---

### ExecutionSummary

Summary information about an execution.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionSummary {
    pub id: Uuid,
    pub status: ExecutionStatus,
    pub started_at: DateTime<Utc>,
    pub duration: Option<Duration>,
}
```

---

### ExecutionStats

Statistics for plan execution.

```rust
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionStats {
    pub total: usize,
    pub completed: usize,
    pub failed: usize,
    pub cancelled: usize,
    pub timeout: usize,
}
```

---

## Type Aliases

```rust
pub type Result<T> = std::result::Result<T, ExecutionError>;
```

---

## Related Documents

- [Architecture]architecture.md
- [Types Reference]types.md
- [Usage Examples]usage.md
- [Event Handlers]event-handlers.md