Repository navigation
feat(runtime): opt-in host shell for PHP process execution - #2644
Conversation
|
Reviewed: AI disclosure: Claude Opus (Pi, via Roadie) reviewed this PR. The implementation is Claude Opus 5.5 (Homeboy Cook, cook-heavy fallback route). |
Bumps the WordPress extension's managed WP Codebox pin from v0.36.0 to v0.38.0, using the same two-line change as #20077. v0.38.0 includes: - Automattic/wp-codebox#2634: PHPUnit project mode starts with core's test-install permalink state. - Automattic/wp-codebox#2644: opt-in `runtime.hostProcess: "shell"`. Without the bump, extension setup installs v0.36.0, so the `hostProcess` option #20280 now passes would be rejected by the pinned CLI's recipe schema. Check: `wp-codebox-doctor-smoke.sh` passes with the updated expectation. The end-to-end proof (Jetpack wpcomsh `SQLImporterTest` on homeboy-lab) follows this release. Refs #20278. AI disclosure: Claude Opus (Pi, via Roadie) made this change and wrote this PR.
Summary
Fixes #2635. Adds an opt-in runtime capability,
runtime.hostProcess: "shell"(defaultnone). When on, a php-wasm spawn handler runs PHP'sexec()/proc_open()commands through the host/bin/sh -c. Commands receive the run's environment (DB_*, PATH, secretEnv targets) and a per-run host temp directory. That directory is mounted into PHP at the same path, used as PHP's temp dir, and removed with the run. With the capability off, Playground's sandboxed spawn handler stays installed and behaviour is unchanged. When on, the run records it in metadata, review risk flags and a lifecycle event.docs/recipe-contract.mddocuments the shared paths and the trust boundary.What changed
RuntimeHostProcessMode(none|shell). It is threaded through the runtime environment spec and normalizer, theWorkspaceReciperuntime type, the JSON schema, and CLI recipe validation. It is also wired into the recipe-run environment mapping, thebuildWordPressPhpunitRecipebuilder and therecipe-build phpunitcommand.host-process-spawn-handler.tsadapts Nodechild_process.spawnto the php-wasm contract: - emits spawn before exit; - streams stdin, stdout and stderr; - emits exit only after output is drained; - reports exit code 127 when exec fails. It does no command parsing and has no allowlist. One routing rule keeps Codebox's VFS-only/internal/shared/bin/php, used by PHPUnit process isolation, inside php-wasm.host-process-execution.tsprepares, per run: - a host temp dir, mounted at the same path in PHP and set assys_temp_dirandTMPDIR; - working-directory mappings; - the forwarded environment; - cleanup when the run ends.wpCodeboxHostProcessrunCLI option. The regenerated@wp-playground/clipatch threads it intobootRequestHandlerin the ESM worker threads (v1 and v2). Those workers import the handler by URL and wrap the sandboxed factory. The programmatic runner wrapssandboxedSpawnHandlerFactorythe same way. When the option is absent, both paths are unchanged.runtime.host-process-executionlifecycle event; - ametadata.jsonhostProcessExecutionblock (schemawp-codebox/host-process-execution/v1) holding mode, temp dir, cwd mappings and env variable names only, never values; - ahost-process-executionentry in reviewriskFlags. Docs: a 'Host Process Execution' section indocs/recipe-contract.mdand the rationale inpatches/README.md. Tests: a unit test and an end-to-end Playground PHPUnit integration test.Verification
All gates passed on
203e8aff4bb0. Basemain: gated on470b3743deb3, target now470b3743deb3, re-verified: no.HOMEBOY_LINT_BASE=470b3743deb3132965f1008cb18f63e8c90d5286 homeboy --placement local review lint wp-codebox --path . --…: passed, 68294 ms; retained gate metadata.npm run build: passed, 546 ms; retained gate metadata.Cook run
agent-task-65c82602-75fc-44c5-abd3-cba035edf56bagent-task-65c82602-75fc-44c5-abd3-cba035edf56b-attempt-1-f2282ba747fe18ccc693410663adfebfc42d86298834671d47fe18ccc693410663adfebfc42d86298834671dDelivery
runtime.hostProcess: shellcapability, default off with sandboxed behaviour unchanged/bin/sh -cspawn handler: run env, streamed stdin/stdout/stderr, exit status, spawn emitted before exitsys_get_temp_dir()/TMPDIRand cleaned up with the run; working directory mapped through mounts; shared paths documenteddocs/recipe-contract.mdexec()/system()$result_codeparity with native (php-wasm's popen path (js_popen_to_file) never records the child process, sopclose()loses the exit code for every spawn handler, the stock sandbox included. Output is correct, andproc_open()/proc_close()returns the host status. The limitation is documented and was not patched in php-wasm's generated runtime.)Evidence
nodejsextension is not installed; that gate is left to Homeboy. The full smoke and integration suites were not run. The CJS worker builds are not patched, since Codebox loads the ESM entry.runtime.hostProcessis rejected by the recipe schema (additionalProperties: falseon runtime). In Playground, the acceptance pipeline goes to the sandboxed handler: no output andproc_close127. The PR's disabled case exercises this same code path.metadata.jsonhadhostProcessExecution.enabled=trueandmode=shell. -files/review.jsonriskFlagsincludedhost-process-execution. - The shared temp dir no longer existed after the run.hostProcess: "shell":tests/playground-host-process-execution.integration.test.tsran a real Playground PHPUnit run, 3/3 tests passed in about 16s. -exec('{ echo hi; false; echo "exit:$?"; } | tail -c 100')returned the native/bin/shoutputhi\nexit:1, andproc_closereturned 0. - A file written viatempnam(sys_get_temp_dir())was read back by hostcat, and$TMPDIRequalledsys_get_temp_dir(). -proc_openstreamed stdin, stdout and stderr, andexit 7returned 7.proc_closereturned 127, and nohostProcessExecutionmetadata was recorded.AI disclosure
Tool: Homeboy Cook. Agent: Homeboy (roadie). Model: roadie · route cook-heavy · served claude-opus-5-5. Cook time: 34m35s.
The AI did the whole change: - traced the php-wasm and Playground CLI spawn-handler plumbing; - designed and implemented the opt-in capability, contract threading, host spawn handler, path parity, evidence recording and Playground CLI patch; - wrote the docs, unit test and end-to-end test; - found the php-wasm popen exit-code limitation with direct runtime probes, under the direction of the Cook requester. Homeboy reports controller verification separately from this account of the AI's work. A human reviews before merge.
Refs #2635