From 95cafae96c517628ce9dd1ed0ddb976b33bba221 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Tue, 27 Oct 2026 00:17:03 +0000 Subject: [PATCH] Format all Rust sources and clean up repository checks (#57314) ## Why Rust formatting should include source files that Cargo cannot discover, while keeping command lines within Windows limits. ## What changed - Update `scripts/format.py` to discover tracked and non-ignored untracked Rust files with Git and invoke `rustfmt` in batches of 64 files. Use the workspace configuration and skip recursive child-module formatting. - Pass `SystemDrive` and `LOCALAPPDATA` to Windows Bazel tests. - Extend the spelling allowlist, remove a manifest feature exception, and clean up an unused import, an empty MCP scenario module, and its snapshot. GitOrigin-RevId: c0d625fda9290ead6a63919325d65f7352abfa40 --- .bazelrc | 2 + .codespellignore | 2 + .../verify_cargo_workspace_manifests.py | 1 - codex-rs/app-server/src/message_processor.rs | 6 +-- codex-rs/core/tests/suite/openai_file_mcp.rs | 1 - .../tests/suite/scenarios_read_only_mcp.rs | 1 - ...read_only_mcp__read_only_mcp_requests.snap | 48 ------------------- scripts/format.py | 39 +++++++++++++-- 8 files changed, 43 insertions(+), 57 deletions(-) delete mode 100644 codex-rs/core/tests/suite/scenarios_read_only_mcp.rs delete mode 100644 codex-rs/core/tests/suite/snapshots/all__suite__scenarios__read_only_mcp__read_only_mcp_requests.snap diff --git a/.bazelrc b/.bazelrc index fafa36952a..14b941c263 100644 --- a/.bazelrc +++ b/.bazelrc @@ -45,6 +45,8 @@ common:macos --strategy=CcConfigureMakeRule=remote,sandboxed,local common:windows --test_env=SYSTEMROOT common:windows --test_env=COMSPEC common:windows --test_env=WINDIR +common:windows --test_env=SystemDrive +common:windows --test_env=LOCALAPPDATA # Rust's libtest harness runs test bodies on std-spawned threads. The default # 2 MiB stack can be too small for large async test futures on Windows CI; see # https://github.com/openai/codex/pull/19067 for the motivating failure. diff --git a/.codespellignore b/.codespellignore index 4f3c8c3513..f6c0a5de3e 100644 --- a/.codespellignore +++ b/.codespellignore @@ -1,7 +1,9 @@ iTerm iTerm2 numer +oint psuedo SOM te TE +WRONLY diff --git a/.github/scripts/verify_cargo_workspace_manifests.py b/.github/scripts/verify_cargo_workspace_manifests.py index 645c6c59e5..a8c6c28602 100644 --- a/.github/scripts/verify_cargo_workspace_manifests.py +++ b/.github/scripts/verify_cargo_workspace_manifests.py @@ -26,7 +26,6 @@ UTILITY_NAME_EXCEPTIONS = { "path-utils": "codex-utils-path", } MANIFEST_FEATURE_EXCEPTIONS = { - "codex-rs/code-mode/Cargo.toml": {"sandbox": ("v8/v8_enable_sandbox",)}, "codex-rs/v8-poc/Cargo.toml": {"sandbox": ("v8/v8_enable_sandbox",)}, } OPTIONAL_DEPENDENCY_EXCEPTIONS = set() diff --git a/codex-rs/app-server/src/message_processor.rs b/codex-rs/app-server/src/message_processor.rs index 14ef60000b..33951aa8fa 100644 --- a/codex-rs/app-server/src/message_processor.rs +++ b/codex-rs/app-server/src/message_processor.rs @@ -385,11 +385,11 @@ impl MessageProcessor { outgoing.clone(), thread_state_manager.clone(), )), - Some({ + { let time_provider = app_server_time_provider(outgoing.clone(), thread_state_manager.clone()); - time_provider - }), + Some(time_provider) + }, ); match code_mode_session_provider { Some(provider) => manager.with_code_mode_session_provider(provider), diff --git a/codex-rs/core/tests/suite/openai_file_mcp.rs b/codex-rs/core/tests/suite/openai_file_mcp.rs index 2a18b1c854..43dad210a0 100644 --- a/codex-rs/core/tests/suite/openai_file_mcp.rs +++ b/codex-rs/core/tests/suite/openai_file_mcp.rs @@ -44,7 +44,6 @@ use serde_json::json; use wiremock::Mock; use wiremock::MockServer; use wiremock::ResponseTemplate; -use wiremock::matchers::body_json; use wiremock::matchers::body_partial_json; use wiremock::matchers::header; use wiremock::matchers::method; diff --git a/codex-rs/core/tests/suite/scenarios_read_only_mcp.rs b/codex-rs/core/tests/suite/scenarios_read_only_mcp.rs deleted file mode 100644 index 2cad1c9307..0000000000 --- a/codex-rs/core/tests/suite/scenarios_read_only_mcp.rs +++ /dev/null @@ -1 +0,0 @@ -//! Thread policy reaches MCP discovery and execution without relying on model arguments. diff --git a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__read_only_mcp__read_only_mcp_requests.snap b/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__read_only_mcp__read_only_mcp_requests.snap deleted file mode 100644 index 4bd889eed6..0000000000 --- a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__read_only_mcp__read_only_mcp_requests.snap +++ /dev/null @@ -1,48 +0,0 @@ ---- -source: core/tests/suite/scenarios_read_only_mcp.rs -expression: "context_snapshot::format_request_history_snapshot(\"A read-only thread receives only read tools from the MCP server and executes a read.\",\n&mock.requests(),\n&ContextSnapshotOptions::default().rewrite_known_segments().include_request_settings(),)" ---- -Scenario: A read-only thread receives only read tools from the MCP server and executes a read. - -## Window 1 -Settings: - include: ["reasoning.encrypted_content"] - model: "gpt-5.5" - parallel_tool_calls: true - prompt_cache_key: "" - reasoning: {"effort":"medium"} - store: false - stream: true - text: {"verbosity":"low"} - tool_choice: "auto" - tools (11; hash=14a76ba72d609d9e): - - function/exec_command: Runs a command in a PTY, returning output or a session ID for ongoing interaction.; args=[cmd, justification, login, max_output_tokens, prefix_rule, sandbox_permissions, shell, tty, workdir, yield_time_ms]; hash=c04108e51a8548c5 - - function/write_stdin: Writes characters to an existing unified exec session and returns recent output.; args=[chars, max_output_tokens, session_id, yield_time_ms]; hash=7fb62d8a3e2df4e2 - - function/list_mcp_resources: Lists resources provided by MCP servers. Resources allow servers to share data that provides cont...; args=[cursor, server]; hash=6792edaff13561bd - - function/list_mcp_resource_templates: Lists resource templates provided by MCP servers. Parameterized resource templates allow servers ...; args=[cursor, server]; hash=60f17c90ef7a4ebb - - function/read_mcp_resource: Read a specific resource from an MCP server given the server name and resource URI.; args=[server, uri]; hash=24246896b39008ae - - function/request_user_input: Request user input for one to three short questions and wait for the response. This tool is only ...; args=[questions]; hash=64a729b25c424fc6 - - custom/apply_patch: The `apply_patch` tool can be used to edit files. This is a FREEFORM tool, so do not wrap the pat...; hash=dea9f12b0111a4ba - - function/view_image: View a local image file from the filesystem when visual inspection is needed. Use this for images...; args=[detail, path]; hash=3b766d5bdec5d50e - - namespace/multi_agent_v1: Tools for spawning and managing sub-agents.; hash=2327142bda177c50 - - function/close_agent - - function/resume_agent - - function/send_input - - function/spawn_agent - - function/wait_agent - - namespace/mcp__policy: Tools in the mcp__policy namespace.; hash=4868c429e15f1bec - - function/read - - web_search; hash=e214d4db1bc49e89 --- request 1 (turn) -- -00:message/developer: - -01:message/developer: - -02:message/user: - -03:message/user: - Read the report. --- request 2 (turn) -- -04:function_call/mcp__policy.read:{} -05:function_call_output:Wall time: seconds - Output: | Report ready. diff --git a/scripts/format.py b/scripts/format.py index 9b408e1c7c..cc1e96bee8 100644 --- a/scripts/format.py +++ b/scripts/format.py @@ -41,11 +41,44 @@ def just_formatter_group(*, check: bool) -> FormatterGroup: def rust_formatter_group(*, check: bool) -> FormatterGroup: - args = ["cargo", "fmt", "--", "--config", "imports_granularity=Item"] + rust_workspace = REPO_ROOT / "codex-rs" + repository_files = subprocess.check_output( + [ + "git", + "ls-files", + "-z", + "--cached", + "--others", + "--exclude-standard", + "--", + "*.rs", + ], + cwd=REPO_ROOT, + ).split(b"\0") + rust_files = sorted( + os.path.relpath(REPO_ROOT / os.fsdecode(encoded_path), rust_workspace) + for encoded_path in repository_files + if encoded_path and (REPO_ROOT / os.fsdecode(encoded_path)).is_file() + ) + # Git supplies every source file, including files Cargo cannot discover. + # Do not recursively format child modules again or include ignored files. + args = [ + "rustfmt", + "--edition", + "2024", + "--config-path", + str(rust_workspace / "rustfmt.toml"), + "--config", + "imports_granularity=Item,skip_children=true", + ] if check: args.append("--check") - command = Command(tuple(args), REPO_ROOT / "codex-rs") - return FormatterGroup("Rust", (command,)) + # Batch relative paths to stay below Windows command-line limits. + commands = tuple( + Command(tuple(args + rust_files[start : start + 64]), rust_workspace) + for start in range(0, len(rust_files), 64) + ) + return FormatterGroup("Rust", commands) def buildifier_formatter_group(*, check: bool) -> FormatterGroup: