Skip to content

fix(service): accept legacy WSL ownership state - #262

Draft
luvs01 wants to merge 1 commit into
devfrom
codex/fix-wsl-service-ownership-check-issue
Draft

luvs01 wants to merge 1 commit into
devfrom
codex/fix-wsl-service-ownership-check-issue

Conversation

@luvs01

@luvs01 luvs01 commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent legitimate WSL installs written by older releases (which recorded Linux ~/.codex) from being treated as foreign after runtime WSL home discovery changed to a Windows Desktop path.
  • Restore repair/stop/uninstall usability for those legacy installs while keeping explicit CODEX_HOME authoritative.

Description

  • Add serviceCodexHomeMatchesInstall(recordedHome, deps) which accepts an exact legacy ~/.codex record when running under WSL with CODEX_HOME unset and otherwise enforces strict path equality.
  • Update assertServiceEnvironmentMatchesInstall() to use the compatibility-aware comparator for codexHome while preserving the existing OPENCODEX_HOME comparison logic.
  • Add a focused regression test in tests/codex-home-wsl.test.ts that verifies WSL Windows-home discovery and the legacy-Linux fallback acceptance and non-acceptance cases.
  • Document the narrowly scoped compatibility exception in structure/02_config-and-codex-home.md and leave all other foreign ownership records unmigrated.

Testing

  • Ran ./node_modules/.bin/bun test tests/codex-home-wsl.test.ts which passed (6/6).
  • Ran ./node_modules/.bin/bun run typecheck and ./node_modules/.bin/bun run privacy:scan which succeeded.
  • Ran ./node_modules/.bin/bun test tests/service.test.ts --timeout 15000 which showed 112 passing service tests and one unrelated pre-existing assertion failure in this checkout.
  • Verified git diff --check and committed the change as fix(service): accept legacy WSL ownership state.

Codex Task

Summary by CodeRabbit

  • Bug Fixes

    • Improved service installation checks in WSL environments when transitioning from the legacy Linux Codex home to the discovered Windows Codex home.
    • Preserved explicit CODEX_HOME overrides as authoritative.
    • Prevented unrelated or foreign home paths from being incorrectly accepted as matching installations.
  • Documentation

    • Clarified service ownership and Codex home matching behavior for WSL installations.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: ff63031c-006a-44e1-bdb4-8e763affa0e3

📥 Commits

Reviewing files that changed from the base of the PR and between d08d11f and 114ece2.

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

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The service now accepts the legacy Linux ~/.codex record when WSL discovers a Windows Codex home. Explicit CODEX_HOME values remain authoritative. Tests and ownership documentation cover the new matching behavior.

Changes

WSL Codex home matching

Layer / File(s) Summary
Legacy home matching and ownership validation
src/service.ts, tests/codex-home-wsl.test.ts, structure/02_config-and-codex-home.md
The new serviceCodexHomeMatchesInstall helper accepts the legacy Linux home only when WSL is active and CODEX_HOME is unset. Service ownership validation uses the helper. Tests cover matching, rejection of other paths, and explicit override behavior. Documentation records the rule.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: lidge-jun

Merge Risk: ⚪ Minimal · up to 114ec

The legacy WSL ownership record is accepted only in its intended compatibility case, while explicit overrides and unrelated ownership records retain strict matching. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: accepting legacy WSL service ownership state. It matches the compatibility behavior implemented in src/service.ts and covered by the tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 3
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch codex/fix-wsl-service-ownership-check-issue
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-wsl-service-ownership-check-issue

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 github-actions Bot added the bug Something isn't working label Aug 13, 2026
@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 114ece2949

ℹ️ 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 src/service.ts
Comment on lines +249 to +252
const env = deps.env ?? process.env;
if (env.CODEX_HOME?.trim() || !isWslRuntime(deps)) return false;
const legacyDefault = join((deps.homedir ?? homedir)(), ".codex");
return serviceHomeMatches(recordedHome, legacyDefault);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve explicitly pinned Linux-home ownership

When a WSL service was intentionally installed with CODEX_HOME=/home/$USER/.codex, but that home has no config.toml—for example, because Codex integration was disabled—a later shell with CODEX_HOME unset can discover the sole Windows home. This fallback cannot distinguish that explicit install record from legacy implicit metadata and returns true, so repair silently rewrites the unit and state for the Windows home, while stop/uninstall restore the wrong home. Only accept the compatibility case when the installed launcher/state proves the original home was implicit.

Useful? React with 👍 / 👎.

Comment thread src/service.ts
const expected = normalizePathForCompare(state.codexHome);
const actual = normalizePathForCompare(actualCodexHome);
if (expected !== actual) {
if (!serviceCodexHomeMatchesInstall(state.codexHome)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compare against one Codex-home snapshot

In WSL, home discovery depends on live config.toml files and candidate directories, but assertServiceEnvironmentMatchesInstall() resolves actualCodexHome and then this call resolves it again inside serviceCodexHomeMatchesInstall(). If candidates change between those reads, the check can reject a matching record while reporting identical installed/current paths, or accept based on a different snapshot. Pass the already-resolved actualCodexHome into the compatibility comparison so ownership and diagnostics use the same result.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot changed the title fix(service): accept legacy WSL ownership state [WRONG BRANCH] fix(service): accept legacy WSL ownership state Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

✅ READY

  • all PR quality gates passed.

Hygiene

Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft August 13, 2026 00:44
@luvs01 luvs01 closed this Aug 19, 2026
@luvs01 luvs01 reopened this Aug 19, 2026
@luvs01 luvs01 changed the title [WRONG BRANCH] fix(service): accept legacy WSL ownership state fix(service): accept legacy WSL ownership state Sep 3, 2026
@luvs01
luvs01 changed the base branch from main to dev September 3, 2026 06:24
@github-actions
github-actions Bot marked this pull request as ready for review September 3, 2026 06:33
@luvs01
luvs01 marked this pull request as draft September 14, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant