epic: optionally run managed OpenCode instances in containers #375
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#375
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Add an optional container runtime for ocman-managed, one-per-project OpenCode instances so agent commands have a narrower filesystem/process boundary and bounded resources, while preserving native tmux mode.
Why this is not only a launcher change
Ocman controls project launch through
EnsureProjectOpencode, but it still reconstructs instance identity from a global OpenCode SQLite database plus hostlsof, PID cwd, tmux state, and127.0.0.1:<port>. Containers need explicit lifecycle metadata, published endpoints, canonical mounts, health, credentials, and recovery after an ocman restart.The security benefit is meaningful only with narrow mounts and secret injection. Host PID/network namespaces, privileged containers, the Docker socket, broad home mounts, or full SSH/config mounts are out of bounds because they largely defeat isolation.
Intended architecture
Keep
hostsvc.Host.EnsureProjectOpencodeas the owner-resolved outer seam. Add a host-local OpenCode runtime policy behind it:platforms.Platformcontinues to own session operations and remains unaware of Docker/Podman.Principal constraints
lsof/PID cwd discovery does not work reliably across container namespaces.0.0.0.0, and be published only to a host-loopback port known to ocman..worktrees/<repo>layout without exposing unrelated repositories.Database decision
Decision #384 rejects sharing or bind-mounting host OpenCode SQLite into project containers, especially on Docker Desktop for macOS. Each managed project container owns a persistent OpenCode database; ocman will build a host-local API-fed read model for unified history, routing, projects, and analytics. Native mode keeps its current read-only global database path during migration.
Delivery plan
Child tickets cover lifecycle ownership, authenticated transport, the isolated-data container tracer bullet, sandbox/config defaults, attachments, execution-environment semantics, the host-local read model, and user-facing rollout/diagnostics. #384 precedes #378; #382 is superseded. Dependencies are recorded in each child issue.
Completion criteria
Non-goals
hostsvc.Hostor creating a container-specific platform adapter.Child tickets and dependency frontier
Initial frontier: #376 and #377 can proceed in parallel.
Dependency correction after #384: #384 now precedes and blocks #378. Shared-SQLite qualification #382 is superseded; container work must use isolated per-project OpenCode databases plus the planned host-local API-fed read model.