[CLI] Run PHP in clean worker processes - #4146
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a runInFreshProcess() execution path for CLI workers so consumers can run PHP in a clean runtime (no inherited WP symbols), safely under worker concurrency, with per-run unique script paths and cleanup.
Changes:
- Introduces
runInFreshProcess()for Blueprint v1/v2 worker threads with per-worker sequencing to avoid queue poisoning on failures. - Executes
coderequests via unique temporary script paths and disposes the per-run request handler after execution. - Adds an integration test validating WP symbols aren’t inherited across fresh runs while still allowing WP to be loaded when required.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/playground/cli/tests/run-cli.spec.ts | Adds an integration test covering fresh-process execution isolation vs. booted worker state. |
| packages/playground/cli/src/blueprints-v2/worker-thread-v2.ts | Implements runInFreshProcess() with serialized execution, unique script paths, and cleanup. |
| packages/playground/cli/src/blueprints-v1/worker-thread-v1.ts | Implements runInFreshProcess() for v1, mirroring v2’s approach (with some config parity gaps). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@brandonpayton Review follow-up is ready: queue recovery now has explicit failure-then-success coverage in |
|
Downstream full-stack validation completed against this PR plus #4108 using https://github.com/chubes4/wordpress-playground/tree/proof/bet12-clean-worker-abi.
Downstream PR: Automattic/wp-codebox#1938 |
…ound into fix/clean-php-worker-rpc
Fixes #4145.
What changed
runInFreshProcess()to Blueprint v1 and v2 CLI workers./internal/eval.php, preventing concurrent parse corruption.Why
Programmatic CLI consumers need project-owned bootstraps to start without PHP symbols inherited from the long-lived worker. The same API also needs to remain safe when several pooled CLI workers execute code concurrently.
Verification
npx nx run playground-cli:typechecknpx nx run playground-cli:lintnpx nx run playground-cli:test-playground-cli --testNamePattern="should run PHP without inheriting booted WordPress symbols"AI assistance: OpenAI gpt-5.6-sol via OpenCode was used to review and implement the follow-up fixes and tests.