Skip to main content

pet_resort_worker/
runtime.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2/// Classifies agent runtime modes used by the worker shell.
3///
4/// The mode chooses whether workflow packets are answered by deterministic fixtures or
5/// skipped entirely; neither variant grants authority to perform live customer messaging
6/// or provider writes.
7pub enum AgentRuntimeMode {
8    /// Uses deterministic fixtures so local workers can exercise packet flow without calling live agents.
9    FakeDeterministic,
10    /// Skips agent execution while keeping the worker process and side-effect stubs available.
11    Disabled,
12}
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
15/// Classifies side-effect posture for the worker runtime.
16///
17/// Current workers expose only stubbed side effects so tests and demos cannot write to
18/// Gingr, payment providers, SMS/email systems, or customer-facing channels.
19pub enum SideEffectMode {
20    /// Keeps provider writes, customer sends, and payment movement behind no-op test doubles.
21    Stubbed,
22}
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25/// Configuration carried by the worker runtime.
26///
27/// The config is intentionally small: it selects deterministic agent execution and an
28/// explicit side-effect posture so durable workflow workers can be inspected without
29/// confusing storage evidence with permission to act in live systems.
30pub struct Config {
31    agent_runtime_mode: AgentRuntimeMode,
32    side_effect_mode: SideEffectMode,
33}
34
35impl Config {
36    /// Reads safe local defaults from the environment without enabling live side effects.
37    ///
38    /// `PET_RESORT_AGENT_RUNTIME_MODE=disabled` turns agent execution off; every other
39    /// value falls back to deterministic fixtures. Side effects remain [`SideEffectMode::Stubbed`].
40    pub fn from_env_defaults() -> Self {
41        let agent_runtime_mode = match std::env::var("PET_RESORT_AGENT_RUNTIME_MODE")
42            .unwrap_or_else(|_| "fake".to_owned())
43            .as_str()
44        {
45            "disabled" => AgentRuntimeMode::Disabled,
46            _ => AgentRuntimeMode::FakeDeterministic,
47        };
48
49        Self {
50            agent_runtime_mode,
51            side_effect_mode: SideEffectMode::Stubbed,
52        }
53    }
54
55    /// Returns the agent runtime mode carried by this worker runtime value.
56    pub fn agent_runtime_mode(&self) -> AgentRuntimeMode {
57        self.agent_runtime_mode
58    }
59
60    /// Returns the side effect mode carried by this worker runtime value.
61    pub fn side_effect_mode(&self) -> SideEffectMode {
62        self.side_effect_mode
63    }
64}