Skip to content

test(cli): isolate fixture PWD from ambient working directory - #822

Merged
agenteinstinct1-max merged 3 commits into
dev-vibecodedfrom
test/cli-pwd-fixture-isolation
Nov 7, 2026
Merged

agenteinstinct1-max merged 3 commits into
dev-vibecodedfrom
test/cli-pwd-fixture-isolation

Conversation

@agenteinstinct1-max

@agenteinstinct1-max agenteinstinct1-max commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #823. Narrow CLI fixture isolation defect only; this does not establish a fix for the broader test-suite bottleneck.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Keep CLI fixture children from inheriting the repository's ambient PWD. The CLI resolves session.directory from env.PWD before cwd, so a stale parent PWD can escape fixture isolation even when HOME and cwd are isolated.

Default PWD to the fixture home for spawn, startRun and serve, and to the resolved requested cwd for ACP. Explicit caller env overrides still win. Add an isolated subprocess regression that sets an ambient PWD containing spaces and checks the child session.directory is the fixture home. Production code is unchanged.

How did you verify your code works?

  • Independent source review of the exact lifetime correction (PWD source SHA-256 5167dd0a...) found no must-fix. Canonical identities are captured inside the live fixture scope, after the child run and before home cleanup. The old post-scope catchall returned raw paths after home had been removed; it is now removed. Assertions and all four source budgets are unchanged.
  • One focused Linux x64, Bun 1.3.14 run of bun test --timeout 30000 test/cli/run/pwd-isolation.test.ts: exit 0 in 7.633 seconds; inner 1 pass / 0 fail with 14 assertions, outer 1 pass / 0 fail with 2 assertions. The diagnostic captured canonical home equal to session.directory and different from ambient PWD containing spaces.
  • A single frozen install restored a recycled local environment. All three source hashes and the root bun.lock hash matched before and after. The earlier missing-preload attempt did not execute a test body and is not a regression result.
  • The unchanged child-permission repair previously passed one focused Linux run: exit 0, 2 pass / 0 fail in 10.236 seconds. Both original --yolo and non-yolo outcomes passed; the latter requires external_directory plus auto-rejecting in child stderr. It uses an owned external sibling fixture and Effect.acquireRelease with visible cleanup failures.
  • Owned temporary-directory prefixes were absent after the focused runs. No individual child PID/reap observation or timeout/interruption cleanup proof was recorded. Production and lockfile are unchanged.

Earlier CI exposed stream typing, Windows short/long-path comparison, and a permission fixture that depended on stale ambient PWD. The previous revision passed typecheck and Linux CI but failed the Windows canonical comparison. This revision fixes the proven scope-lifetime/raw-fallback path; it is not Windows runtime qualification.

Runtime evidence for this correction is Linux only. Fresh exact-head CI and review are required. Full local typecheck was not rerun; the earlier local attempts ended in OOM and a narrow wasm-module error. The prior Windows suite took 1969 seconds: no full-suite speedup, suite-wide pass, or universal cleanup claim is made.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@kilo-code-bot

kilo-code-bot Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/opencode/test/cli/run/pwd-isolation.test.ts (incremental changes verified)
  • packages/opencode/test/cli/run/child-permission.test.ts
  • packages/opencode/test/lib/cli-process.ts
Previous Review Summaries (2 snapshots, latest commit 25b7896)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 25b7896)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/test/cli/run/child-permission.test.ts
  • packages/opencode/test/cli/run/pwd-isolation.test.ts

Previous review (commit e0d1014)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/test/cli/run/pwd-isolation.test.ts
  • packages/opencode/test/lib/cli-process.ts

Reviewed by free · Input: 26.6K · Output: 2.4K · Cached: 116.2K

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@agenteinstinct1-max
agenteinstinct1-max merged commit b11eae7 into dev-vibecoded Nov 7, 2026
8 checks passed
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.

test(cli): ambient PWD escapes CLI fixture isolation into session.directory

1 participant