mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Batch filesystem metadata checks for instruction and skill discovery (#63266)
## Why Discovering project instructions and repository skill directories can require several metadata checks per ancestor directory. Batching those checks reduces remote executor round trips and sandbox helper launches. ## What changed Add bounded metadata batches that return a result or error for each path in input order. Remote executors advertise support for `fs/getMetadataBatch`, and sandboxed filesystems can process a batch in one helper invocation. Check project root markers alongside the first working-directory instruction candidate, then batch the next candidate across unresolved directories in filename priority order. Batch checks for `.agents/skills` directories between the project root and the working directory. Fall back to individual checks when batching is unsupported. ## Testing Extend tests to assert batch counts for shallow and nested `AGENTS.md` discovery and verify that metadata batches preserve result order and per-path errors. GitOrigin-RevId: 6cb04202a905d783454908348d008def95b9a5d6
This commit is contained in:
@@ -42,6 +42,7 @@ pub const FS_CLOSE_METHOD: &str = "fs/close";
|
||||
pub const FS_WRITE_FILE_METHOD: &str = "fs/writeFile";
|
||||
pub const FS_CREATE_DIRECTORY_METHOD: &str = "fs/createDirectory";
|
||||
pub const FS_GET_METADATA_METHOD: &str = "fs/getMetadata";
|
||||
pub const FS_GET_METADATA_BATCH_METHOD: &str = "fs/getMetadataBatch";
|
||||
pub const FS_WATCH_MISSING_METHOD: &str = "fs/watchMissing";
|
||||
pub const FS_MISSING_CHANGED_METHOD: &str = "fs/missingChanged";
|
||||
pub const FS_CANONICALIZE_METHOD: &str = "fs/canonicalize";
|
||||
@@ -170,6 +171,9 @@ pub struct EnvironmentCapabilities {
|
||||
/// Whether capability discovery applies the filesystem sandbox sent with each root.
|
||||
#[serde(default)]
|
||||
pub capability_discovery_sandbox: bool,
|
||||
/// Whether this executor supports ordered per-path metadata results in one request.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub fs_metadata_batch: bool,
|
||||
/// Whether missing metadata paths can be watched on this physical connection.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub fs_watch_missing: bool,
|
||||
@@ -330,6 +334,7 @@ impl EnvironmentInfo {
|
||||
credential_masking,
|
||||
credential_masking_custom_providers: credential_masking,
|
||||
capability_discovery_sandbox: true,
|
||||
fs_metadata_batch: true,
|
||||
fs_watch_missing: cfg!(target_os = "linux"),
|
||||
capability_discovery_v2: true,
|
||||
environment_config_read: true,
|
||||
@@ -796,6 +801,21 @@ pub struct FsGetMetadataParams {
|
||||
pub sandbox: Option<FileSystemSandboxContext>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FsGetMetadataBatchParams {
|
||||
pub paths: Vec<PathUri>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub follow_symlinks: Option<bool>,
|
||||
pub sandbox: Option<FileSystemSandboxContext>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FsGetMetadataBatchResponse {
|
||||
pub results: Vec<Result<codex_file_system::FileMetadata, JSONRPCErrorError>>,
|
||||
}
|
||||
|
||||
/// One unsandboxed metadata observation per connection. A newer id supersedes the prior watch.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -1612,6 +1632,7 @@ mod tests {
|
||||
credential_masking: false,
|
||||
credential_masking_custom_providers: false,
|
||||
capability_discovery_sandbox: true,
|
||||
fs_metadata_batch: false,
|
||||
fs_watch_missing: false,
|
||||
capability_discovery_v2: false,
|
||||
environment_config_read: false,
|
||||
|
||||
Reference in New Issue
Block a user