Skip to main content

ta_submit/
none.rs

1//! "None" adapter - backwards-compatible fallback with no VCS operations
2
3use ta_changeset::DraftPackage;
4use ta_goal::GoalRun;
5
6use crate::adapter::{CommitResult, PushResult, Result, ReviewResult, SourceAdapter};
7use crate::config::SubmitConfig;
8
9/// Fallback adapter that performs no VCS operations
10///
11/// This adapter maintains backwards compatibility with workflows that don't
12/// use version control integration. It's selected automatically when no
13/// workflow config exists or when adapter = "none".
14pub struct NoneAdapter;
15
16impl NoneAdapter {
17    pub fn new() -> Self {
18        Self
19    }
20}
21
22impl Default for NoneAdapter {
23    fn default() -> Self {
24        Self::new()
25    }
26}
27
28impl SourceAdapter for NoneAdapter {
29    fn prepare(&self, _goal: &GoalRun, _config: &SubmitConfig) -> Result<()> {
30        // No-op: no workspace preparation needed
31        tracing::debug!("NoneAdapter: prepare() - no-op");
32        Ok(())
33    }
34
35    fn commit(&self, goal: &GoalRun, _pr: &DraftPackage, message: &str) -> Result<CommitResult> {
36        // No-op: no commit operation
37        tracing::debug!("NoneAdapter: commit() - no-op");
38        Ok(CommitResult {
39            commit_id: format!("none-{}", goal.goal_run_id),
40            message: message.to_string(),
41            metadata: Default::default(),
42            ignored_artifacts: vec![],
43        })
44    }
45
46    fn push(&self, goal: &GoalRun) -> Result<PushResult> {
47        // No-op: no push operation
48        tracing::debug!("NoneAdapter: push() - no-op");
49        Ok(PushResult {
50            remote_ref: format!("none-{}", goal.goal_run_id),
51            message: "No push operation (none adapter)".to_string(),
52            metadata: Default::default(),
53        })
54    }
55
56    fn open_review(&self, goal: &GoalRun, _pr: &DraftPackage) -> Result<ReviewResult> {
57        // No-op: no review creation
58        tracing::debug!("NoneAdapter: open_review() - no-op");
59        Ok(ReviewResult {
60            review_url: format!("none://{}", goal.goal_run_id),
61            review_id: format!("none-{}", goal.goal_run_id),
62            message: "No review creation (none adapter)".to_string(),
63            metadata: Default::default(),
64        })
65    }
66
67    fn name(&self) -> &str {
68        "none"
69    }
70}
71
72#[cfg(test)]
73mod tests {
74    use super::*;
75    use ta_goal::GoalRun;
76
77    fn mock_goal() -> GoalRun {
78        GoalRun::new(
79            "Test Goal",
80            "Test objective",
81            "test-agent",
82            std::path::PathBuf::from("/tmp/workspace"),
83            std::path::PathBuf::from("/tmp/store"),
84        )
85    }
86
87    #[test]
88    fn test_none_adapter_name() {
89        let adapter = NoneAdapter::new();
90        assert_eq!(adapter.name(), "none");
91    }
92
93    #[test]
94    fn test_none_adapter_prepare() {
95        let adapter = NoneAdapter::new();
96        let goal = mock_goal();
97        let config = SubmitConfig::default();
98
99        assert!(adapter.prepare(&goal, &config).is_ok());
100    }
101
102    #[test]
103    fn test_none_adapter_push() {
104        let adapter = NoneAdapter::new();
105        let goal = mock_goal();
106
107        let result = adapter.push(&goal).unwrap();
108        assert!(result.remote_ref.starts_with("none-"));
109    }
110
111    // Note: Tests for commit() and open_review() require PRPackage construction
112    // which has a complex structure. These will be added as integration tests
113    // that use actual PRPackage instances from ta-changeset test utilities.
114}