Skip to content

fix: isolate diagnostic subprocess working directories - #238

Merged
nicknisi merged 2 commits into
mainfrom
fix/isolated-tool-probes
Sep 14, 2026
Merged

nicknisi merged 2 commits into
mainfrom
fix/isolated-tool-probes

Conversation

@nicknisi

@nicknisi nicknisi commented Sep 14, 2026

Copy link
Copy Markdown
Member

Summary

Run commands without an explicit cwd from a fresh temporary directory instead of inheriting the project directory. This prevents Windows shell lookup from selecting repo-local tool shims and keeps diagnostic probes scoped to host tools and user-level MCP configuration.

Preserve explicit working directories for trusted project commands. Clean up temporary directories and return a failed result if setup or cleanup fails.

Add real-process regression tests and a compiled-CLI smoke check covering runtime and MCP probes, including Windows batch shims and paths containing spaces.

Verification

  • A1. bun run test: 2,767 tests passed across 160 files.
  • A2. bun run build, bun run typecheck, and bun run lint passed. Changed TypeScript files pass formatting checks.
  • A3. env -u WORKOS_API_KEY sh scripts/command-smoke.sh ./dist/workos passed against the compiled CLI. Authenticated checks were skipped. Shell syntax and sandbox setup failure checks passed.
  • A4. Run the regression tests and compiled-CLI smoke check on native Windows before release. The smoke script already runs in the Windows x64 and arm64 release jobs, but those runs have not been verified for this change.

Local verification used macOS and Bun 1.4.2. This PR remains a draft pending native Windows verification.

@nicknisi
nicknisi marked this pull request as ready for review September 14, 2026 20:31
@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge based on the reviewed changes, with no concrete correctness, security, or repository-rule violations identified.

Summary

This PR changes subprocess execution without an explicit cwd to use a fresh temporary directory, preventing diagnostic host-tool and user-level MCP probes from resolving repository-local shims or configuration.

  • Preserves explicit working directories for trusted project commands.
  • Converts temporary-directory setup and cleanup failures into failed execution results.
  • Adds real-process coverage for executable lookup, cleanup, nonzero exits, missing tools, setup failures, timeouts, and explicit working directories.
  • Extends compiled-binary smoke coverage with diagnostic probes and platform-specific shim fixtures.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[execFileNoThrow invocation] --> B{Explicit cwd supplied?}
    B -->|Yes| C[Run in trusted project directory]
    B -->|No| D[Create fresh temporary directory]
    D --> E[Run host tool or user-level MCP probe]
    C --> F[Collect status, stdout, and stderr]
    E --> F
    F --> G{Temporary directory created?}
    G -->|Yes| H[Remove temporary directory]
    G -->|No| I[Return process result]
    H --> I
    D -->|Setup failure| J[Return failed result]
    H -->|Cleanup failure| J
Loading

Reviews (1) · Last reviewed commit: "test: keep POSIX smoke PATH compatible w..."

@nicknisi
nicknisi merged commit 601079d into main Sep 14, 2026
6 checks passed
@nicknisi
nicknisi deleted the fix/isolated-tool-probes branch September 14, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant