Skip to content

[codex] Report structured Git status refusals - #30863

Open
bookholt-oai wants to merge 27 commits into
codex/psec-4394-git-06-merge-guardfrom
codex/psec-4396-git-07-status-guard
Open

bookholt-oai wants to merge 27 commits into
codex/psec-4394-git-06-merge-guardfrom
codex/psec-4396-git-07-status-guard

Conversation

@bookholt-oai

@bookholt-oai bookholt-oai commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Why

Workspace change detection currently reduces Git failures to an unavailable boolean. It can also let git status select 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

  • Add try_get_has_changes, which returns the change result or a structured GitReadError.
  • Keep get_has_changes as the existing best-effort compatibility wrapper.
  • Report has_changes_unavailable_reason in turn metadata when the safe read cannot complete.
  • Limit this PR to status and workspace-change detection; remote-diff behavior is unchanged.

This PR is stacked on #30854 and should land after it.

How

  • Use one trusted, repository-authorized Git runner for preparation and the final status child, while preserving lexical repository ancestry across symlinked paths.
  • Keep status command routing, executable-filter screening, and frozen-status orchestration in focused private sibling modules.
  • Build an operation-owned read context that freezes the authorized config, attributes, HEAD, untracked-presence result, repository format, replacement-ref policy, index view, and effective core.symlinks setting.
  • Inventory only stage-zero index entries whose worktree representation can select content filters, neutralize executable filter namespaces, and disambiguate Git's set/unset/unspecified attribute spellings with bounded helper-free attribute pathspecs.
  • Normalize Git's implicit spelling to true only for Boolean-capable status keys; keep path-, enum-, list-, and integer-valued keys strict.
  • Encode isolated alternate-object directories with Git's C-style path grammar so platform path-list separators and backslashes remain path data.
  • Run a fixed git status --porcelain --ignore-submodules=dirty --untracked-files=no command with hooks, fsmonitor, optional locks, filters, and replacement objects disabled.
  • Bound child output and the full operation deadline, and kill the active child on cancellation.

Testing

  • just test -p codex-git-utils — 393 passed.
  • Focused regressions cover implicit Boolean projection, alternate-object paths containing platform separators, native and emulated symlinks, gitlinks, unmerged stages, and core.symlinks projection 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, then just fmt — completed.

@bookholt-oai
bookholt-oai marked this pull request as ready for review July 1, 2026 19:59
@bookholt-oai
bookholt-oai requested a review from a team as a code owner July 1, 2026 19:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread codex-rs/git-utils/src/safe_git.rs Resolved
@bookholt-oai
bookholt-oai marked this pull request as draft July 2, 2026 01:02
@bookholt-oai
bookholt-oai marked this pull request as ready for review July 7, 2026 05:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread codex-rs/git-utils/src/git_command.rs Resolved
Comment thread codex-rs/git-utils/Cargo.toml Resolved
@bookholt-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread codex-rs/git-utils/Cargo.toml Resolved
@bookholt-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@bookholt-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +111 to +114
let entries = self
.sources
.read_effective_async(STATUS_SAFE_CONFIG_PATTERN, "status allowlist")
.await?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant