Skip to main content

stasis/application/runtime/
runtime_handler_execution_context.rs

1use std::sync::Arc;
2
3use crate::application::orchestration::prompt_pipeline::PromptExecutionContext;
4use crate::domain::runtime::job::Job;
5
6#[derive(Clone)]
7pub struct RuntimeHandlerExecutionContext {
8    correlation_id: Arc<str>,
9    policy_profile: Arc<Option<String>>,
10    model_hint: Arc<Option<String>>,
11    prompt_context: Arc<PromptExecutionContext>,
12    memory_reader_enabled: bool,
13    memory_writer_enabled: bool,
14    identity_enabled: bool,
15}
16
17impl RuntimeHandlerExecutionContext {
18    pub fn new(
19        job: &Job,
20        policy_profile: Option<String>,
21        model_hint: Option<String>,
22        reasoning_effort: Option<String>,
23        memory_reader_enabled: bool,
24        memory_writer_enabled: bool,
25        identity_enabled: bool,
26    ) -> Self {
27        let prompt_context = PromptExecutionContext {
28            trace_id: Some(job.trace_id.clone()),
29            correlation_id: Some(job.correlation_id.clone()),
30            policy_profile: policy_profile.clone(),
31            model_hint: model_hint.clone(),
32            reasoning_effort,
33        };
34
35        Self {
36            correlation_id: Arc::<str>::from(job.correlation_id.as_str()),
37            policy_profile: Arc::new(policy_profile),
38            model_hint: Arc::new(model_hint),
39            prompt_context: Arc::new(prompt_context),
40            memory_reader_enabled,
41            memory_writer_enabled,
42            identity_enabled,
43        }
44    }
45
46    pub fn correlation_id(&self) -> &str {
47        &self.correlation_id
48    }
49
50    pub fn prompt_context_clone(&self) -> PromptExecutionContext {
51        (*self.prompt_context).clone()
52    }
53
54    pub fn policy_profile(&self) -> Option<&str> {
55        self.policy_profile.as_ref().as_deref()
56    }
57
58    pub fn policy_profile_clone(&self) -> Option<String> {
59        (*self.policy_profile).clone()
60    }
61
62    pub fn model_hint_clone(&self) -> Option<String> {
63        (*self.model_hint).clone()
64    }
65
66    pub fn memory_reader_enabled(&self) -> bool {
67        self.memory_reader_enabled
68    }
69
70    pub fn memory_writer_enabled(&self) -> bool {
71        self.memory_writer_enabled
72    }
73
74    pub fn identity_enabled(&self) -> bool {
75        self.identity_enabled
76    }
77}