Skip to content

fix(windows): make Codex runtime and browser workflows portable - #2522

Open
alexpozharskiy wants to merge 2 commits into
garrytan:mainfrom
alexpozharskiy:fix/windows-codex-runtime-tests
Open

fix(windows): make Codex runtime and browser workflows portable#2522
alexpozharskiy wants to merge 2 commits into
garrytan:mainfrom
alexpozharskiy:fix/windows-codex-runtime-tests

Conversation

@alexpozharskiy

Copy link
Copy Markdown

Summary

This PR repairs the Codex browser runtime and the curated Windows test suite without weakening the existing Unix paths or the untrusted-skill environment boundary.

High-impact repairs

  • Isolate cookie-import tests from the real user home. The Linux-profile fixtures previously resolved through the real Windows home and could temporarily replace ~/.config/chromium/Default/Cookies. A process crash before restoration could leave sensitive authentication state corrupted. Tests now set both HOME and USERPROFILE to a disposable directory before module import. No cookie transmission or exfiltration was observed; this is a sensitive-data integrity/privacy-boundary repair.
  • Make stop and restart deterministic. The CLI now distinguishes intentional shutdown from a crash, waits for state-file and PID teardown, and explicitly starts a replacement after restart. Regression coverage verifies both no-replacement stop behavior and healthy replacement-PID restart behavior.
  • Package the complete minimal Codex runtime. Codex setup now includes the browser server source, required top-level runtime libraries, and external packages used by the compiled/Node server path. Windows copied skill directories are refreshed and prefixed metadata is repaired before linking.
  • Use Windows-safe file URL conversion. Runtime hooks, iOS generation helpers, and tests now use fileURLToPath(import.meta.url) instead of producing /C:/... and then C:\C:\... paths.
  • Harden ACL ownership for the effective process identity. Windows ACL restriction now resolves the active principal with whoami, with a safe fallback, so inheritance removal does not lock the running process out of its own files.
  • Resolve Bun without leaking the full parent PATH. Browser skills use the absolute Bun executable and retain only Bun's directory plus system fallbacks in the untrusted environment.

Additional Windows reliability and test isolation

  • Invoke extensionless Bash hooks explicitly through Bash on Windows and normalize paths in the question-log shim.
  • Prefer signal-0 process probes before tasklist, which can be denied under restricted Windows tokens.
  • Remove import-time side effects from the terminal-agent module and respect injected server state paths.
  • Inject temporary worktree harvest roots instead of writing to persistent user state.
  • Handle optional jq, gbrain, codex, Xvfb/process utilities, Windows command shims, path separators, URL quoting, USERPROFILE, and millisecond timing assumptions in their relevant tests.
  • Exclude two tests from the Windows-safe set because they genuinely require macOS/BSD sed or symbolic-link semantics.

Root causes

The failures were a combination of Windows URL/path semantics, CreateProcess not interpreting extensionless shebang scripts, Windows key/ACL identity differences, incomplete Codex runtime packaging, and tests that assumed POSIX home/path/process behavior. Several tests also wrote state outside their fixture boundaries.

Validation

  • bun run test:windows — all 20 curated Windows-safe shards completed with zero failures (193 files).
  • bun test browse/test/stop-lifecycle.test.ts — 2 passed, 0 failed, covering real daemon stop and replacement-PID restart behavior.
  • Rebuilt browse/dist/browse.exe and browse/dist/server-node.mjs.
  • Installed-runtime start → restart → status → stop succeeded from the global Codex skill path; the replacement PID was healthy and final state was removed.
  • Global gstack-qa, gstack-review, and gstack-ship metadata and minimal runtime dependencies were verified.
  • Search for new URL(import.meta.url).pathname outside dependencies/generated output returned zero matches.
  • git diff --check completed cleanly.

Deliberately not included

  • Generated gstack/llms.txt line-ending/worktree drift.
  • A historical v1.38 migration issue where the done marker is written when jq is unavailable. Existing installations need a new forward migration; changing the historical migration alone would not backfill them.
  • Apple-only iOS execution support on Windows; Xcode/CoreDevice workflows still require a Mac.

@trunk-io

trunk-io Bot commented Aug 11, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@alexpozharskiy
alexpozharskiy force-pushed the fix/windows-codex-runtime-tests branch from ec4eb23 to dda4098 Compare August 11, 2026 12:29
@alexpozharskiy
alexpozharskiy marked this pull request as ready for review August 11, 2026 12:35
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.

1 participant