Skip to main content

orchestrator_config/config/
item_isolation.rs

1use serde::{Deserialize, Serialize};
2
3/// Supported isolation strategies for item-scoped execution.
4#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
5#[serde(rename_all = "snake_case")]
6pub enum ItemIsolationStrategy {
7    /// No isolation. All items execute in the primary workspace.
8    #[default]
9    None,
10    /// Each item executes in its own git worktree.
11    GitWorktree,
12}
13
14/// Cleanup timing for isolated item workspaces.
15#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
16#[serde(rename_all = "snake_case")]
17pub enum ItemIsolationCleanup {
18    /// Remove temporary worktrees and branches when the workflow finishes.
19    #[default]
20    AfterWorkflow,
21    /// Keep worktrees and branches for manual inspection.
22    Never,
23}
24
25/// Workflow-level configuration for item-scoped isolation.
26#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
27pub struct ItemIsolationConfig {
28    /// Isolation strategy to use for item-scoped execution.
29    #[serde(default)]
30    pub strategy: ItemIsolationStrategy,
31    /// Prefix used for temporary git branches created per item.
32    #[serde(default, skip_serializing_if = "Option::is_none")]
33    pub branch_prefix: Option<String>,
34    /// Cleanup policy for temporary worktrees and branches.
35    #[serde(default)]
36    pub cleanup: ItemIsolationCleanup,
37}
38
39impl Default for ItemIsolationConfig {
40    fn default() -> Self {
41        Self {
42            strategy: ItemIsolationStrategy::None,
43            branch_prefix: None,
44            cleanup: ItemIsolationCleanup::AfterWorkflow,
45        }
46    }
47}
48
49impl ItemIsolationConfig {
50    /// Whether item isolation is active.
51    pub fn is_enabled(&self) -> bool {
52        self.strategy != ItemIsolationStrategy::None
53    }
54}