bug(plan): subplan spawn creates metadata but does not orchestrate real child plan execution #823

Closed
opened 2026-03-13 20:12:45 +00:00 by freemo · 4 comments
Owner

Metadata

  • Commit Message: fix(plan): implement end-to-end subplan execution orchestration
  • Branch: bugfix/m6-subplan-spawn-orchestration
  • Type: Bug
  • Priority: Critical
  • MoSCoW: Must have
  • Points: 8
  • Milestone: v3.5.0

Background and Context

The specification defines subplan spawning as creating real child plans that go through the full plan lifecycle (strategize → execute → validate). However, SubplanService.spawn() only creates metadata (SubplanStatus records and SpawnMetadata) but does NOT create actual child Plan domain objects.

Acceptance Criteria

  • SubplanService.spawn() creates real child Plan domain objects with full PlanIdentity linking
  • Child plans are set to PlanPhase.STRATEGIZE / ProcessingState.QUEUED
  • SpawnResult includes child_plans: list[Plan] alongside metadata
  • Parent plan's subplan_statuses tracks child lifecycle state
  • SpawnResult.total_spawned matches child_plans count

Subtasks

  • Implement real child Plan creation in SubplanService.spawn()
  • Wire child plan PlanIdentity with parent_plan_id and root_plan_id
  • Implement parent-child plan status tracking via SubplanStatus
  • Extend SpawnResult with child_plans field
  • Fix Pyright type errors (missing Plan/NamespacedName constructor params)
  • Tests (Behave): Add scenarios for spawn → child plan creation → parent tracking
  • Tests (Robot): Add integration tests for subplan spawn orchestration
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • 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.
## Metadata - **Commit Message**: `fix(plan): implement end-to-end subplan execution orchestration` - **Branch**: `bugfix/m6-subplan-spawn-orchestration` - **Type**: Bug - **Priority**: Critical - **MoSCoW**: Must have - **Points**: 8 - **Milestone**: v3.5.0 ## Background and Context The specification defines subplan spawning as creating real child plans that go through the full plan lifecycle (strategize → execute → validate). However, `SubplanService.spawn()` only creates metadata (SubplanStatus records and SpawnMetadata) but does NOT create actual child `Plan` domain objects. ## Acceptance Criteria - [x] `SubplanService.spawn()` creates real child `Plan` domain objects with full `PlanIdentity` linking - [x] Child plans are set to `PlanPhase.STRATEGIZE / ProcessingState.QUEUED` - [x] `SpawnResult` includes `child_plans: list[Plan]` alongside metadata - [x] Parent plan's `subplan_statuses` tracks child lifecycle state - [x] `SpawnResult.total_spawned` matches `child_plans` count ## Subtasks - [x] Implement real child Plan creation in `SubplanService.spawn()` - [x] Wire child plan PlanIdentity with parent_plan_id and root_plan_id - [x] Implement parent-child plan status tracking via SubplanStatus - [x] Extend SpawnResult with child_plans field - [x] Fix Pyright type errors (missing Plan/NamespacedName constructor params) - [x] Tests (Behave): Add scenarios for spawn → child plan creation → parent tracking - [x] Tests (Robot): Add integration tests for subplan spawn orchestration - [x] Verify coverage >=97% via `nox -s coverage_report` - [x] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - 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.
freemo added this to the v3.5.0 milestone 2026-03-13 20:19:58 +00:00
freemo self-assigned this 2026-03-13 21:31:14 +00:00
Author
Owner

Dependency (TDD workflow): This bug fix is blocked by TDD issue #838. Per CONTRIBUTING.md Bug Fix Workflow, the TDD test capturing the bug must be written and merged first (@tdd_expected_fail), then the fix PR removes the tag.

Blocked by: #838

**Dependency (TDD workflow):** This bug fix is blocked by TDD issue #838. Per `CONTRIBUTING.md` Bug Fix Workflow, the TDD test capturing the bug must be written and merged first (`@tdd_expected_fail`), then the fix PR removes the tag. **Blocked by:** #838
Author
Owner

PM Status — Day 36

TDD COMPLETE — Fix can now proceed.

TDD counterpart #838 was closed on 2026-03-16 (today). The @tdd_expected_fail tests proving the bug exist are now on master.

TDD Pipeline Status:

Stage Item Status
1. TDD Issue #838 CLOSED
2. TDD PR (merged) MERGED
3. Bug fix PR NOT STARTED

Action required — CRITICAL:

