Skip to content

fix(service): align WSL Codex home ownership - #1427

Merged
Wibias merged 2 commits into
devfrom
agent/fix-wsl-service-home
Aug 10, 2026
Merged

fix(service): align WSL Codex home ownership#1427
Wibias merged 2 commits into
devfrom
agent/fix-wsl-service-home

Conversation

@Ingwannu

@Ingwannu Ingwannu commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • resolve service install-state ownership through the same Codex-home resolver used by the runtime
  • preserve explicit CODEX_HOME authority while allowing the existing narrow WSL single-Windows-home discovery when it is unset
  • keep ambiguous or genuinely foreign service state fail-closed and document the ownership decision

Root cause

The runtime already used the WSL-aware resolveCodexHomeDir(), but service ownership independently recorded CODEX_HOME || ~/.codex. In a Windows Desktop + WSL layout with one discoverable Windows Codex home, the service could therefore record Linux ~/.codex while the proxy actually used the Windows home. Later repair or uninstall then looked foreign even in the same environment.

User impact

New service installs and same-environment ownership checks now agree with runtime Codex-home targeting. The patch does not migrate or take over existing foreign service state.

Verification

  • bun test tests/codex-home-wsl.test.ts tests/service.test.ts: 106 passed, 0 failed
  • focused WSL regression rerun: 5 passed, 0 failed
  • bun run typecheck: passed
  • bun run privacy:scan: passed
  • git diff --check: passed
  • full-suite rerun was not repeated after the same clean-origin/dev host showed the documented service-token inheritance failure and the CPU-limited suite showed unrelated endpoint admission timeouts; exact-head GitHub CI remains required before readiness

Closes #1400

Summary by CodeRabbit

  • Bug Fixes

    • Service ownership now consistently uses the resolved Codex home, including Windows Codex locations when running under WSL.
    • Explicit Codex home paths remain honored without being automatically migrated.
  • Documentation

    • Added guidance and decision notes describing Codex home resolution and service ownership behavior.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Wibias, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 755769df-d8a5-4368-b6a7-ea904133a6b6

📥 Commits

Reviewing files that changed from the base of the PR and between af11b4e and 2416e5e.

📒 Files selected for processing (1)
  • src/service.ts
📝 Walkthrough

Walkthrough

currentServiceHomes now uses the shared WSL-aware Codex-home resolver. The change adds dependency injection, documents ownership behavior, and tests Windows Codex-home discovery under WSL.

Changes

Codex-home resolution

Layer / File(s) Summary
Integrate the shared Codex-home resolver
src/service.ts
currentCodexHome delegates resolution to resolveCodexHomeDir. currentServiceHomes accepts optional CodexHomeDeps and forwards them while preserving OpenCodex-home resolution.
Validate WSL service-home ownership
tests/codex-home-wsl.test.ts, structure/02_config-and-codex-home.md
The WSL test verifies selection of the discovered Windows Codex home. The documentation records resolver behavior, explicit overrides, and unchanged foreign ownership records.

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

Possibly related PRs

  • lidge-jun/opencodex#503: Both changes cover shared Codex-home resolution, service ownership, WSL behavior, documentation, and tests.

Suggested labels: review-ready

Suggested reviewers: lidge-jun, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: aligning service Codex-home ownership with WSL-aware resolution.
Linked Issues check ✅ Passed The changes use the shared WSL-aware resolver, preserve explicit paths, and add coverage for issue #1400’s service ownership mismatch.
Out of Scope Changes check ✅ Passed The service change, decision-log documentation, and WSL regression test directly support the linked issue and stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-wsl-service-home

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.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 10, 2026
@Ingwannu
Ingwannu requested review from Wibias and lidge-jun August 10, 2026 14:42
@Wibias
Wibias marked this pull request as ready for review August 10, 2026 22:43
@Wibias
Wibias force-pushed the agent/fix-wsl-service-home branch from ac632b9 to af11b4e Compare August 10, 2026 22:44

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/service.ts`:
- Around line 97-101: Update assertServiceEnvironmentMatchesInstall() to call
currentCodexHome() once, store the resolved path in a local variable, and reuse
that value for both the ownership comparison and any error reporting instead of
resolving it separately.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cfe2238b-0969-405a-8c81-e9d6ad499607

📥 Commits

Reviewing files that changed from the base of the PR and between bdd89e6 and af11b4e.

📒 Files selected for processing (3)
  • src/service.ts
  • structure/02_config-and-codex-home.md
  • tests/codex-home-wsl.test.ts

Comment thread src/service.ts
Reuse a single currentCodexHome() result for comparison and error
reporting so WSL discovery cannot diverge between the two calls.
@Wibias
Wibias merged commit 7b377ce into dev Aug 10, 2026
45 of 47 checks passed
@Wibias

Wibias commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Ingwannu — merged.

This closes #1400 with a small but important alignment fix. The runtime already resolved Codex home through the WSL-aware resolveCodexHomeDir(), but service install-state still recorded CODEX_HOME || ~/.codex independently. On Windows Desktop + WSL with a single discoverable Windows Codex home, that meant the service could record Linux ~/.codex while the proxy actually used the Windows home — so later repair/uninstall looked "foreign" even in the same environment.

Routing service ownership through the same resolver keeps explicit CODEX_HOME authority, preserves the narrow WSL discovery path when unset, and stays fail-closed for genuinely foreign state. The regression test and structure note make the ownership contract hard to regress.

Appreciate the focused scope and the follow-up fix to resolve the Codex home once per ownership check.

@Wibias
Wibias deleted the agent/fix-wsl-service-home branch August 10, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants