core: load AGENTS.md from foreign environments (#28958)

## Why

Make it possible to load AGENTS.md from remote exec-servers whose OS is
different than app-server.

## What

- keep `AGENTS.md` discovery and provenance as `PathUri`, with
root-aware parent and ancestor traversal
- expose lifecycle instruction sources as legacy app-server path strings
in events while retaining `PathUri` internally
- preserve and test mixed POSIX and Windows paths in model context and
TUI status output
- cover remote Windows loading end to end by seeding the Wine prefix
through host filesystem APIs
- fix bug in `PathUri`'s parent() implementation that would erase
Windows drive letters
This commit is contained in:
Adam Perry @ OpenAI authored and GitHub committed 2026-06-18 15:06:23 -07:00
1 parent 406062c3af
commit dce673905a
38 files changed
+550 -203

No files matched your search

@@ -36,6 +36,7 @@ use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_absolute_path::test_support::PathBufExt;
use codex_utils_absolute_path::test_support::test_path_buf;
use codex_utils_path_uri::LegacyAppPathString;
use codex_utils_path_uri::PathUri;
use pretty_assertions::assert_eq;
use serde_json::Value as JsonValue;
use serde_json::json;
@@ -3685,17 +3686,49 @@ fn thread_lifecycle_responses_default_missing_optional_fields() {
serde_json::from_value(response.clone()).expect("thread/start response");
let resume: ThreadResumeResponse =
serde_json::from_value(response.clone()).expect("thread/resume response");
let fork: ThreadForkResponse = serde_json::from_value(response).expect("thread/fork response");
let fork: ThreadForkResponse =
serde_json::from_value(response.clone()).expect("thread/fork response");
assert_eq!(start.instruction_sources, Vec::<AbsolutePathBuf>::new());
assert_eq!(start.instruction_sources, Vec::<LegacyAppPathString>::new());
assert_eq!(start.thread.parent_thread_id, None);
assert_eq!(start.thread.recency_at, None);
assert_eq!(resume.instruction_sources, Vec::<AbsolutePathBuf>::new());
assert_eq!(fork.instruction_sources, Vec::<AbsolutePathBuf>::new());
assert_eq!(
resume.instruction_sources,
Vec::<LegacyAppPathString>::new()
);
assert_eq!(fork.instruction_sources, Vec::<LegacyAppPathString>::new());
assert_eq!(start.active_permission_profile, None);
assert_eq!(resume.active_permission_profile, None);
assert_eq!(resume.initial_turns_page, None);
assert_eq!(fork.active_permission_profile, None);
let foreign_source: LegacyAppPathString =
serde_json::from_value(json!(r"C:\workspace\AGENTS.md")).expect("foreign source");
let mut response_with_foreign_source = response;
response_with_foreign_source["instructionSources"] = json!([foreign_source.as_str()]);
let start: ThreadStartResponse = serde_json::from_value(response_with_foreign_source.clone())
.expect("thread/start response with foreign source");
let resume: ThreadResumeResponse = serde_json::from_value(response_with_foreign_source.clone())
.expect("thread/resume response with foreign source");
let fork: ThreadForkResponse = serde_json::from_value(response_with_foreign_source)
.expect("thread/fork response with foreign source");
assert_eq!(start.instruction_sources, vec![foreign_source.clone()]);
assert_eq!(resume.instruction_sources, vec![foreign_source.clone()]);
assert_eq!(fork.instruction_sources, vec![foreign_source]);
let foreign_source_uri =
PathUri::parse("file:///C:/workspace/AGENTS.md").expect("foreign source URI");
assert_eq!(
start.instruction_source_path_uris(),
vec![foreign_source_uri.clone()]
);
assert_eq!(
resume.instruction_source_path_uris(),
vec![foreign_source_uri.clone()]
);
assert_eq!(
fork.instruction_source_path_uris(),
vec![foreign_source_uri]
);
}
#[test]