@freemo — The TDD tests for this bug are merged. Per CONTRIBUTING.md Bug Fix Workflow, the fix can now proceed. Please:

  1. Create branch bugfix/m6-subplan-spawn-orchestration
  2. Implement the fix: SubplanService.spawn() must create a real child Plan domain object, trigger the child plan's lifecycle (strategize → execute → validate → complete), set up inter-plan communication, merge results, and handle failures.
  3. Remove the @tdd_expected_fail tag from the tests in features/tdd_subplan_spawn_orchestration.feature and robot/tdd_subplan_spawn_orchestration.robot
  4. Verify all quality gates pass

Priority: Critical. This is a v3.5.0 milestone item and blocks autonomy hardening acceptance criteria.


PM status comment — Day 36

## PM Status — Day 36 **TDD COMPLETE — Fix can now proceed.** TDD counterpart #838 was **closed** on 2026-03-16 (today). The `@tdd_expected_fail` tests proving the bug exist are now on master. **TDD Pipeline Status:** | Stage | Item | Status | |-------|------|--------| | 1. TDD Issue | #838 | **CLOSED** | | 2. TDD PR | (merged) | **MERGED** | | 3. Bug fix PR | — | **NOT STARTED** | **Action required — CRITICAL:** @freemo — The TDD tests for this bug are merged. Per CONTRIBUTING.md Bug Fix Workflow, the fix can now proceed. Please: 1. Create branch `bugfix/m6-subplan-spawn-orchestration` 2. Implement the fix: `SubplanService.spawn()` must create a real child `Plan` domain object, trigger the child plan's lifecycle (strategize → execute → validate → complete), set up inter-plan communication, merge results, and handle failures. 3. Remove the `@tdd_expected_fail` tag from the tests in `features/tdd_subplan_spawn_orchestration.feature` and `robot/tdd_subplan_spawn_orchestration.robot` 4. Verify all quality gates pass **Priority**: Critical. This is a v3.5.0 milestone item and blocks autonomy hardening acceptance criteria. --- *PM status comment — Day 36*
Author
Owner

PM Escalation — Day 37

STALLED TDD PIPELINE — FIX BRANCH NOT STARTED

