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:
dozaki-openai
2026-11-23 05:39:53 +00:00
committed by copyberry
parent 794584993e
commit 5f645d732c
17 changed files with 537 additions and 45 deletions
@@ -39,6 +39,8 @@ use crate::protocol::FsCopyParams;
use crate::protocol::FsCopyResponse;
use crate::protocol::FsCreateDirectoryParams;
use crate::protocol::FsCreateDirectoryResponse;
use crate::protocol::FsGetMetadataBatchParams;
use crate::protocol::FsGetMetadataBatchResponse;
use crate::protocol::FsGetMetadataParams;
use crate::protocol::FsGetMetadataResponse;
use crate::protocol::FsOpenParams;
@@ -419,6 +421,14 @@ impl ExecServerHandler {
.map_err(|error| crate::rpc::internal_error(error.to_string()))?
}
pub(crate) async fn fs_get_metadata_batch(
&self,
params: FsGetMetadataBatchParams,
) -> Result<FsGetMetadataBatchResponse, JSONRPCErrorError> {
self.require_initialized_for("filesystem")?;
self.file_system.get_metadata_batch(params).await
}
pub(crate) async fn fs_get_metadata(
&self,
params: FsGetMetadataParams,