use common_contracts::messages::TaskType;

pub struct IOBinder;

impl IOBinder {
    pub fn new() -> Self {
        Self
    }

    pub fn allocate_output_path(
        &self,
        task_type: TaskType,
        symbol: &str,
        task_id: &str,
    ) -> String {
        // Convention based paths:
        // DataFetch: raw/{provider_id}/{symbol}
        // DataProcessing: processed/{processor_id}/{symbol}
        // Analysis: analysis/{module_id}/{symbol}.md
        
        let clean_task_id = task_id.split(':').last().unwrap_or(task_id);
        
        match task_type {
            TaskType::DataFetch => format!("raw/{}/{}", clean_task_id, symbol),
            TaskType::DataProcessing => format!("processed/{}/{}", clean_task_id, symbol),
            TaskType::Analysis => format!("analysis/{}/{}.md", clean_task_id, symbol),
        }
    }

    pub fn allocate_trace_path(
        &self,
        task_type: TaskType,
        symbol: &str,
        task_id: &str,
    ) -> String {
        let clean_task_id = task_id.split(':').last().unwrap_or(task_id);
        match task_type {
             TaskType::Analysis => format!("analysis/{}/{}_trace.md", clean_task_id, symbol),
             _ => format!("debug/{}/{}_trace.md", clean_task_id, symbol),
        }
    }
}

