feat: Container-based isolation for safe autonomous execution#876
Draft
feat: Container-based isolation for safe autonomous execution#876
Conversation
- Add `parseComposeFile()` to extract port mappings from docker-compose.yml - Add `generateOverrideFile()` to write override files with offset host ports - Export `ComposePortMapping` type with service, hostPort, containerPort, protocol, hostIp - Handle short syntax, IP-bound syntax, long-form syntax, protocol variants - Preserve host_ip bindings in generated overrides to prevent unintended 0.0.0.0 exposure - Skip port ranges (V1 scope) and container-only entries - Throw on non-numeric identifier to prevent NaN propagation - Handle port wrap-around via wrapPort() for ports exceeding 65535 - Add yaml@2.8.2 dependency for YAML parsing and serialization - Add 30 tests covering all port formats, edge cases, and security scenarios
86d2d4b to
9c0808a
Compare
…er dev server suggestion - Add detectComposeFile() to src/utils/docker.ts supporting compose.yaml, compose.yml, docker-compose.yaml, docker-compose.yml (priority order per Docker docs) - Parse compose services and port mappings (short/long syntax, IP:HOST:CONTAINER, string published) - Rethrow unexpected errors; only suppress YAMLException for malformed YAML - Pass HAS_COMPOSE_FILE, COMPOSE_FILE_NAME, COMPOSE_SERVICES_INFO template variables in init - Add compose detection question to init-prompt.txt suggesting docker dev server mode - Track compose_detected boolean in init.completed telemetry - Add 18-test suite covering all file variants, port syntaxes, and edge cases - Add js-yaml runtime dependency for YAML parsing
…orkflows - Add compose management methods to DockerManager: buildComposeProjectName, getComposeOverrideDir, getComposeOverridePath, hasComposeOverrideFile, isComposeStackRunning, teardownComposeStack, removeComposeOverrideFile - Update terminateDevServer to check for compose override file and tear down compose stack before falling back to single-container cleanup - Add Step 1.6 to cleanupWorktree to remove compose override files from the iloom data directory in docker mode (non-fatal) - Add 'compose-override' to OperationResult.type union - Add 9 new tests covering compose teardown in terminateDevServer and cleanupWorktree
…ction
When devServer is set to 'docker', DevServerManager now auto-detects
compose files (compose.yml, compose.yaml, docker-compose.yml,
docker-compose.yaml) in the worktree before falling back to
Dockerfile-based strategy.
- Add ComposeDevServerStrategy: start/stop/status for docker compose
stacks, port readiness via TCP probe, signal forwarding, override
file lifecycle, project naming as iloom-{identifier}
- Add findComposeFile() utility: checks compose file candidates in
preference order (compose.yml first)
- Update DevServerManager to inject ComposeUtils and auto-detect
compose files in ensureServerRunning, runServerForeground,
isServerRunning, and cleanup
- Compose override directory is created on demand and override files
are cleaned up on stack teardown
- Running compose stacks tracked by project name (not port) to avoid
key collision on retry
- TCP probe uses 1-second socket timeout to avoid blocking on
firewalled ports
- Full test coverage: ComposeDevServerStrategy.test.ts (30 tests),
DevServerManager compose mode tests (20 tests)
- Fix TypeScript strict mode errors in compose.ts with undefined guards - Unify override file naming between compose.ts and DockerManager.ts - Deduplicate ComposePortMapping type definition - Standardize compose file search order - Consolidate on single yaml parsing library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #332
feat: Container-based isolation for safe autonomous execution
Overview
Add optional container-based isolation for looms, enabling safer
bypassPermissionsusage and allowing users to define complex multi-service environments (Redis, databases, multiple servers) without iloom needing to understand each service.Value Proposition
bypassPermissionsexecutes on hostCore Concept
iloom provides:
User provides:
devcontainer.json/docker-compose.ymldefining their servicesILOOM_PORT_<NAME>convention for port variablesPort Discovery & Configuration
Convention
Users use
ILOOM_PORT_<NAME>prefix in their compose files:During
il initiloom parses compose file, finds
ILOOM_PORT_*vars, prompts for base ports:Settings
{ "container": { "enabled": true, "ports": { "WEB": 3000, "API": 4000, "REDIS": 6379 } } }At
il start 123iloom calculates offsets and writes to
.env:Proposed Flow
Configuration
{ "container": { "enabled": true, "configPath": ".devcontainer/devcontainer.json", "ports": { "WEB": 3000, "API": 4000 }, "keepAlive": false // Stop container on finish vs keep running }, "workflows": { "issue": { "permissionMode": "bypassPermissions" // Now safe! } } }Open Questions
Claude Code Execution
devcontainer execinteract with Claude's terminal sessions?IDE Integration
--ide cursorwork with devcontainers?Container Lifecycle
il start, stop onil finish?il spinmultiple times - reuse running container?il cleanup- force remove container?Parsing Strategy
devcontainer.jsonordocker-compose.ymlor both?container.enabled: true?Database Integration
Secrets & Environment
.env.local? Copy? Inject via env?Filesystem Mounting
node_modules- mount or install inside?.gitdirectory handlingNetwork Isolation
Risks
Complexity - Significant feature touching many parts of iloom (init, start, finish, spin, cleanup, open, dev-server)
Docker dependency - Not all users have/want Docker. Must remain optional with graceful degradation.
Performance overhead - Container startup adds latency to
il start. Image pull on first run. Need to quantify.Platform inconsistencies - Docker behavior differs across macOS/Linux/Windows. Docker Desktop licensing considerations.
Resource usage - Multiple running containers (one per loom) could exhaust memory/CPU. May need guidance on limits.
Debugging difficulty - Container issues are harder to diagnose than host issues. Need good error messages.
devcontainer CLI dependency - Requires
@devcontainers/cliinstalled. Add to iloom dependencies or require user install?Breaking existing workflows - Users with existing devcontainer setups may have conflicts. Migration path needed.
Non-Goals (V1)
Implementation Approach
Suggest implementing in waves:
Wave 1: Foundation
il init.envinjection atil startWave 2: Integration
il spininside containeril open/il dev-serverwith containersWave 3: Polish
il cleanupcontainer handlingAcceptance Criteria
il initdetects and configures port mappingsil startlaunches container with correct portsbypassPermissionsis sandboxed to containeril finishcleans up containerThis PR was created automatically by iloom.