[codex] migrate ExecutorFileSystem paths to PathUri (#27424)

## Why

We're moving exec-server to use PathUri for its internal path
representations.

## What

Move `ExecutorFileSystem` APIs to use `PathUri` instead of
`AbsolutePathBuf`. Future changes will convert higher-level parts of
exec-server.
This commit is contained in:
Adam Perry @ OpenAI authored and GitHub committed 2026-06-11 18:44:18 +00:00
1 parent 4a05d3b282
commit b2a4e3be27
52 files changed
+1126 -495

No files matched your search

+80 -10
View File
@@ -19,6 +19,7 @@ use codex_protocol::protocol::Product;
use codex_protocol::protocol::SkillScope;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_absolute_path::AbsolutePathBufGuard;
use codex_utils_path_uri::PathUri;
use codex_utils_plugins::PluginSkillRoot;
use codex_utils_plugins::plugin_namespace_for_skill_path;
use dirs::home_dir;
@@ -374,7 +375,17 @@ async fn repo_agents_skill_roots(
let mut roots = Vec::new();
for dir in dirs {
let agents_skills = dir.join(AGENTS_DIR_NAME).join(SKILLS_DIR_NAME);
match fs.get_metadata(&agents_skills, /*sandbox*/ None).await {
let agents_skills_uri = match PathUri::from_abs_path(&agents_skills) {
Ok(path) => path,
Err(err) => {
tracing::warn!(
"failed to convert repo skills root {} to URI: {err:#}",
agents_skills.display()
);
continue;
}
};
match fs.get_metadata(&agents_skills_uri, /*sandbox*/ None).await {
Ok(metadata) if metadata.is_directory => roots.push(SkillRoot {
path: agents_skills,
scope: SkillScope::Repo,
@@ -429,7 +440,17 @@ async fn find_project_root(
for ancestor in cwd.ancestors() {
for marker in project_root_markers {
let marker_path = ancestor.join(marker);
match fs.get_metadata(&marker_path, /*sandbox*/ None).await {
let marker_path_uri = match PathUri::from_abs_path(&marker_path) {
Ok(path) => path,
Err(err) => {
tracing::warn!(
"failed to convert project root marker {} to URI: {err:#}",
marker_path.display()
);
continue;
}
};
match fs.get_metadata(&marker_path_uri, /*sandbox*/ None).await {
Ok(_) => return ancestor,
Err(err) if err.kind() == io::ErrorKind::NotFound => {}
Err(err) => {
@@ -475,8 +496,12 @@ async fn canonicalize_for_skill_identity(
fs: &dyn ExecutorFileSystem,
path: &AbsolutePathBuf,
) -> AbsolutePathBuf {
fs.canonicalize(path, /*sandbox*/ None)
let Ok(path_uri) = PathUri::from_abs_path(path) else {
return path.clone();
};
fs.canonicalize(&path_uri, /*sandbox*/ None)
.await
.and_then(|path| path.to_abs_path())
.unwrap_or_else(|_| path.clone())
}
@@ -494,7 +519,17 @@ async fn discover_skills_under_root(
None => None,
};
match fs.get_metadata(&root, /*sandbox*/ None).await {
let root_uri = match PathUri::from_abs_path(&root) {
Ok(path) => path,
Err(err) => {
tracing::warn!(
"failed to convert skills root {} to URI: {err:#}",
root.display()
);
return;
}
};
match fs.get_metadata(&root_uri, /*sandbox*/ None).await {
Ok(metadata) if metadata.is_directory => {}
Ok(_) => return,
Err(err) if err.kind() == io::ErrorKind::NotFound => return,
@@ -536,7 +571,17 @@ async fn discover_skills_under_root(
let mut truncated_by_dir_limit = false;
while let Some((dir, depth)) = queue.pop_front() {
let entries = match fs.read_directory(&dir, /*sandbox*/ None).await {
let dir_uri = match PathUri::from_abs_path(&dir) {
Ok(path) => path,
Err(e) => {
tracing::warn!(
"failed to convert skills dir {} to URI: {e:#}",
dir.display()
);
continue;
}
};
let entries = match fs.read_directory(&dir_uri, /*sandbox*/ None).await {
Ok(entries) => entries,
Err(e) => {
error!("failed to read skills dir {}: {e:#}", dir.display());
@@ -551,7 +596,17 @@ async fn discover_skills_under_root(
}
let path = dir.join(&file_name);
let metadata = match fs.get_metadata(&path, /*sandbox*/ None).await {
let path_uri = match PathUri::from_abs_path(&path) {
Ok(path) => path,
Err(e) => {
tracing::warn!(
"failed to convert skills path {} to URI: {e:#}",
path.display()
);
continue;
}
};
let metadata = match fs.get_metadata(&path_uri, /*sandbox*/ None).await {
Ok(metadata) => metadata,
Err(e) => {
error!("failed to stat skills path {}: {e:#}", path.display());
@@ -563,7 +618,7 @@ async fn discover_skills_under_root(
if !follow_symlinks {
continue;
}
match fs.read_directory(&path, /*sandbox*/ None).await {
match fs.read_directory(&path_uri, /*sandbox*/ None).await {
Ok(_) => {
let resolved_dir = canonicalize_for_skill_identity(fs, &path).await;
enqueue_dir(
@@ -635,8 +690,9 @@ async fn parse_skill_file(
plugin_id: Option<&str>,
plugin_root: Option<&AbsolutePathBuf>,
) -> Result<SkillMetadata, SkillParseError> {
let path_uri = PathUri::from_abs_path(path).map_err(SkillParseError::Read)?;
let contents = fs
.read_file_text(path, /*sandbox*/ None)
.read_file_text(&path_uri, /*sandbox*/ None)
.await
.map_err(SkillParseError::Read)?;
@@ -730,7 +786,18 @@ async fn load_skill_metadata(
let metadata_path = skill_dir
.join(SKILLS_METADATA_DIR)
.join(SKILLS_METADATA_FILENAME);
match fs.get_metadata(&metadata_path, /*sandbox*/ None).await {
let metadata_path_uri = match PathUri::from_abs_path(&metadata_path) {
Ok(path) => path,
Err(error) => {
tracing::warn!(
"ignoring {path}: failed to convert {label} path to URI: {error}",
path = metadata_path.display(),
label = SKILLS_METADATA_FILENAME
);
return LoadedSkillMetadata::default();
}
};
match fs.get_metadata(&metadata_path_uri, /*sandbox*/ None).await {
Ok(metadata) if metadata.is_file => {}
Ok(_) => return LoadedSkillMetadata::default(),
Err(error) if error.kind() == io::ErrorKind::NotFound => {
@@ -746,7 +813,10 @@ async fn load_skill_metadata(
}
}
let contents = match fs.read_file_text(&metadata_path, /*sandbox*/ None).await {
let contents = match fs
.read_file_text(&metadata_path_uri, /*sandbox*/ None)
.await
{
Ok(contents) => contents,
Err(error) => {
tracing::warn!(