pkg/isolation/README.md
pkg/isolationpkg/isolation provides process-level isolation for child processes started by picoclaw.
It does not sandbox the main picoclaw process itself.
The current scope is the child-process startup path:
exec toolclaude-cli and codex-clistdio serverspicoclaw main process still runs in the host environment.pkg/isolation startup path first.The implementation has four layers:
config.Config.Isolation and injects it through isolation.Configure(cfg).config.GetHome(), prepares instance directories, and builds the runtime user environment.bwrap; Windows uses a restricted token, low integrity, and a Job Object; other platforms are not implemented.PrepareCommand(cmd), Start(cmd), and Run(cmd).All integrations that spawn subprocesses should reuse these helpers instead of calling cmd.Start or cmd.Run directly.
Isolation lives under:
{
"isolation": {
"enabled": false,
"expose_paths": []
}
}
Field meanings:
enabled: enables or disables subprocess isolation. Default: false.expose_paths: explicitly exposes host paths inside the isolated environment. It only matters when enabled=true. This is currently supported on Linux only.Example:
{
"isolation": {
"enabled": true,
"expose_paths": [
{
"source": "/opt/toolchains/go",
"target": "/opt/toolchains/go",
"mode": "ro"
},
{
"source": "/data/shared-assets",
"target": "/opt/picoclaw-instance-a/workspace/assets",
"mode": "rw"
}
]
}
}
Rules for expose_paths:
source is a host path.target is the path inside the isolated environment.mode must be ro or rw.target is empty, it defaults to source.target.target.Platform note:
source -> target mount view.expose_paths.The instance root follows config.GetHome():
PICOCLAW_HOME is set, use it..picoclaw directory under the user home.If config.GetHome() falls back to . while isolation is enabled, startup should fail.
Default instance directories include:
skillslogscachestateruntime-user-envworkspace is derived from cfg.WorkspacePath() when configured, otherwise from the default workspace rule.
Windows also prepares:
runtime-user-env/AppData/Roamingruntime-user-env/AppData/LocalWhen isolation is enabled, child processes receive a redirected per-instance user environment.
Linux variables:
HOMETMPDIRXDG_CONFIG_HOMEXDG_CACHE_HOMEXDG_STATE_HOMEWindows variables:
USERPROFILEHOMETEMPTMPAPPDATALOCALAPPDATAThese paths point into runtime-user-env under the instance root.
The Linux backend currently depends on bwrap (bubblewrap).
Capabilities:
ipc namespace isolationsource -> target read-only or read-write mountsDefault mounts include the instance root plus the minimum runtime system paths such as /usr, /bin, /lib, /lib64, and /etc/resolv.conf.
At runtime, PicoClaw also adds the executable path, its directory, the effective working directory, and absolute path arguments when needed.
There is no automatic fallback when bwrap is missing.
Install examples:
apt install bubblewrapdnf install bubblewrapyum install bubblewrappacman -S bubblewrapapk add bubblewrapIf isolation must be disabled temporarily:
{
"isolation": {
"enabled": false
}
}
Disabling isolation increases the risk that child processes can access or modify more host files.
Windows isolation currently supports process-level restrictions such as restricted tokens, low integrity, job objects, and redirected user-environment directories.
expose_paths is not currently supported on Windows. If it is configured, startup should fail instead of pretending the paths were exposed.
The Windows backend currently uses:
Job ObjectIt does not currently implement true source -> target filesystem remapping.
They are not implemented yet.
When isolation is explicitly enabled on an unsupported platform, the higher-level runtime should surface that as an unsupported configuration instead of pretending isolation succeeded.
When isolation is enabled, PicoClaw logs the generated isolation plan.
Linux log name:
linux isolation mount planWindows log name:
windows isolation access rulesIf you suspect isolation is ineffective, check whether unexpected host paths appear in those logs.
restrict_to_workspacerestrict_to_workspace limits the paths an agent is normally allowed to access.pkg/isolation limits what a child process can see and where its user environment points.They complement each other and do not replace each other.
bwrap, not a custom in-process isolation runtime.pid namespace by default.picoclaw process.If you are new to this code, read it in this order:
pkg/config/config.gopkg/isolation/runtime.gopkg/isolation/platform_linux.gopkg/isolation/platform_windows.gopkg/tools/shell.gopkg/providers/*.gopkg/agent/hook_process.gopkg/mcp/manager.goThat path gives the fastest overview of the configuration model, runtime flow, and platform-specific limits.