| 155 | } |
| 156 | |
| 157 | async fn delete(&self, id: &str) -> Result<()> { |
| 158 | let path = self.session_path(id); |
| 159 | |
| 160 | if path.exists() { |
| 161 | fs::remove_file(&path) |
| 162 | .await |
| 163 | .with_context(|| format!("Failed to delete session file: {}", path.display()))?; |
| 164 | |
| 165 | tracing::debug!("Deleted session {} from {}", id, path.display()); |
| 166 | } |
| 167 | |
| 168 | let artifact_dir = self.artifact_dir(id); |
| 169 | if artifact_dir.exists() { |
| 170 | fs::remove_dir_all(&artifact_dir).await.with_context(|| { |
| 171 | format!( |
| 172 | "Failed to delete artifact directory for session {}: {}", |
| 173 | id, |
| 174 | artifact_dir.display() |
| 175 | ) |
| 176 | })?; |
| 177 | } |
| 178 | |
| 179 | let trace_path = self.trace_path(id); |
| 180 | if trace_path.exists() { |
| 181 | fs::remove_file(&trace_path).await.with_context(|| { |
| 182 | format!( |
| 183 | "Failed to delete trace file for session {}: {}", |
| 184 | id, |
| 185 | trace_path.display() |
| 186 | ) |
| 187 | })?; |
| 188 | } |
| 189 | |
| 190 | let verification_path = self.verification_path(id); |
| 191 | if verification_path.exists() { |
| 192 | fs::remove_file(&verification_path).await.with_context(|| { |
| 193 | format!( |
| 194 | "Failed to delete verification report file for session {}: {}", |
| 195 | id, |
| 196 | verification_path.display() |
| 197 | ) |
| 198 | })?; |
| 199 | } |
| 200 | |
| 201 | let runs_path = self.runs_path(id); |
| 202 | if runs_path.exists() { |
| 203 | fs::remove_file(&runs_path).await.with_context(|| { |
| 204 | format!( |
| 205 | "Failed to delete run record file for session {}: {}", |
| 206 | id, |
| 207 | runs_path.display() |
| 208 | ) |
| 209 | })?; |
| 210 | } |
| 211 | |
| 212 | let subagent_tasks_path = self.subagent_tasks_path(id); |
| 213 | if subagent_tasks_path.exists() { |
| 214 | fs::remove_file(&subagent_tasks_path) |