['String]) -> Result<TaskId> {\n    let task_id = generate_task_id();\n    \n    // Validate dependencies exist and no cycles\n    validate_dependencies(&task_id, dependencies)?;\n    \n    // Create task with dependencies\n    create_task(task_id.clone(), title, dependencies)?;\n    \n    Ok(task_id)\n}\n\nfn validate_dependencies(task_id: &str, dependencies: &[String]) -> Result<()> {\n    for dep_id in dependencies {\n        if !task_exists(dep_id) {\n            return Err(DependencyError::TaskNotFound(dep_id.clone()));\n        }\n        if would_create_cycle(task_id, dep_id) {\n            return Err(DependencyError::CycleDetected(task_id.clone(), dep_id.clone()));\n        }\n    }\n    Ok(())\n}\n```\n\n### 1.2 Cycle Detection\n\nUse depth-first search to detect cycles when adding dependencies:\n\n```rust\nfn would_create_cycle(task_id: &str, new_dep_id: &str) -> bool {\n    let mut visited = HashSet::new();\n    would_create_cycle_dfs(new_dep_id, task_id, &mut visited)\n}\n\nfn would_create_cycle_dfs(current: &str, target: &str, visited: &mut HashSet<String>) -> bool {\n    if current == target {\n        return true;\n    }\n    \n    if visited.contains(current) {\n        return false;\n    }\n    \n    visited.insert(current.to_string());\n    \n    let dependencies = get_dependencies(current);\n    for dep in dependencies {\n        if would_create_cycle_dfs(&dep, target, visited) {\n            return true;\n        }\n    }\n    \n    false\n}\n```\n\n## 2. Runtime Enforcement\n\n### 2.1 Pre-execution Validation\n\nBefore executing any task, validate that all dependencies are satisfied:\n\n```rust\nfn can_execute(task_id: &str) -> Result<bool> {\n    let dependencies = get_dependencies(task_id);\n    for dep_id in dependencies {\n        let dep_status = get_task_status(dep_id);\n        if dep_status != Status::Done {\n            return Ok(false);\n        }\n    }\n    Ok(true)\n}\n```\n\n### 2.2 Scheduler Integration\n\nThe scheduler must check dependencies before dispatching tasks:\n\n```rust\nfn schedule_task(task_id: &str) -> ScheduleResult {\n    if !can_execute(task_id) {\n        return ScheduleResult::Blocked(task_id.to_string());\n    }\n    \n    // Proceed with execution\n    dispatch_task(task_id)\n}\n```\n\n## 3. Coordinator Prompt Processing\n\n### 3.1 Prompt Parsing\n\nWhen the coordinator receives a prompt with `--after` directives, it must:\n1. Parse the dependency specifications\n2. Validate all dependencies exist\n3. Ensure no cycles would be created\n4. Only then create the task\n\n### 3.2 Example Prompt Processing\n\n```\nwg add "Task B" --after task-a-id\n```\n\nProcessing steps:\n1. Parse "task-a-id" as a dependency\n2. Verify task with ID "task-a-id" exists\n3. Check that creating this dependency wouldn\'t form a cycle\n4. Create task "Task B" with dependency on "task-a-id', 5.0, 'Update dependency tracking structures\n\n## 4. Data Structures\n\n### 4.1 Dependency Tracking\n\n```rust\nstruct DependencyTracker {\n    // task_id -> [dependency_ids]\n    dependencies: HashMap<String, Vec<String>>,\n    // task_id -> [dependent_task_ids]  \n    dependents: HashMap<String, Vec<String>>,\n}\n\nimpl DependencyTracker {\n    fn add_dependency(&mut self, task_id: &str, dependency_id: &str) {\n        self.dependencies.entry(task_id.to_string()).or_insert_with(Vec::new).push(dependency_id.to_string());\n        self.dependents.entry(dependency_id.to_string()).or_insert_with(Vec::new).push(task_id.to_string());\n    }\n    \n    fn get_dependencies(&self, task_id: &str) -> &[String] {\n        self.dependencies.get(task_id).map(|v| v.as_slice()).unwrap_or(&[])\n    }\n    \n    fn get_dependents(&self, task_id: &str) -> &[String] {\n        self.dependents.get(task_id).map(|v| v.as_slice()).unwrap_or(&[])\n    }\n}\n```\n\n## 5. Error Handling\n\n### 5.1 Dependency Errors\n\n```rust\n#[derive(Debug)]\nenum DependencyError {\n    TaskNotFound(String),\n    CycleDetected(String, String),\n    InvalidDependencyFormat(String),\n}\n\nimpl std::error::Error for DependencyError {}\n\nimpl std::fmt::Display for DependencyError {\n    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n        match self {\n            DependencyError::TaskNotFound(id) => write!(f, "Dependency task not found: {}', 'id),\n            DependencyError::CycleDetected(task_id, dep_id) => write!(f, "Cycle detected: {} -> {}', 'task_id, dep_id),\n            DependencyError::InvalidDependencyFormat(format) => write!(f, "Invalid dependency format: {}', 'format),\n        }\n    }\n}\n```\n\n## 6. Validation\n\n### 6.1 Creation Time Validation\n\n- All specified dependencies must exist\n- No circular dependencies can be created\n- Dependency format must be valid\n\n### 6.2 Runtime Validation\n\n- All dependencies must be in "done', 'status before execution\n- Dependent tasks must be blocked if dependencies are not satisfied\n\n## 7. Implementation Plan\n\n1. **Phase 1**: Implement dependency validation in task creation\n2. **Phase 2**: Add cycle detection algorithms\n3. **Phase 3**: Integrate with the scheduler for runtime enforcement\n4. **Phase 4**: Add comprehensive error handling\n5. **Phase 5**: Add tests for all validation scenarios\n\n## 8. Test Cases\n\n### 8.1 Dependency Validation Tests\n\n```rust\n#[test]\nfn test_dependency_validation_success() {\n    // Create task-a\n    let task_a_id = create_task("Task A");\n    \n    // Create task-b with dependency on task-a (should succeed)\n    assert!(create_task_with_dependencies("Task B', 'vec![task_a_id.clone()]).is_ok());\n}\n\n#[test]\nfn test_dependency_validation_failure() {\n    // Try to create task with non-existent dependency (should fail)\n    assert!(create_task_with_dependencies("Task B', 'vec!["non-existent-id', '.', 'to_string()]).is_err());\n}\n```\n\n### 8.2 Cycle Detection Tests\n\n```rust\n#[test]\nfn test_cycle_detection() {\n    // Create task-a\n    let task_a_id = create_task("Task A");\n    \n    // Create task-b with dependency on task-a\n    let task_b_id = create_task_with_dependencies("Task B', 'vec![task_a_id.clone()]).unwrap();\n    \n    // Try to create task-a with dependency on task-b (should fail due to cycle)\n    assert!(create_task_with_dependencies("Task A', 'vec![task_b_id]).is_err());\n}\n```\n\n### 8.3 Runtime Validation Tests\n\n```rust\n#[test]\nfn test_runtime_validation() {\n    // Create task-a and task-b\n    let task_a_id = create_task("Task A");\n    let task_b_id = create_task_with_dependencies("Task B', "vec![task_a_id.clone()]).unwrap();\n    \n    // task-b should not be able to execute since task-a is not done\n    assert!(!can_execute(&task_b_id));\n    \n    // Mark task-a as done\n    mark_task_done(&task_a_id);\n    \n    // task-b should now be able to execute\n    assert!(can_execute(&task_b_id));\n}\n```\n\n## 9. Security Considerations\n\n- Dependency validation prevents tasks from being created with invalid or malicious dependencies\n- Cycle detection prevents denial of service through infinite dependency loops\n- Proper error handling ensures that malformed dependencies don't crash the system\n\n## 10. Performance Considerations\n\n- Dependency validation should be O(n) where n is the number of dependencies\n- Cycle detection should use caching to avoid repeated computations\n- Runtime validation should use indexed lookups for dependency status\n\n## 11. Monitoring and Observability\n\n- Log dependency validation failures\n- Track cycle detection events\n- Monitor blocked tasks due to unresolved dependencies"]