Skip to content

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

Open
faizan-oai wants to merge 1 commit into
mainfrom
agent/windows-powershell-environment
Open

fix(windows): preserve PowerShell environment and activity paths#634
faizan-oai wants to merge 1 commit into
mainfrom
agent/windows-powershell-environment

Conversation

@faizan-oai

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.

Testing

  • 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-24T18:35:18.200823Z 237dc00 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.

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