Files
Mai Development f7d263e173
Some checks failed
Discord Webhook / git (push) Has been cancelled
docs(02): create phase plan
Phase 02: Safety & Sandboxing
- 4 plans in 3 waves
- Security assessment, sandbox execution, audit logging, integration
- Wave 1 parallel: assessment (02-01) + sandbox (02-02)
- Wave 2: audit logging (02-03)
- Wave 3: integration (02-04)
- Ready for execution
2026-01-27 14:28:35 -05:00

4.8 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous, must_haves
phase plan type wave depends_on files_modified autonomous must_haves
02-safety-sandboxing 02 execute 1
src/sandbox/__init__.py
src/sandbox/executor.py
src/sandbox/container_manager.py
config/sandbox.yaml
true
truths artifacts key_links
Code executes in isolated Docker containers
Containers have configurable resource limits enforced
Filesystem is read-only where possible for security
Network access is restricted to dependency fetching only
path provides min_lines
src/sandbox/executor.py Sandbox execution interface 50
path provides min_lines
src/sandbox/container_manager.py Docker container lifecycle management 40
path provides contains
config/sandbox.yaml Container security policies cpu_count, mem_limit, timeout
from to via pattern
src/sandbox/executor.py Docker Python SDK docker.from_env() docker.*from_env
from to via pattern
src/sandbox/container_manager.py Docker daemon container.run containers.run.*mem_limit
from to via pattern
config/sandbox.yaml container security read-only filesystem read_only.*true
Create secure Docker sandbox execution environment with resource limits and security hardening.

Purpose: Isolate generated code execution using Docker containers with strict resource controls, read-only filesystems, and network restrictions as defined in CONTEXT.md. Output: Working sandbox executor that can run Python code securely with real-time resource monitoring.

<execution_context> @/.opencode/get-shit-done/workflows/execute-plan.md @/.opencode/get-shit-done/templates/summary.md </execution_context>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md

Research references

@.planning/phases/02-safety-sandboxing/02-RESEARCH.md

Task 1: Create Docker sandbox manager src/sandbox/__init__.py, src/sandbox/container_manager.py Create ContainerManager class using Docker Python SDK. Implement create_container(image, runtime_configs) method with security hardening: --cap-drop=ALL, --no-new-privileges, non-root user, read-only filesystem where possible. Support network_mode='none' for no network access and network whitelist for read-only internet access. Include cleanup methods for container isolation. python -c "from src.sandbox.container_manager import ContainerManager; print('ContainerManager imported successfully')" ContainerManager creates secure containers with proper isolation, resource limits, and cleanup Task 2: Implement sandbox execution interface src/sandbox/executor.py, config/sandbox.yaml Create SandboxExecutor class that uses ContainerManager to run Python code. Execute code in isolated containers with configurable limits from config/sandbox.yaml (2 CPU cores, 1GB RAM, 2 minute timeout for trusted code). Implement real-time resource monitoring using docker.stats(). Handle execution timeouts, resource violations, and return results with security metadata. python -c "from src.sandbox.executor import SandboxExecutor; print('SandboxExecutor imported successfully')" SandboxExecutor can execute Python code securely with resource limits and monitoring Task 3: Configure sandbox policies config/sandbox.yaml Create config/sandbox.yaml with sandbox policies matching CONTEXT.md decisions: resource quotas (cpu_count: 2, mem_limit: "1g", timeout: 120), security settings (security_opt: ["no-new-privileges"], cap_drop: ["ALL"], read_only: true), and network policies (network_mode: "none" with whitelist for dependency access). Include dynamic allocation rules based on trust level. python -c "import yaml; print('Config loads:', yaml.safe_load(open('config/sandbox.yaml'))')" Configuration defines sandbox security policies, resource limits, and network restrictions - ContainerManager creates Docker containers with proper security hardening - SandboxExecutor can execute Python code in isolated containers - Resource limits are enforced (CPU, memory, timeout, PIDs) - Network access is properly restricted - Container cleanup happens after execution - Real-time resource monitoring works

<success_criteria> Docker sandbox execution environment ready with configurable resource limits, security hardening, and real-time monitoring for safe code execution. </success_criteria>

After completion, create `.planning/phases/02-safety-sandboxing/02-02-SUMMARY.md`