Skip to content

feat: add uf sandbox command for containerized OpenCode sessions (Spec 028) - #93

Merged
jflowers merged 1 commit into
mainfrom
028-sandbox-command
Apr 12, 2026
Merged

jflowers merged 1 commit into
mainfrom
028-sandbox-command

Conversation

@jflowers

Copy link
Copy Markdown
Contributor

Summary

Adds uf sandbox command with 5 subcommands (start, stop, attach, extract, status) for containerized OpenCode session management via Podman.

Closes #91

What It Does

  • uf sandbox start: Checks prerequisites (Podman, OpenCode), detects platform (macOS/Linux, SELinux), pulls image if needed, starts container with API key forwarding and resource limits, waits for health check with exponential backoff (500ms->5s, 60s timeout), and attaches TUI (or prints URL in --detach mode)
  • uf sandbox extract: Generates patches via git format-patch inside container, displays summary, applies via git am on confirmation
  • uf sandbox stop: Idempotent container stop + remove
  • uf sandbox status: Parses podman inspect JSON for container state, uptime, mounts, mode
  • uf sandbox attach: Delegates to opencode attach

Key Design

  • Options/ExecCmd injection: Same testability pattern as setup/doctor (Constitution Principle IV)
  • Two modes: --mode isolated (read-only mount, default) and --mode direct (read-write)
  • SELinux :Z flag: Auto-detected on Linux via /etc/selinux/config
  • Dead container cleanup: Removes exited containers before starting new ones
  • Google Cloud auth: Forwards GOOGLE_CLOUD_PROJECT, VERTEX_LOCATION. Mounts service account key file or gcloud ADC credentials
  • Single container: Fixed name uf-sandbox, one at a time

Files

Directory Files Lines
internal/sandbox/ sandbox.go, detect.go, config.go, sandbox_test.go ~1,200
cmd/unbound-force/ sandbox.go, main.go ~240
specs/028-*/ 10 spec artifacts ~2,500

39 test functions, all passing with -race -count=1.

…c 028)

- Add internal/sandbox/ package (3 source files: sandbox.go,
  detect.go, config.go) with Start, Stop, Attach, Extract,
  Status operations following Options/ExecCmd injection pattern
- Add cmd/unbound-force/sandbox.go with 5 Cobra subcommands
  (start, stop, attach, extract, status) and flags (--mode,
  --detach, --image, --memory, --cpus, --yes)
- Platform detection: macOS/Linux arch, SELinux :Z flag
- Health check polling with exponential backoff (500ms->5s, 60s)
- Dead container cleanup before start
- Google Cloud credential forwarding (GOOGLE_CLOUD_PROJECT,
  VERTEX_LOCATION) and service account / ADC file mounting
- git format-patch / git am for change extraction
- Add 39 test functions covering all public functions,
  error paths, platform detection, and config builders
- Add spec artifacts (spec, plan, tasks, research, data-model,
  quickstart, contracts)
@jflowers
jflowers merged commit 29ad0fe into main Apr 12, 2026
1 check passed
@jflowers
jflowers deleted the 028-sandbox-command branch April 12, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

feat: add uf sandbox command for containerized OpenCode sessions

1 participant