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
//! Paladin Executor Port
//!
//! Defines the abstraction for executing a Paladin agent. This port breaks the
//! circular dependency between `HandoffService` and `PaladinExecutionService`:
//!
//! - `HandoffService` depends on `Arc<dyn PaladinExecutorPort>` to execute specialists
//! - `PaladinExecutionService` implements `PaladinExecutorPort`
//!
//! This follows the Dependency Inversion Principle: both high-level (HandoffService)
//! and low-level (PaladinExecutionService) modules depend on the abstraction.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────┐ ┌──────────────────────────┐
//! │ HandoffService │────▶│ PaladinExecutorPort │
//! │ (uses trait to │ │ (trait / abstraction) │
//! │ execute specialist)│ └──────────┬───────────────┘
//! └─────────────────────┘ │ implements
//! ▼
//! ┌──────────────────────────┐
//! │ PaladinExecutionService │
//! │ (concrete implementation) │
//! └──────────────────────────┘
//! ```
use async_trait;
use cratePaladinResult;
use Paladin;
use PaladinError;
/// Port trait for executing a Paladin agent
///
/// This abstraction allows services like `HandoffService` to delegate execution
/// to a Paladin without directly depending on `PaladinExecutionService`, thus
/// avoiding circular dependencies in the dependency graph.
///
/// # Thread Safety
///
/// Implementations must be `Send + Sync` to allow sharing across async tasks.
///
/// # Example
///
/// ```rust,no_run
/// use paladin::application::ports::output::paladin_executor_port::PaladinExecutorPort;
/// use paladin::application::ports::output::paladin_port::PaladinResult;
/// use paladin::core::platform::container::paladin::Paladin;
/// use std::sync::Arc;
///
/// async fn delegate_to_specialist(
/// executor: &dyn PaladinExecutorPort,
/// specialist: &Paladin,
/// task: &str,
/// ) -> Result<PaladinResult, paladin_core::platform::container::paladin_error::PaladinError> {
/// executor.execute(specialist, task).await
/// }
/// ```