Skip to content

fix(windows): preserve PowerShell environment and activity paths - #634

Merged
faizan-oai merged 2 commits into
mainfrom
agent/windows-powershell-environment
Aug 28, 2026
Merged

fix(windows): preserve PowerShell environment and activity paths#634
faizan-oai merged 2 commits into
mainfrom
agent/windows-powershell-environment

Conversation

@faizan-oai

@faizan-oai faizan-oai commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve the selected Codex home when Windows environment objects retain a non-uppercase CODEX_HOME spelling, and report repository file activity from ordinary PowerShell commands.

Changes

  • Reuse the existing environment lookup for Windows skill commands before normalizing the child environment. Keep exact-name behavior on other platforms.
  • Recognize standard and braced PowerShell repository-environment references, including Windows case aliases.
  • Unwrap the native PowerShell/pwsh -Command event form while retaining the script's inner quotes.
  • Extend existing regressions for copied environments, emitted and persisted command events, literal text, unrelated variables, and paths outside the repository.
  • Integrate the current canonical-plugin source/build layout while preserving the four-file PowerShell fix and newer CLI behavior.

Testing

Current main integration

Validated the integration of main 9bd256a on Windows using Node 24.19.0, Bun 1.3.14, pnpm 11.9.0, and npm 10.9.2:

  • Frozen SDK dependencies and canonical MCP dependencies installed without lockfile changes.
  • build:plugin, check:plugin-source, types, format, build, and git diff --check: passed. The 118-file generated plugin payload remains ignored, not tracked.
  • bun test --timeout 30000 tests-ts/cli-skills.test.ts tests-ts/scan-activity.test.ts tests-ts/build-plugin.test.ts: 70 passed, 1 existing Windows skip, 0 failed, 374 assertions; reported seed 678080754.
  • Native PowerShell 5.1/7 checks: 6/6 copied-environment controls, 12/12 public patch/verify-fix entrypoint controls, and 16/16 read/literal activity controls passed. Two previously captured native SDK events replay correctly against the current compiled parser. Service/worker fixtures are synthetic; this is not a completed model-backed scan.
  • pnpm pack and node scripts/check-package.mjs <exact-tgz>: passed. The one-argument check ran the full installed smoke, including public import, NodeNext types, CLI, credential locking, MCP initialization, bundled Codex, and a nested worker without global Codex. It validated 282 archive entries in 72.04 seconds. The supported npm_execpath selects npm 10.9.2, executed by Node 24.19.0; no smoke stage or timeout was changed.
  • Initial pnpm preflight/launcher failures were retained separately; the run settings were aligned with the installed store layout before the successful checks. A historical synthetic service stub was refreshed for current imports/API shape before the native entrypoint checks passed. Neither is reported as a product fix or an explanation for unrelated CI failures.

The initial exact-head node-ci run passed all 28 jobs on 1e5f029, including both Windows package-inspection jobs. Codex code review reported no major issues on this head. At this description update, the additional automatic CI run and requested maintainer re-review remain to be verified. The patch relative to main is still the original four files.

Earlier validation before this integration

  • Final focused tests, seed 12345: 64 passed, 1 existing Windows skip, 0 failed.
  • Package types, formatting, build, and git diff --check: passed.
  • Native Windows controls: PowerShell 5.1/7 CLI matrix 12/12 passed using synthetic integration and worker fixtures; environment forwarding 6/6 passed; PowerShell read/literal controls 16/16 passed.
  • Replayed 2 actual native SDK command events against the final compiled parser: both now report the expected repository path. The synthetic localhost replay does not constitute a completed security scan.
  • Earlier full seeded package run: 1,638 passed, 59 skipped, 1 failed. The failure was a Python subprocess returning null status in workbench-scan-root-alias.test.ts; the same isolated test passes on both unchanged main and this branch, so its cause remains unresolved. That full run predates the final launcher-parser addition; final-source full-suite CI is required.

Risk and rollout

No new CLI flags, environment variables, or dependencies. The home-selection change is Windows-only. Activity changes affect displayed commands and file paths, not scan coverage. POSIX variable-name behavior and existing literal/traversal filtering remain covered. Absolute Windows root-case matching and authentication setup guidance are outside this patch.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@github-actions github-actions Bot added the bug Something isn't working label Aug 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-27T19:49:36.192878Z 1e5f029 Manual request
🔒 Security Review Completed 2026-08-24T18:34:35.754281Z 237dc00 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Contributor Author

@mldangelo-oai — could you review this Windows environment and PowerShell activity fix? Final focused tests and native controls pass; the PR description records the unresolved broader-suite subprocess failure separately. Cross-platform CI is running.

@codex review the current head 237dc0005300afaeeee9d1a222aaba18136f7c1c.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 237dc00053

ℹ️ 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".

@kmbroai kmbroai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Critical review

Reviewed 237dc0005300afaeeee9d1a222aaba18136f7c1c. No blocking correctness issue found. The Codex-home fix is necessary; the activity-parser changes are useful but optional presentation work.

Necessity and scope

The home lookup must happen before deleting case aliases from the copied environment. On Windows a plain copied object does not provide the native environment object's case-insensitive lookup behavior, so reading only the uppercase key can discard the user's selected home. Reusing environmentValue on Windows and emitting one canonical child key is the right small fix; preserving POSIX case sensitivity is important.

PowerShell launcher unwrapping and repository-variable recognition improve activity display, but they do not make scans more complete or change coverage. If the parser needs further iteration, it should not delay landing the independent environment fix. Separate commits would make that distinction easier to retain; a larger redesign is unnecessary.

Correctness and simplification

The launcher match is intentionally limited to the emitted -Command form and verifies the executable basename. The path normalization excludes single-quoted variable literals and unrelated variables before reusing the existing traversal filter. That is preferable to trying to implement a general PowerShell parser for optional progress reporting.

Keep unsupported launch forms unchanged rather than guessing. Do not expand this patch into arbitrary PowerShell switches, encoded commands, evaluation of variables, or a dependency on executing PowerShell to discover paths. Similarly, keep inferred activity separate from authoritative coverage. The existing whitespace/token heuristics mean this is still a best-effort display parser, not an exact shell interpreter.

The test cases for literal quotes, escaped variable sigils, mixed-case environment names, and parent traversal are the valuable coverage here; no extra generic parser framework is warranted.

Verification

Ran scan-activity.test.ts and cli-skills.test.ts: 66 passed, 0 failed on Bun 1.3.14/Linux with locally available dependencies. Also ran 4/4 synthetic controls against the actual parser with its platform dependency set to Windows, covering ordinary/braced variables, a single-quoted literal, and traversal rejection. Those controls execute the Windows parser branch, but are not native PowerShell or Windows subprocess tests. I did not rerun the full platform matrix.

Copy link
Copy Markdown
Contributor Author

@codex review the current head 1e5f029117a620cf713f54f1f2d2c9b136b09952.

This integrates main's canonical plugin source/build layout while retaining the original four-file PowerShell fix and newer CLI behavior. Local focused checks passed (70 tests, one existing Windows skip), as did native PowerShell controls and the full Node 24 installed-package inspection. Both Windows verification jobs have passed on this head; the remaining full CI jobs are still running.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 1e5f029117

ℹ️ 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".

@faizan-oai
faizan-oai merged commit c64fddc into main Aug 28, 2026
67 checks passed
@faizan-oai
faizan-oai deleted the agent/windows-powershell-environment branch August 28, 2026 21:09
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.

3 participants