Repository navigation
[codex] Report structured Git status refusals - #30863
bookholt-oai wants to merge 27 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52b2106666
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ec-4396-git-07-status-guard # Conflicts: # codex-rs/git-utils/src/errors.rs # codex-rs/git-utils/src/git_command.rs # codex-rs/git-utils/src/safe_git.rs # codex-rs/git-utils/src/safe_git_tests.rs
…ec-4396-git-07-status-guard
…6-git-07-status-guard
# Conflicts: # codex-rs/git-utils/src/git_command.rs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8413b04e1a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a44ec411cf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d5d8b3c46
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub(crate) has_changes: Option<bool>, | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub(crate) has_changes_unavailable_reason: Option<codex_git_utils::GitReadError>, |
There was a problem hiding this comment.
Bound Git refusal details before metadata
When a repo triggers a structured status refusal such as SelectedExecutableFilter, this field serializes the raw GitReadError into x-codex-turn-metadata via both client metadata and compatibility headers. The driver/path strings come from repo-controlled Git config/index data and are only bounded by the internal Git-output cap, so a crafted repo can make this metadata megabytes long and cause subsequent Responses/MCP requests to exceed request/header limits instead of simply reporting status as unavailable; please cap or summarize these details before storing them in turn metadata.
AGENTS.md reference: AGENTS.md:L97-L99
Useful? React with 👍 / 👎.
| windows-sys = { version = "0.52", features = ["Win32_Storage_FileSystem"] } | ||
|
|
||
| [dev-dependencies] | ||
| futures = { workspace = true, features = ["executor"] } |
There was a problem hiding this comment.
Refresh the Bazel lock after dependency changes
This change adds a new futures dev-dependency (and changes the tokio feature set above), but the diff does not include MODULE.bazel.lock or Cargo.lock; CI verifies Bazel lock drift for Cargo.toml changes, so this will fail the lockfile check until just bazel-lock-update is run and the resulting lockfile update is included.
AGENTS.md reference: AGENTS.md:L37-L39
Useful? React with 👍 / 👎.
| get_head_commit_hash(&self.cwd), | ||
| get_git_remote_urls_assume_git_repo(&self.cwd), | ||
| get_has_changes(&self.cwd), | ||
| Box::pin(try_get_has_changes(&self.cwd)), |
There was a problem hiding this comment.
Add integration coverage for status refusals
This new call path is what converts a real GitReadError from status into turn metadata, but the added coverage only serializes synthetic workspace values and does not exercise a live refusal through the Responses request path. A wiring regression could still drop has_changes_unavailable_reason from outbound turn metadata; add an integration test that creates a repo with a refused status condition and asserts the header/client metadata contains the structured reason.
AGENTS.md reference: AGENTS.md:L114-L118
Useful? React with 👍 / 👎.
| try_get_has_changes(cwd).await.ok() | ||
| } | ||
|
|
||
| pub async fn try_get_has_changes(cwd: &Path) -> Result<bool, GitReadError> { |
There was a problem hiding this comment.
Split the guarded status pipeline into stages
This entry point lands a non-mechanical guarded status implementation together with metadata propagation, async Git runner changes, config-source parsing, multiple new status modules, and large regression suites in one 6k+ line diff. The API/metadata Result propagation can land independently from the guarded status engine, which would make the security-sensitive review much more tractable and match the repository’s staged-change guidance.
AGENTS.md reference: AGENTS.md:L125-L131
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1941f1c02
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let entries = self | ||
| .sources | ||
| .read_effective_async(STATUS_SAFE_CONFIG_PATTERN, "status allowlist") | ||
| .await?; |
There was a problem hiding this comment.
Normalize implicit booleans before status projection
When a repository uses Git's valid implicit-boolean spelling for any allowlisted status key (for example [core] followed by filemode), this projection path calls read_effective_async, which uses the strict GitConfigEntry parser and rejects records without a key/value separator; Git documents that “a variable defined without = is taken as true” (git-config). That makes try_get_has_changes report the status as unavailable even though git status succeeds, so the new metadata path regresses valid configuration loading unless these boolean allowlist entries are normalized or parsed permissively before writing the frozen config.
Useful? React with 👍 / 👎.
Why
Workspace change detection currently reduces Git failures to an unavailable boolean. It can also let
git statusselect repository-configured executable filters before the caller knows whether the read is safe.Callers need either a safe status result or a useful explanation of why that result is unavailable.
What
try_get_has_changes, which returns the change result or a structuredGitReadError.get_has_changesas the existing best-effort compatibility wrapper.has_changes_unavailable_reasonin turn metadata when the safe read cannot complete.This PR is stacked on #30854 and should land after it.
How
core.symlinkssetting.set/unset/unspecifiedattribute spellings with bounded helper-free attribute pathspecs.trueonly for Boolean-capable status keys; keep path-, enum-, list-, and integer-valued keys strict.git status --porcelain --ignore-submodules=dirty --untracked-files=nocommand with hooks, fsmonitor, optional locks, filters, and replacement objects disabled.Testing
just test -p codex-git-utils— 393 passed.core.symlinksprojection drift.RUST_MIN_STACK=16777216 cargo test -p codex-core --test responses_headers responses_stream_includes_turn_metadata_header_for_git_workspace_e2e -- --exact --nocapture— passed.cargo check -p codex-git-utils --all-targets— passed.cargo clippy -p codex-git-utils --all-targets -- -D warnings— passed.just argument-comment-lint— passed.just bazel-lock-update— completed with no lockfile change.just fix -p codex-git-utils, thenjust fmt— completed.