use std::path::{Path, PathBuf};
pub fn destination(tool: &str, root: &Path, candidate: &Path) -> Result<PathBuf, String> {
let (output, _) = crate::core::io_boundary::jail_and_check_export_path(tool, candidate, root)?;
let canonical_root = crate::core::pathutil::canonicalize_secure(root)
.map_err(|_| "project root is unavailable".to_string())?;
let inside = output
.parent()
.and_then(|parent| crate::core::pathutil::canonicalize_secure(parent).ok())
.is_some_and(|parent| parent.starts_with(&canonical_root));
if !inside {
return Err("a bundle file must stay inside the project root".to_string());
}
crate::core::pathjail::enforce_writable(&output)?;
Ok(output)
}