From 17fe70fdf5406c565e99f44ec93bb54d9ba7e48e Mon Sep 17 00:00:00 2001 From: Tom Wiltzius Date: Mon, 11 May 2026 23:23:19 -0700 Subject: [PATCH] Avoid git probes outside repositories The metadata rewrite added git metadata collection to live thread creation and kept SessionMeta git collection in the rollout recorder. Those paths can also run with temporary working directories that are not git repositories, especially in app-server integration tests. collect_git_info may spawn git and wait for its timeout before discovering that a directory is not a repository. On slower CI platforms that extra subprocess work made unrelated app-server startup tests miss their existing deadlines. Guard the call sites with get_git_repo_root first. Non-repository directories now skip git probing and record no git metadata, while real repository working directories still collect the same commit, branch, and remote information as before. This is a focused performance/behavior fix rather than a test timeout increase. --- codex-rs/rollout/src/recorder.rs | 15 ++++++++++----- codex-rs/thread-store/src/thread_metadata_sync.rs | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/codex-rs/rollout/src/recorder.rs b/codex-rs/rollout/src/recorder.rs index ad9f54a779..23b05b9def 100644 --- a/codex-rs/rollout/src/recorder.rs +++ b/codex-rs/rollout/src/recorder.rs @@ -48,6 +48,7 @@ use crate::default_client::originator; use crate::state_db; use crate::state_db::StateDbHandle; use codex_git_utils::collect_git_info; +use codex_git_utils::get_git_repo_root; use codex_protocol::protocol::GitInfo as ProtocolGitInfo; use codex_protocol::protocol::InitialHistory; use codex_protocol::protocol::ResumedHistory; @@ -1580,11 +1581,15 @@ async fn write_session_meta( session_meta: SessionMeta, cwd: &Path, ) -> std::io::Result<()> { - let git_info = collect_git_info(cwd).await.map(|info| ProtocolGitInfo { - commit_hash: info.commit_hash, - branch: info.branch, - repository_url: info.repository_url, - }); + let git_info = if get_git_repo_root(cwd).is_some() { + collect_git_info(cwd).await.map(|info| ProtocolGitInfo { + commit_hash: info.commit_hash, + branch: info.branch, + repository_url: info.repository_url, + }) + } else { + None + }; let session_meta_line = SessionMetaLine { meta: session_meta, git: git_info, diff --git a/codex-rs/thread-store/src/thread_metadata_sync.rs b/codex-rs/thread-store/src/thread_metadata_sync.rs index 38a1293a7b..e40ae64217 100644 --- a/codex-rs/thread-store/src/thread_metadata_sync.rs +++ b/codex-rs/thread-store/src/thread_metadata_sync.rs @@ -5,6 +5,7 @@ use chrono::DateTime; use chrono::NaiveDateTime; use chrono::Utc; use codex_git_utils::collect_git_info; +use codex_git_utils::get_git_repo_root; use codex_protocol::ThreadId; use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::GitInfo; @@ -51,11 +52,15 @@ impl ThreadMetadataSync { pub(crate) async fn for_create(params: &CreateThreadParams) -> Self { let created_at = Utc::now(); let cwd = params.metadata.cwd.clone().unwrap_or_default(); - let git_info = collect_git_info(cwd.as_path()).await.map(|info| GitInfo { - commit_hash: info.commit_hash, - branch: info.branch, - repository_url: info.repository_url, - }); + let git_info = if get_git_repo_root(cwd.as_path()).is_some() { + collect_git_info(cwd.as_path()).await.map(|info| GitInfo { + commit_hash: info.commit_hash, + branch: info.branch, + repository_url: info.repository_url, + }) + } else { + None + }; let dynamic_tools = (!params.dynamic_tools.is_empty()).then(|| params.dynamic_tools.clone()); let update = ThreadMetadataPatch {