|
| 1 | +# Phase 07 Plan: Worker Boundary and Cloud-Safe Execution Profiles |
| 2 | + |
| 3 | +**Phase**: 07 — Worker Boundary and Cloud-Safe Execution Profiles |
| 4 | +**Goal**: Make long-running execution explicit and safe when the control plane is hosted away from the local workstation. Separate cloud ingress from local-only providers. |
| 5 | +**Requirements**: WRKR-01, WRKR-02, WRKR-03 |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +Phase 6 delivered a stable REST API and shared orchestration contract. Phase 7 introduces a worker boundary so HTTP ingress never waits on long-running repo execution, and adds execution profiles so cloud-hosted runs can explicitly reject local-only subprocess providers. |
| 10 | + |
| 11 | +The local execution path is preserved intact. Cloud-safe is strictly opt-in via `--profile cloud-safe`. |
| 12 | + |
| 13 | +## Plans |
| 14 | + |
| 15 | +### 07-01: Worker boundary and background run dispatch contract |
| 16 | + |
| 17 | +**Files created:** |
| 18 | +- `maf_starter/worker_boundary.py` — `WorkerProfile` enum (LOCAL, CLOUD_SAFE), `WorkerBoundary` class with async dispatch and run status |
| 19 | +- `tests/test_worker_boundary.py` — unit tests for submit_async, get_status, done/pending states |
| 20 | + |
| 21 | +**Design decisions:** |
| 22 | +- `WorkerBoundary.submit_async(run_id, workflow)` dispatches via `asyncio.create_task` — no new dependencies |
| 23 | +- Status is tracked in a plain dict keyed by run_id; values are `"pending"`, `"running"`, `"done"`, or `"error:<message>"` |
| 24 | +- `submit_async` returns immediately with the run_id so the HTTP layer is never blocked |
| 25 | +- `WorkerProfile` is a string enum to allow clean serialization and CLI parsing |
| 26 | + |
| 27 | +### 07-02: Cloud-safe provider and execution profiles |
| 28 | + |
| 29 | +**Files created / modified:** |
| 30 | +- `maf_starter/execution_profile.py` — `ExecutionProfile` dataclass, `CLOUD_SAFE_PROFILE` and `LOCAL_PROFILE` constants, `IncompatibleProviderError` |
| 31 | +- `maf_starter/provider_fallback.py` — guard added at the top of `_execute_chain_step` to reject subprocess providers when profile is CLOUD_SAFE |
| 32 | +- `maf_starter/devui_overrides.py` — `--profile` CLI flag added (choices: local, cloud-safe; default: local) wired through to settings context |
| 33 | +- `tests/test_execution_profile.py` — unit tests for profile enforcement and IncompatibleProviderError |
| 34 | + |
| 35 | +**Design decisions:** |
| 36 | +- `IncompatibleProviderError(RuntimeError)` carries provider name and profile name in a clear message |
| 37 | +- Subprocess providers are `gemini-cli`, `claude-cli`, `codex-cli` — same set already used throughout `provider_fallback.py` |
| 38 | +- LOCAL profile imposes no restrictions; CLOUD_SAFE rejects all subprocess providers on first check before any subprocess is spawned |
| 39 | +- `ExecutionProfile` is a frozen dataclass with `profile: WorkerProfile` and `capabilities: tuple[str, ...]` |
| 40 | +- `CLOUD_SAFE_PROFILE` capabilities list: `["api-only", "no-subprocess"]` |
| 41 | +- `LOCAL_PROFILE` capabilities list: `["api", "subprocess", "repo-execution"]` |
| 42 | + |
| 43 | +### 07-03: End-to-end validation |
| 44 | + |
| 45 | +**Files created / modified:** |
| 46 | +- `tests/test_phase7_e2e.py` — three integration tests: |
| 47 | + 1. Cloud-safe profile rejects gemini-cli subprocess provider with `IncompatibleProviderError` |
| 48 | + 2. Local profile accepts all providers (gemini, anthropic, gemini-cli, claude-cli, codex-cli) |
| 49 | + 3. Async dispatch via `WorkerBoundary.submit_async` returns run_id immediately without blocking |
| 50 | +- `STATE.md` updated: Phase 7 marked complete |
| 51 | + |
| 52 | +## Verification |
| 53 | + |
| 54 | +All tests pass with: |
| 55 | +``` |
| 56 | +cd C:\PersonalRepo\portfolio\autogen && python -m pytest tests/ -v |
| 57 | +``` |
| 58 | + |
| 59 | +## Constraints |
| 60 | + |
| 61 | +- No new pip dependencies — asyncio and stdlib only |
| 62 | +- Local path unchanged — subprocess providers still work under LOCAL profile |
| 63 | +- `IncompatibleProviderError` is informative: `"Provider {name} requires subprocess access which is not available in cloud-safe profile"` |
| 64 | +- snake_case modules, PascalCase dataclasses, UPPER_SNAKE_CASE module constants — consistent with existing maf_starter patterns |
0 commit comments