Skip to content

[Phase 4.B] ExecutionContext abstraction: local | worktree | e2b-sandbox #532

Description

@frankbria

Overview

Phase 4.B introduces an ExecutionContext abstraction so that conductor.py and all agent adapters can isolate task execution from the shared filesystem.

Motivation

cf work batch run --strategy parallel currently runs concurrent threads on the same live filesystem with no isolation. Agents can corrupt each other's work, hit git index locks, or overwrite changes.

Deliverables

codeframe/core/sandbox/context.py

Define the ExecutionContext protocol/dataclass:

class IsolationLevel(str, Enum):
    NONE = "none"         # shared filesystem (current behavior)
    WORKTREE = "worktree" # git worktree per task
    CLOUD = "cloud"       # E2B Linux VM per task

@dataclass
class ExecutionContext:
    task_id: str
    isolation: IsolationLevel
    workspace_path: Path
    cleanup: Callable[[], None]  # called on task completion

CLI flag

  • --isolation none|worktree|cloud on cf work start and cf work batch run
  • Default: none (preserves current behavior)

Integration points

  • conductor.py passes ExecutionContext to each worker
  • All agent adapters (ReactAgent, ClaudeCodeAdapter, etc.) respect context.workspace_path
  • Runtime creates/tears down context around each task run

Acceptance Criteria

  • ExecutionContext dataclass defined in core/sandbox/context.py
  • IsolationLevel enum with none | worktree | cloud
  • --isolation flag wired up on cf work start and cf work batch run
  • conductor.py creates context before dispatch, cleans up after
  • Tests for context lifecycle (create, use, cleanup)
  • Default none preserves all existing behavior

Dependencies

  • Blocked by nothing (can start now)
  • Blocks: worktree isolation (#next), E2BAgentAdapter (#next+1)

Track

Phase 4.B — Execution Environment Layer

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureSystem architecture and design patternsenhancementNew feature or requestphase-4Phase 4: Multi-Agent Coordinationpriority:high

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions