Repository navigation
Description
Problem
PHP code under test that shells out cannot run in a Codebox PHPUnit run, even when the run is a trusted review or gate run on a host that has the tools installed. Example: Jetpack wpcomsh's Imports\SQL_Importer (the Playground backup restore used on Atomic) runs
{ mysql -u … -h … db 2>&1 < /tmp/file.sql; echo "wpcomsh-mysql-exit:$?"; } | tail -c N
through exec(). Its 3 SQLImporterTest cases pass in Jetpack CI and on Atomic (native PHP) and fail under Codebox on homeboy-lab, which has MariaDB 11.8.6 and the client installed. PHP runs in php-wasm, and exec/proc_open reach the host only through php.setSpawnHandler(), which Codebox does not provide.
Why this shape
Codebox's no-spawn default is the right boundary where Codebox is the isolation (disposable agent sites, MCP and browser sessions). It is not the boundary for review and gate runs: those already execute repository code natively on the runner (npm run build, composer, cargo). There, refusing a shell only makes tests diverge from production. A narrow command allowlist with a custom parser does not fix that either: real code uses grouping, lists, $? and pipes. So the fix is fidelity behind an explicit opt-in, not a shell emulation.
Desired
An opt-in runtime capability (for example a recipe/runtime setting such as host_process: shell; pick a name consistent with the recipe contract), off by default:
- When enabled, Codebox installs a spawn handler that runs the command through the host
/bin/sh -cwith the run's environment (itsDB_*,PATH, and the env the runtime already exposes to PHP), streaming stdin/stdout/stderr and the exit status. - Path parity: commands must see the same paths PHP sees for the files they touch. At minimum PHP's temp dir (
sys_get_temp_dir(),/tmp) and the working directory resolve to the same host directories inside and outside the sandbox (for example identity mounts of a per-run host temp dir), somysql … < /tmp/x.sqlwritten by PHP is readable by the host process. Document which paths are shared. - When disabled (default), behavior is unchanged: Playground's sandboxed handler, no host processes.
- Record in the run's evidence/receipt that host process execution was enabled.
- Document the capability and its trust boundary in docs/recipe-contract.md.
The Homeboy WordPress extension then enables it for review/gate test runs (separate change in that repo).
Acceptance
End-to-end Playground PHPUnit integration test with the capability enabled: a test runs exec('{ echo hi; false; echo "exit:$?"; } | tail -c 100') and a command reading a file PHP wrote to sys_get_temp_dir(), both producing the native-shell result; the same test with the capability disabled shows host processes are unavailable. Fails on main, passes on the PR. Final proof: Jetpack wpcomsh full suite on homeboy-lab with database_type=mysql and the capability enabled passes SQLImporterTest with no exclusions.
Supersedes the earlier allowlisted-MySQL-client design for this issue (abandoned: it cannot run the real importer pipeline).
AI disclosure: Claude Opus (Pi, via Roadie) traced this from the wpcomsh importer source, a Lab run with an allowlist prototype, and the Codebox and php-wasm source, and wrote this issue.
Activity
[-]MySQL-mode PHPUnit runs cannot exec the MySQL client: install an allowlisted spawn handler[/-][+]Opt-in host shell for PHP process execution in trusted runs (exec/proc_open fidelity)[/+]chubes4 commentedon Dec 5, 2026
End-to-end proof on homeboy-lab: Jetpack wpcomsh full suite at
228893873ea(trunk),--setting database_type=mysql --setting-json 'wp_config_defines={"IS_ATOMIC":true}', with no exclusions. WordPress extensioncbccff0d(#20280 + the v0.38.0 pin in #20283) and WP Codebox v0.38.0 (#2634, #2644).Result:
Tests: 369, Assertions: 723, Skipped: 13, 0 failures (run82ac9c1b-dd91-41a7-8712-00d95bff4814).SQLImporterTestcases pass, including "Open an invalid sql file" and "Large failing statement reports the mysql error". They run the importer's real{ mysql …; echo "…$?"; } | tail -c Npipeline through the host shell.AuthorSlugRedirectTestwith data set "paged" passes (fix(phpunit): reset project-mode database to core's test-install state #2634).Before: the same 3 SQLImporter cases failed with "SQL import failed" and no output.
AI disclosure: Claude Opus (Pi, via Roadie) ran this verification and wrote this comment.