[PR #12] [CLOSED] feat: add windows support and fix integration tests #88

Closed
opened 2026-02-27 10:22:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mikeyobrien/ralph-orchestrator/pull/12
Author: @procGro
Created: 12/31/2025
Status: Closed

Base: mainHead: fix/windows-support


📝 Commits (1)

  • d16c361 feat: add windows support and fix integration tests

📊 Changes

9 files changed (+264 additions, -81 deletions)

View changed files

patch_windows.sh (+21 -0)
📝 pyproject.toml (+1 -0)
📝 ralph.yml (+12 -40)
📝 src/ralph_orchestrator/adapters/qchat.py (+39 -12)
📝 src/ralph_orchestrator/context.py (+2 -2)
📝 tests/test_integration.py (+45 -22)
📝 tests/test_qchat_adapter.py (+13 -3)
📝 tests/test_qchat_integration.py (+11 -2)
📝 uv.lock (+120 -0)

📄 Description

Summary of changes:

This PR enables ralph-orchestrator to run on Windows environments. Previously, the tool would crash on import due to Unix-specific dependencies (fcntl) and fail during execution due to default OS encoding issues.

  • Unix Dependency Mocking: In src/ralph_orchestrator/adapters/qchat.py, I added a conditional import for fcntl. On Windows, a MagicMock style class is used to prevent ImportError, allowing the adapter to load safely.

  • UTF-8 Enforcement: Forced encoding="utf-8" on all Path.write_text() and read_text() calls. Windows defaults to cp1252, which caused crashes when encountering non-ASCII characters in prompt files.

  • Async/Sync Bridge: Since Windows unittest often struggles with async test methods, I refactored test_orchestrator_checkpoint_creation to use a standard def with an internal asyncio.run() call.

  • Setup Lifecycle: Fixed the TestOrchestratorIntegration class where self.orchestrator was not being initialized in setUp(), causing AttributeError across the suite.

  • Git Side-Effect Verification: Refactored checkpoint tests to verify success by checking the git rev-list --count, ensuring the orchestrator actually performs commits in the local environment.

Environment: Windows 11, Python 3.12.0
Command: uv run pytest tests/test_integration.py -v

  • 10 PASSED
  • 7 SKIPPED (Legacy/Manual tests)

Why I changed Git verification to use commit counts

In the original test, we were asserting against the return value of _create_checkpoint(). However, I refactored this to use git rev-list --count for several reasons:

Action vs. Return Value: The primary purpose of a checkpoint is the side effect (saving the state to history). Verifying that the commit count actually increased is a "black-box" test that proves the orchestrator successfully communicated with the OS-level Git binary.

Windows NoneType Consistency: On Windows, depending on the shell environment and Git version, some internal Git commands may return different exit codes or empty strings that cause the orchestrator to return None even if the commit was successful.

Decoupling: This approach makes the test less brittle. It focuses on the result (a new commit in the log) rather than the internal implementation of how the method returns its success status.
Component Status Detail
Claude SDK Verified with sdk-based adapter
  • Q Chat Execution: The fix ensures the code runs on Windows, but full Q Chat tool execution still requires the q CLI to be configured in the Windows path.
  • Token Extraction: test_claude_token_extraction remains skipped as it needs a rewrite to support the current SDK response schema.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mikeyobrien/ralph-orchestrator/pull/12 **Author:** [@procGro](https://github.com/procGro) **Created:** 12/31/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/windows-support` --- ### 📝 Commits (1) - [`d16c361`](https://github.com/mikeyobrien/ralph-orchestrator/commit/d16c361ecd3d08171e21880fe88f3628e3220805) feat: add windows support and fix integration tests ### 📊 Changes **9 files changed** (+264 additions, -81 deletions) <details> <summary>View changed files</summary> ➕ `patch_windows.sh` (+21 -0) 📝 `pyproject.toml` (+1 -0) 📝 `ralph.yml` (+12 -40) 📝 `src/ralph_orchestrator/adapters/qchat.py` (+39 -12) 📝 `src/ralph_orchestrator/context.py` (+2 -2) 📝 `tests/test_integration.py` (+45 -22) 📝 `tests/test_qchat_adapter.py` (+13 -3) 📝 `tests/test_qchat_integration.py` (+11 -2) 📝 `uv.lock` (+120 -0) </details> ### 📄 Description Summary of changes: This PR enables `ralph-orchestrator` to run on Windows environments. Previously, the tool would crash on import due to Unix-specific dependencies (`fcntl`) and fail during execution due to default OS encoding issues. - **Unix Dependency Mocking**: In `src/ralph_orchestrator/adapters/qchat.py`, I added a conditional import for `fcntl`. On Windows, a `MagicMock` style class is used to prevent `ImportError`, allowing the adapter to load safely. - **UTF-8 Enforcement**: Forced `encoding="utf-8"` on all `Path.write_text()` and `read_text()` calls. Windows defaults to `cp1252`, which caused crashes when encountering non-ASCII characters in prompt files. - **Async/Sync Bridge**: Since Windows `unittest` often struggles with `async` test methods, I refactored `test_orchestrator_checkpoint_creation` to use a standard `def` with an internal `asyncio.run()` call. - **Setup Lifecycle**: Fixed the `TestOrchestratorIntegration` class where `self.orchestrator` was not being initialized in `setUp()`, causing `AttributeError` across the suite. - **Git Side-Effect Verification**: Refactored checkpoint tests to verify success by checking the `git rev-list --count`, ensuring the orchestrator actually performs commits in the local environment. **Environment:** Windows 11, Python 3.12.0 **Command:** `uv run pytest tests/test_integration.py -v` - **10 PASSED** - **7 SKIPPED** (Legacy/Manual tests) Why I changed Git verification to use commit counts In the original test, we were asserting against the return value of _create_checkpoint(). However, I refactored this to use git rev-list --count for several reasons: Action vs. Return Value: The primary purpose of a checkpoint is the side effect (saving the state to history). Verifying that the commit count actually increased is a "black-box" test that proves the orchestrator successfully communicated with the OS-level Git binary. Windows NoneType Consistency: On Windows, depending on the shell environment and Git version, some internal Git commands may return different exit codes or empty strings that cause the orchestrator to return None even if the commit was successful. Decoupling: This approach makes the test less brittle. It focuses on the result (a new commit in the log) rather than the internal implementation of how the method returns its success status. | Component | Status | Detail | | :--- | :--- | :--- | | Claude SDK | ✅ | Verified with sdk-based adapter | | Orchestrator | ✅ | Checkpoints, Fallbacks, and Safety limits verified | | Q Chat | ⚠️ | Adapter loads; integration tests skipped (requires manual env) | - **Q Chat Execution**: The fix ensures the code *runs* on Windows, but full Q Chat tool execution still requires the `q` CLI to be configured in the Windows path. - **Token Extraction**: `test_claude_token_extraction` remains skipped as it needs a rewrite to support the current SDK response schema. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 10:22:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#88
No description provided.