Skip to main content
ExecutionPolicy is immutable. Every with*() method returns a new instance.

Minimal Policy

use Cognesy\Sandbox\Config\ExecutionPolicy;

$policy = ExecutionPolicy::in(__DIR__);
// @doctest id="4f58"

Common Overrides

$policy = $policy
    ->withTimeout(30)
    ->withIdleTimeout(10)
    ->withMemory('256M')
    ->withNetwork(false)
    ->withOutputCaps(2 * 1024 * 1024, 512 * 1024)
    ->withReadablePaths('/data/shared')
    ->withWritablePaths('/tmp/work')
    ->withEnv(['APP_ENV' => 'test'], inherit: true);
// @doctest id="03cd"

Key Notes

  • Default timeout is 5 seconds.
  • Default memory limit normalizes to 128M.
  • Network is disabled by default.
  • Output caps are enforced for stdout and stderr.