| 242 | } |
| 243 | |
| 244 | async fn resolve_repository( |
| 245 | &self, |
| 246 | request: Request<ResolveRepositoryRequest>, |
| 247 | ) -> Result<Response<ResolveRepositoryResponse>, Status> { |
| 248 | let request = request.into_inner(); |
| 249 | let root = Repository::find_root(std::path::Path::new(&request.path)) |
| 250 | .map_err(|error| domain_status(ErrorCode::RepositoryNotFound, error.to_string()))?; |
| 251 | let handle = self.state.register(root.clone()); |
| 252 | self.state.log_rpc("ResolveRepository", Some(&handle)); |
| 253 | // Resolve is a pure path walk + registry entry — it never opens a |
| 254 | // repository database, so it must NOT queue behind the per-repo |
| 255 | // serialization gate (a CLI command resolving while a turn records |
| 256 | // would otherwise block for the record's whole duration). |
| 257 | let relative_cwd = std::path::Path::new(&request.path) |
| 258 | .strip_prefix(&handle.root) |
| 259 | .map(|p| p.display().to_string()) |
| 260 | .unwrap_or_default(); |
| 261 | Ok(Response::new(ResolveRepositoryResponse { |
| 262 | repository: Some(handle.repository_ref()), |
| 263 | workspace: Some(WorkspaceInfo { |
| 264 | workspace_id: "default".to_string(), |
| 265 | root_path: handle.root.display().to_string(), |
| 266 | relative_cwd, |
| 267 | current_view: Some(ViewRef { |
| 268 | view_id: blake3::hash(handle.current_view().as_bytes()) |
| 269 | .as_bytes() |
| 270 | .to_vec(), |
| 271 | name: Some(handle.current_view()), |
| 272 | }), |
| 273 | }), |
| 274 | })) |
| 275 | } |
| 276 | |
| 277 | async fn register_repository( |
| 278 | &self, |