Skip to content

test(codex_cli): build session paths component by component so hashes match on Windows - #226

Merged
mike1858 merged 1 commit into
Piebald-AI:mainfrom
NickAme03:fix-windows-test-paths
Jul 31, 2026
Merged

test(codex_cli): build session paths component by component so hashes match on Windows#226
mike1858 merged 1 commit into
Piebald-AI:mainfrom
NickAme03:fix-windows-test-paths

Conversation

@NickAme03

@NickAme03 NickAme03 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Closes #225.

test_message_hashes_remain_stable_after_archiving built the active session
directory with a single join(".codex/sessions/2026/07/22"). On Windows those
forward slashes stay inside the path string, while canonical_session_path
rebuilds the archived path one component at a time and gets native separators.
conversation_hash hashes the string form of the path, so the two sides hashed
different strings and the assertion failed.

Both paths are now built component by component, which produces the same string
on either platform. The comment above them says why, so the next person editing
this fixture does not undo it.

The other nine join calls in this file that embed slashes are left alone. They
only create directories, and Windows accepts forward slashes there, so changing
them would widen the diff without fixing anything.

Verification. 409 passed, 0 failed on both ubuntu-latest and windows-latest,
on the same tree as this branch plus a temporary workflow that is not part of the
change: https://github.com/NickAme03/splitrail/actions/runs/30660532341

The failure this fixes is visible in the run reported in #225, taken on main
before this branch existed: 404 passed and 1 failed, with Windows the only red
job. https://github.com/NickAme03/splitrail/actions/runs/30655673828

This is a test fixture fix. It does not change any counting behaviour, and the
production path stays as it was: WalkDir already yields native separators on
both sides, which is why the numbers splitrail reports were never affected.

One thing this does not do, since it belongs to you and not to a fix: checks.yml
runs only on ubuntu-latest and never runs cargo test, so nothing in CI would
have caught this and nothing will catch the next one. I am happy to add a Windows
test job in a separate pull request if you want it.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Codex CLI tests now cover Codex data-directory resolution, root-aware model configuration cases, and platform-native session paths for stable archive hash comparisons.

Changes

Codex CLI test coverage

Layer / File(s) Summary
Codex resolution and configuration cases
src/analyzers/tests/codex_cli.rs
Tests cover default, custom, and empty Codex homes, plus missing, empty, configured, blank, invalid, and incomplete model configuration files.
Native session path construction
src/analyzers/tests/codex_cli.rs
The hash-stability test builds session paths component by component and retains the hash assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: jimyag

Poem

I build each path one part at a time,
With native separators in line.
Config cases join the test parade,
Stable hashes no longer fade.
A rabbit checks the suite with glee. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The pull request also adds Codex home and fallback-model configuration tests that are unrelated to issue #225. Move the unrelated data-directory and fallback-model configuration tests to a separate pull request or link them to relevant issues.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The test paths now use component-by-component construction, which addresses the Windows hash mismatch in issue #225.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the test change that builds session paths component by component to fix Windows hash matching.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@NickAme03 NickAme03 closed this Jul 31, 2026
@NickAme03
NickAme03 force-pushed the fix-windows-test-paths branch from 2d6c39a to 74d6080 Compare July 31, 2026 19:47
@NickAme03 NickAme03 reopened this Jul 31, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/analyzers/tests/codex_cli.rs (2)

562-572: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert precedence over an existing home config.

The test creates only the custom config. It therefore proves that the custom path is read, not that it overrides ~/.codex/config.toml. Write a different model to the home config to cover the precedence rule.

💚 Proposed test strengthening
 fn test_fallback_model_respects_codex_home() {
     let dir = tempfile::tempdir().unwrap();
+    let home_codex = dir.path().join(".codex");
+    std::fs::create_dir(&home_codex).unwrap();
+    std::fs::write(home_codex.join("config.toml"), "model = \"gpt-5-mini\"\n").unwrap();
     let custom = dir.path().join("custom-codex");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/analyzers/tests/codex_cli.rs` around lines 562 - 572, Strengthen
test_fallback_model_respects_codex_home by creating a different model
configuration in the home-root config.toml before calling
get_fallback_model_with_roots. Keep the custom Codex home configuration set to
"gpt-5.5" and assert it is selected over the conflicting home configuration.

514-558: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify the fixture writes and consider a table-driven form.

Each case creates, writes, and drops a File only to replace config.toml. std::fs::write truncates and closes in one call, and Line 566 already uses it. A table of (contents, expected) pairs would also remove the repeated assertion blocks.

♻️ Proposed refactor
-    // Test case 2: empty config file
-    let mut file = std::fs::File::create(&config_path).unwrap();
-    file.write_all(b"").unwrap();
-    drop(file);
-    let model = get_fallback_model_with_roots(None, Some(dir.path()));
-    assert_eq!(model, "gpt-5");
-
-    // Test case 3: model configured in config file
-    let mut file = std::fs::File::create(&config_path).unwrap();
-    file.write_all(b"model = \"gpt-5.5\"\n").unwrap();
-    drop(file);
-    let model = get_fallback_model_with_roots(None, Some(dir.path()));
-    assert_eq!(model, "gpt-5.5");
+    // Contents of config.toml mapped to the expected fallback model.
+    for (contents, expected) in [
+        ("", "gpt-5"),                      // empty file
+        ("model = \"gpt-5.5\"\n", "gpt-5.5"), // configured model
+        ("model = \"\"\n", "gpt-5"),          // empty value
+        ("model = \"   \"\n", "gpt-5"),       // whitespace-only value
+        ("model = \n", "gpt-5"),              // invalid TOML
+        ("other_key = \"value\"\n", "gpt-5"), // model key omitted
+    ] {
+        std::fs::write(&config_path, contents).unwrap();
+        assert_eq!(
+            get_fallback_model_with_roots(None, Some(dir.path())),
+            expected,
+            "unexpected model for config {contents:?}"
+        );
+    }

Keep case 1 before the loop and case 5 after it, because neither uses a config file.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/analyzers/tests/codex_cli.rs` around lines 514 - 558, Simplify the
repeated config-file test setup in get_fallback_model_with_roots tests by
replacing each File::create/write_all/drop sequence with std::fs::write.
Consolidate cases 2–4 and 6–8 into a table-driven loop of contents and expected
models, keeping case 1 before the loop and the None home-directory case after
it. Preserve all existing inputs and assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/analyzers/tests/codex_cli.rs`:
- Around line 562-572: Strengthen test_fallback_model_respects_codex_home by
creating a different model configuration in the home-root config.toml before
calling get_fallback_model_with_roots. Keep the custom Codex home configuration
set to "gpt-5.5" and assert it is selected over the conflicting home
configuration.
- Around line 514-558: Simplify the repeated config-file test setup in
get_fallback_model_with_roots tests by replacing each
File::create/write_all/drop sequence with std::fs::write. Consolidate cases 2–4
and 6–8 into a table-driven loop of contents and expected models, keeping case 1
before the loop and the None home-directory case after it. Preserve all existing
inputs and assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b780dd40-e10f-4053-9a71-22fbd3c8086a

📥 Commits

Reviewing files that changed from the base of the PR and between fa2942e and 2d6c39a.

📒 Files selected for processing (1)
  • src/analyzers/tests/codex_cli.rs

@mike1858
mike1858 merged commit f614099 into Piebald-AI:main Jul 31, 2026
6 checks passed
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.

Codex CLI archive hash test fails on Windows

2 participants