Bug: SubplanService.spawn() copies parent definition_of_done to child plans instead of using spawn entry goal #2073

Open
opened 2026-04-03 03:49:31 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/subplan-service-spawn-definition-of-done
  • Commit Message: fix(subplan): derive child plan definition_of_done from spawn entry goal, not parent plan
  • Milestone: v3.7.0
  • Parent Epic: #368

Background

The SubplanService.spawn() method in src/cleveragents/application/services/subplan_service.py incorrectly copies the parent plan's definition_of_done to child plans. Child plans should have their own definition_of_done derived from the spawn entry's goal/description, not inherit the parent's completion criteria.

The spec (docs/specification.md §Child Plan Spawning Mechanism, line 18343) describes child plans as being spawned with a specific goal:

"During execution, subplan_spawn decisions are realized as actual child plans"

Each subplan_spawn decision has its own question (the goal/description for the child plan). The child plan's definition_of_done should reflect the specific goal of that spawn decision, not the parent plan's overall completion criteria.

The local/create-subplan tool example (lines 18388–18393) shows:

subplan = ctx.spawn_subplan(
    action=params["action"],
    target_files=params.get("target_files", [])
)

The subplan is created with its own action and scope, not the parent's definition of done.

Current Behavior

In SubplanService.spawn() (line 272):

child_plan: Plan = Plan(
    ...
    description=entry.description or f"Child plan for {entry.action_name}",
    definition_of_done=parent_plan.definition_of_done,  # BUG: copies parent's DoD
    ...
)

The child plan inherits the parent's definition_of_done verbatim. This means:

  1. The child plan's strategize actor receives the parent's completion criteria, not the child's specific goal
  2. The child plan may produce a strategy for the wrong scope of work
  3. The description field (correctly set from entry.description) and definition_of_done (incorrectly set from parent) are inconsistent

Code location: src/cleveragents/application/services/subplan_service.py, line 272

Expected Behavior

Set definition_of_done=entry.description (or derive it from the spawn entry's goal) instead of copying from the parent. If the spawn entry has no description, use a sensible default like f"Complete: {entry.action_name}".

Each child plan's definition_of_done must reflect the specific goal of its spawn decision so that the strategize actor plans for the correct, scoped objective.

Subtasks

  • Reproduce the bug with a failing Behave scenario in features/subplan/spawn_definition_of_done.feature
  • Update SubplanService.spawn() at line 272 to set definition_of_done=entry.description or f"Complete: {entry.action_name}" instead of parent_plan.definition_of_done
  • Add/update type annotations on the affected code path to ensure Pyright passes
  • Update any existing Behave scenarios in features/ that assert on child plan definition_of_done to reflect the corrected behaviour
  • Verify no integration tests in robot/ rely on the incorrect inherited definition_of_done behaviour; update if needed
  • Run nox (all sessions) and confirm all quality gates pass

Definition of Done

  • A failing Behave scenario exists that demonstrates the bug before the fix
  • SubplanService.spawn() sets definition_of_done from the spawn entry's goal, not the parent plan
  • All Behave unit tests pass (nox -e unit_tests)
  • All Robot Framework integration tests pass (nox -e integration_tests)
  • Pyright type checking passes (nox -e typecheck)
  • Linting passes (nox -e lint)
  • All nox stages pass
  • Coverage >= 97%
  • Commit created with message fix(subplan): derive child plan definition_of_done from spawn entry goal, not parent plan on branch fix/subplan-service-spawn-definition-of-done
  • PR merged and issue closed with ISSUES CLOSED: #<this issue>

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/subplan-service-spawn-definition-of-done` - **Commit Message**: `fix(subplan): derive child plan definition_of_done from spawn entry goal, not parent plan` - **Milestone**: v3.7.0 - **Parent Epic**: #368 ## Background The `SubplanService.spawn()` method in `src/cleveragents/application/services/subplan_service.py` incorrectly copies the parent plan's `definition_of_done` to child plans. Child plans should have their own `definition_of_done` derived from the spawn entry's goal/description, not inherit the parent's completion criteria. The spec (docs/specification.md §Child Plan Spawning Mechanism, line 18343) describes child plans as being spawned with a specific goal: > "During execution, `subplan_spawn` decisions are realized as actual child plans" Each `subplan_spawn` decision has its own `question` (the goal/description for the child plan). The child plan's `definition_of_done` should reflect the specific goal of that spawn decision, not the parent plan's overall completion criteria. The `local/create-subplan` tool example (lines 18388–18393) shows: ```python subplan = ctx.spawn_subplan( action=params["action"], target_files=params.get("target_files", []) ) ``` The subplan is created with its own action and scope, not the parent's definition of done. ## Current Behavior In `SubplanService.spawn()` (line 272): ```python child_plan: Plan = Plan( ... description=entry.description or f"Child plan for {entry.action_name}", definition_of_done=parent_plan.definition_of_done, # BUG: copies parent's DoD ... ) ``` The child plan inherits the parent's `definition_of_done` verbatim. This means: 1. The child plan's strategize actor receives the parent's completion criteria, not the child's specific goal 2. The child plan may produce a strategy for the wrong scope of work 3. The `description` field (correctly set from `entry.description`) and `definition_of_done` (incorrectly set from parent) are inconsistent **Code location:** `src/cleveragents/application/services/subplan_service.py`, line 272 ## Expected Behavior Set `definition_of_done=entry.description` (or derive it from the spawn entry's goal) instead of copying from the parent. If the spawn entry has no description, use a sensible default like `f"Complete: {entry.action_name}"`. Each child plan's `definition_of_done` must reflect the specific goal of its spawn decision so that the strategize actor plans for the correct, scoped objective. ## Subtasks - [ ] Reproduce the bug with a failing Behave scenario in `features/subplan/spawn_definition_of_done.feature` - [ ] Update `SubplanService.spawn()` at line 272 to set `definition_of_done=entry.description or f"Complete: {entry.action_name}"` instead of `parent_plan.definition_of_done` - [ ] Add/update type annotations on the affected code path to ensure Pyright passes - [ ] Update any existing Behave scenarios in `features/` that assert on child plan `definition_of_done` to reflect the corrected behaviour - [ ] Verify no integration tests in `robot/` rely on the incorrect inherited `definition_of_done` behaviour; update if needed - [ ] Run `nox` (all sessions) and confirm all quality gates pass ## Definition of Done - [ ] A failing Behave scenario exists that demonstrates the bug before the fix - [ ] `SubplanService.spawn()` sets `definition_of_done` from the spawn entry's goal, not the parent plan - [ ] All Behave unit tests pass (`nox -e unit_tests`) - [ ] All Robot Framework integration tests pass (`nox -e integration_tests`) - [ ] Pyright type checking passes (`nox -e typecheck`) - [ ] Linting passes (`nox -e lint`) - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] Commit created with message `fix(subplan): derive child plan definition_of_done from spawn entry goal, not parent plan` on branch `fix/subplan-service-spawn-definition-of-done` - [ ] PR merged and issue closed with `ISSUES CLOSED: #<this issue>` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.7.0 milestone 2026-04-03 03:49:36 +00:00
freemo self-assigned this 2026-04-03 16:58:10 +00:00
Author
Owner

MoSCoW classification: Should Have

Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

MoSCoW classification: **Should Have** Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#2073
No description provided.