UAT: SubplanService.spawn() does not inherit execution_environment and execution_env_priority from parent plan — child plans may run in wrong environment #3959

Open
opened 2026-04-06 07:52:50 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/subplan-execution-environment-inheritance
  • Commit Message: fix(subplan): inherit execution_environment and execution_env_priority in SubplanService.spawn()
  • Milestone: None (backlog)
  • Parent Epic: #368

Backlog note: This issue was discovered during autonomous operation
on milestone v3.4.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Background and Context

SubplanService.spawn() creates child Plan domain objects but does not copy the execution_environment or execution_env_priority fields from the parent plan. These fields control where tool execution takes place (host vs. container).

Per docs/specification.md: "Resolution priority: tool-level > plan-level > project-level > default (HOST)." Child plans spawned via SubplanService.spawn() should inherit the parent plan's execution_environment and execution_env_priority so they run in the same environment as the parent plan.

  • Discovered by: UAT tester (ca-uat-tester), feature area: Subplan and Parallel Execution
  • File: src/cleveragents/application/services/subplan_service.py
  • Method: SubplanService.spawn()
  • Spec reference: docs/specification.md — "Resolution priority: tool-level > plan-level > project-level > default (HOST)."

Current Behavior

The child plan is created without execution_environment or execution_env_priority:

child_plan = Plan(
    identity=PlanIdentity(...),
    ...
    # execution_environment NOT set — child plan defaults to None
    # execution_env_priority NOT set — child plan defaults to None
)

This means child plans fall back to the project-level or default (HOST) environment, even if the parent plan was configured to run in a container.

Steps to Reproduce (code-level)

  1. Create a parent plan with execution_environment="container" and execution_env_priority=ExecutionEnvPriority.OVERRIDE
  2. Call SubplanService.spawn() with spawn entries
  3. Inspect the returned child_plans — each child plan's execution_environment will be None

Impact

Child plans spawned from a parent configured to run in a container will instead run on the host, potentially causing tool execution failures or security boundary violations.

Expected Behavior

Per docs/specification.md, child plans spawned via SubplanService.spawn() should inherit the parent plan's execution_environment and execution_env_priority values, ensuring they run in the same execution environment as the parent plan.

Subtasks

  • Inherit execution_environment from parent plan in SubplanService.spawn()
  • Inherit execution_env_priority from parent plan in SubplanService.spawn()
  • Add unit test (behave) verifying child plans inherit parent's execution environment
  • Verify the validate_env_priority_requires_environment model validator still passes
  • Run nox (all default sessions), fix any errors
  • Verify coverage >= 97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • SubplanService.spawn() sets execution_environment and execution_env_priority on child plans from the parent plan's values
  • Unit tests cover the inheritance behavior
  • No regression in existing subplan spawn tests
  • All subtasks above are completed and checked off
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done
  • All nox stages pass
  • Coverage >= 97%

Supporting Information

  • Parent Epic: #368 (Epic: Subplans & Parallelism)
  • Spec reference: docs/specification.md — execution environment resolution priority

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/subplan-execution-environment-inheritance` - **Commit Message**: `fix(subplan): inherit execution_environment and execution_env_priority in SubplanService.spawn()` - **Milestone**: None (backlog) - **Parent Epic**: #368 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.4.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Background and Context `SubplanService.spawn()` creates child `Plan` domain objects but does **not** copy the `execution_environment` or `execution_env_priority` fields from the parent plan. These fields control where tool execution takes place (host vs. container). Per `docs/specification.md`: "Resolution priority: tool-level > plan-level > project-level > default (HOST)." Child plans spawned via `SubplanService.spawn()` should inherit the parent plan's `execution_environment` and `execution_env_priority` so they run in the same environment as the parent plan. - **Discovered by**: UAT tester (ca-uat-tester), feature area: Subplan and Parallel Execution - **File**: `src/cleveragents/application/services/subplan_service.py` - **Method**: `SubplanService.spawn()` - **Spec reference**: `docs/specification.md` — "Resolution priority: tool-level > plan-level > project-level > default (HOST)." ## Current Behavior The child plan is created without `execution_environment` or `execution_env_priority`: ```python child_plan = Plan( identity=PlanIdentity(...), ... # execution_environment NOT set — child plan defaults to None # execution_env_priority NOT set — child plan defaults to None ) ``` This means child plans fall back to the project-level or default (HOST) environment, even if the parent plan was configured to run in a container. ### Steps to Reproduce (code-level) 1. Create a parent plan with `execution_environment="container"` and `execution_env_priority=ExecutionEnvPriority.OVERRIDE` 2. Call `SubplanService.spawn()` with spawn entries 3. Inspect the returned `child_plans` — each child plan's `execution_environment` will be `None` ### Impact Child plans spawned from a parent configured to run in a container will instead run on the host, potentially causing tool execution failures or security boundary violations. ## Expected Behavior Per `docs/specification.md`, child plans spawned via `SubplanService.spawn()` should inherit the parent plan's `execution_environment` and `execution_env_priority` values, ensuring they run in the same execution environment as the parent plan. ## Subtasks - [ ] Inherit `execution_environment` from parent plan in `SubplanService.spawn()` - [ ] Inherit `execution_env_priority` from parent plan in `SubplanService.spawn()` - [ ] Add unit test (behave) verifying child plans inherit parent's execution environment - [ ] Verify the `validate_env_priority_requires_environment` model validator still passes - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage >= 97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - `SubplanService.spawn()` sets `execution_environment` and `execution_env_priority` on child plans from the parent plan's values - Unit tests cover the inheritance behavior - No regression in existing subplan spawn tests - All subtasks above are completed and checked off - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done - All nox stages pass - Coverage >= 97% ## Supporting Information - Parent Epic: #368 (Epic: Subplans & Parallelism) - Spec reference: `docs/specification.md` — execution environment resolution priority --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#368 Epic: Subplans & Parallelism
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3959
No description provided.