Skip to content

Adding sandbox for linux#14

Merged
ribomo merged 4 commits into
mainfrom
feature/linux-sandbox-v1
Jun 29, 2026
Merged

Adding sandbox for linux#14
ribomo merged 4 commits into
mainfrom
feature/linux-sandbox-v1

Conversation

@ribomo

@ribomo ribomo commented Jun 28, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Linux-only Bubblewrap-backed sandbox for run_command, shifting command execution from a string-based allowlist to an explicit argv vector plus sandbox “mode”, and surfacing startup warnings when sandboxing is unavailable.

Changes:

  • Add plain_agent.sandbox types and a Bubblewrap backend with offline + workspace policy enforcement.
  • Update run_command tool + runtime to execute validated argv through the sandbox and adjust approval UX to show exact quoted argv + requested mode.
  • Add extensive unit + Linux integration tests and a GitHub Actions workflow that installs Bubblewrap and runs the full test suite.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_tools.py Updates tool and runtime tests to use argv + sandbox backend stubs and adds coverage for output retention.
tests/test_textual_terminal.py Adds coverage for rendering command-approval output and startup warnings in the Textual UI.
tests/test_terminal_loop.py Updates approval flow tests to pass CommandRequest and verifies warning output in the basic terminal loop.
tests/test_sandbox.py Adds unit tests for sandbox types, Bubblewrap command construction, discovery behavior, and parse/read-roots validation.
tests/test_linux_sandbox.py Adds Linux integration tests verifying Bubblewrap enforcement (workspace RO/WR, no net, secret masking, timeouts).
tests/test_agent.py Updates agent tests to the argv interface and injects a sandbox-backed Tools for deterministic behavior.
README.md Documents Bubblewrap installation, sandbox behavior/modes, and read-root configuration.
plain_agent/ui/textual_terminal/rendering.py Adds format_command_approval and uses CommandRequest for consistent user-visible rendering.
plain_agent/ui/textual_terminal/app.py Displays startup warnings on mount and updates the approval prompt to use CommandRequest.
plain_agent/tools/tools.py Adds auto-discovery of Linux sandbox, startup warnings, and omits run_command when sandbox is unavailable.
plain_agent/tools/run_command.py Changes tool schema from command to {argv, mode} and routes execution via the sandboxed runtime.
plain_agent/tools/command_runtime.py Replaces allowlist parsing with sandbox backend invocation and threaded stdout/stderr draining + truncation.
plain_agent/tools/command_policy.py Removes the old command allowlist policy module (no longer used).
plain_agent/terminal_loop.py Updates approval prompt formatting to include mode and exact quoted argv.
plain_agent/sandbox/bubblewrap.py Implements Bubblewrap command construction, env filtering, workspace protections, and backend discovery/probing.
plain_agent/sandbox/base.py Adds shared sandbox types (CommandRequest, SandboxMode, backend protocol, error types).
plain_agent/sandbox/init.py Exposes the sandbox public API from the package.
plain_agent/agent_loop.py Threads CommandRequest through approval flow, supports injecting Tools, and exposes startup warnings.
.github/workflows/test.yml Adds CI job on Ubuntu that installs Bubblewrap and runs unittest discovery.
.env.example Documents PLAIN_AGENT_SANDBOX_READ_ROOTS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plain_agent/sandbox/bubblewrap.py Outdated
Comment on lines +49 to +53
process = subprocess.Popen(
sandboxed_argv,
cwd=request.workspace,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Comment thread plain_agent/sandbox/bubblewrap.py Outdated
Comment on lines +135 to +143
def probe(self, timeout_seconds: float = 2) -> None:
true_path = _first_existing(Path("/usr/bin/true"), Path("/bin/true"))
if true_path is None:
raise SandboxUnavailableError("Bubblewrap probe could not find the 'true' executable")
request = CommandRequest(
argv=(str(true_path),),
mode=SandboxMode.READ_ONLY,
workspace=Path.cwd().resolve(),
)
Comment thread plain_agent/sandbox/bubblewrap.py Outdated
Comment on lines +293 to +309
def _sensitive_workspace_files(workspace: Path) -> list[Path]:
sensitive: list[Path] = []
skipped_dirs = set(HIDDEN_WORKSPACE_DIRS)
for root, dirs, files in os.walk(
workspace,
followlinks=False,
onerror=_raise_walk_error,
):
dirs[:] = [name for name in dirs if name not in skipped_dirs]
root_path = Path(root)
for name in files:
lower_name = name.lower()
path = root_path / name
if lower_name in SENSITIVE_FILE_NAMES or path.suffix.lower() in SENSITIVE_FILE_SUFFIXES:
_reject_protected_symlink(path)
sensitive.append(path)
return sorted(sensitive)
@ribomo
ribomo merged commit f0aca71 into main Jun 29, 2026
2 checks passed
@ribomo ribomo mentioned this pull request Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants