pub fn resolve_workspace_path(
workspace_root: &Path,
requested: &Path,
) -> Result<PathBuf, FsError>Expand description
Resolves a request path to an absolute path within the workspace, verifying it does not escape.
Behavior:
- Relative paths are joined with
workspace_root; absolute paths are used as-is. - Walks up from the target to find the nearest existing ancestor and canonicalizes it (on writes, the target itself and even multiple parent directories may not yet exist).
- Checks that the real path of the existing ancestor starts with the real path of
workspace_rootโ prevents symlink escape (e.g.workspace/dir/link โ /etc). - Appends the remaining non-existent path segments as-is, then appends the file name.
Both LocalFsBackend and AcpFsBackend implementations of crate::fs::FsBackend
call
this same function โ in delegated mode the agent still enforces its own boundary, not
relying on the client.
ยงErrors
FsError::NotPermitted: path escapes / no parent directory / no file nameFsError::Backend: canonicalization of ancestor failed (IO error)