The TDD counterpart for this bug (issue #838) was closed on Day 36 when PR #930 was merged to master. The @tdd_expected_fail tests proving the bug exists are now on master. Per the TDD workflow in CONTRIBUTING.md, the fix can and should have started immediately.

It has been over 24 hours since the TDD test landed on master and no fix branch exists.

@freemo — This is a Priority/Critical, MoSCoW/Must Have bug. Subplan spawn orchestration is essential for hierarchical plan decomposition (M6 acceptance criteria). The mandatory next steps are:

  1. Create branch bugfix/m6-subplan-spawn-orchestration from master today.
  2. Implement the fix: SubplanService.spawn() must create real child Plan domain objects, trigger child plan lifecycle (strategize → execute → validate → complete), set up inter-plan communication, merge results, and handle failures.
  3. Remove the @tdd_expected_fail tag from the tests in features/tdd_subplan_spawn_orchestration.feature and robot/tdd_subplan_spawn_orchestration.robot.
  4. Verify all quality gates pass.
  5. Open PR from bugfix/m6-subplan-spawn-orchestration to master.

This bug is blocking M6 closure and the project's autonomy hardening acceptance criteria. Jeff has the heaviest bug load on the team (bugs #822, #823, #967, #968, #969) — all must be prioritized over feature work.


PM escalation — Day 37

## PM Escalation — Day 37 **STALLED TDD PIPELINE — FIX BRANCH NOT STARTED** The TDD counterpart for this bug (issue #838) was **closed on Day 36** when PR #930 was merged to `master`. The `@tdd_expected_fail` tests proving the bug exists are now on `master`. Per the TDD workflow in `CONTRIBUTING.md`, the fix can and should have started immediately. **It has been over 24 hours since the TDD test landed on `master` and no fix branch exists.** @freemo — This is a **Priority/Critical, MoSCoW/Must Have** bug. Subplan spawn orchestration is essential for hierarchical plan decomposition (M6 acceptance criteria). The mandatory next steps are: 1. Create branch `bugfix/m6-subplan-spawn-orchestration` from `master` **today**. 2. Implement the fix: `SubplanService.spawn()` must create real child `Plan` domain objects, trigger child plan lifecycle (strategize → execute → validate → complete), set up inter-plan communication, merge results, and handle failures. 3. Remove the `@tdd_expected_fail` tag from the tests in `features/tdd_subplan_spawn_orchestration.feature` and `robot/tdd_subplan_spawn_orchestration.robot`. 4. Verify all quality gates pass. 5. Open PR from `bugfix/m6-subplan-spawn-orchestration` to `master`. **This bug is blocking M6 closure and the project's autonomy hardening acceptance criteria.** Jeff has the heaviest bug load on the team (bugs #822, #823, #967, #968, #969) — all must be prioritized over feature work. --- *PM escalation — Day 37*
Author
Owner

Implementation Notes — Day 37

Design Decisions

  1. Child Plan domain objects: Each spawn entry now produces a full Plan domain object with a unique ULID, linked to the parent via PlanIdentity(parent_plan_id=parent_id, root_plan_id=root_id). Child plans inherit the parent's namespace, actors, project links, definition of done, and access settings (reusable, read_only).

  2. Lifecycle phase initialization: Child plans are created in PlanPhase.STRATEGIZE / ProcessingState.QUEUED, matching the initial state for newly-created plans. This positions them for downstream lifecycle orchestration when a PlanExecutor picks them up.

  3. SpawnResult extension: The SpawnResult dataclass was extended with child_plans: list[Plan] to carry child plans alongside existing metadata and statuses. This allows callers to access both the tracking metadata and the actual domain objects.

  4. Parent tracking: parent_plan.subplan_statuses is updated with SubplanStatus entries, each with status=ProcessingState.QUEUED, allowing the parent plan to monitor child lifecycle states.

  5. Scope boundary: This fix addresses the first-level fix (creating real Plan objects). Full lifecycle orchestration (auto-triggering child strategize/execute, result merging, failure handling, parallel dispatch) remains as future work tracked by the parent epic.

Key Code Locations

  • SubplanService.spawn()src/cleveragents/application/services/subplan_service.py (commit 0f194402)
  • SpawnResult.child_plans — same file, dataclass definition

Quality Gates

  • Lint: All checks passed
  • Typecheck: 0 errors (Pyright) — fixed missing constructor params
  • Unit tests: 385 features, 10966 scenarios passed
  • Integration tests: 1549 tests passed (0 failed)
  • Coverage: 97%

Branch & PR

  • Branch: bugfix/m6-subplan-spawn-orchestration
  • Commit: 0f194402
  • PR created → transitioning to State/In Review
## Implementation Notes — Day 37 ### Design Decisions 1. **Child Plan domain objects**: Each spawn entry now produces a full `Plan` domain object with a unique ULID, linked to the parent via `PlanIdentity(parent_plan_id=parent_id, root_plan_id=root_id)`. Child plans inherit the parent's namespace, actors, project links, definition of done, and access settings (reusable, read_only). 2. **Lifecycle phase initialization**: Child plans are created in `PlanPhase.STRATEGIZE / ProcessingState.QUEUED`, matching the initial state for newly-created plans. This positions them for downstream lifecycle orchestration when a PlanExecutor picks them up. 3. **SpawnResult extension**: The `SpawnResult` dataclass was extended with `child_plans: list[Plan]` to carry child plans alongside existing metadata and statuses. This allows callers to access both the tracking metadata and the actual domain objects. 4. **Parent tracking**: `parent_plan.subplan_statuses` is updated with `SubplanStatus` entries, each with `status=ProcessingState.QUEUED`, allowing the parent plan to monitor child lifecycle states. 5. **Scope boundary**: This fix addresses the first-level fix (creating real Plan objects). Full lifecycle orchestration (auto-triggering child strategize/execute, result merging, failure handling, parallel dispatch) remains as future work tracked by the parent epic. ### Key Code Locations - `SubplanService.spawn()` — `src/cleveragents/application/services/subplan_service.py` (commit 0f194402) - `SpawnResult.child_plans` — same file, dataclass definition ### Quality Gates - Lint: ✅ All checks passed - Typecheck: ✅ 0 errors (Pyright) — fixed missing constructor params - Unit tests: ✅ 385 features, 10966 scenarios passed - Integration tests: ✅ 1549 tests passed (0 failed) - Coverage: ✅ 97% ### Branch & PR - Branch: `bugfix/m6-subplan-spawn-orchestration` - Commit: `0f194402` - PR created → transitioning to `State/In Review`
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.

Reference
cleveragents/cleveragents-core#823
No description provided.