Skip to main content

resolve_workspace_path

Function resolve_workspace_path 

Source
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:

  1. Relative paths are joined with workspace_root; absolute paths are used as-is.
  2. 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).
  3. 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).
  4. 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