UAT: SubplanMergeService only supports file-content merging — spec requires resource-type-aware merge strategies (databases, APIs, etc.) #4005

Open
opened 2026-04-06 08:29:40 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/subplan-merge-resource-type-aware-strategies
  • Commit Message: fix(subplan): implement resource-type-aware merge strategies in SubplanMergeService
  • 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.

Bug Description

SubplanMergeService only supports file-content merging (git three-way, sequential apply, fail-on-conflict, last-wins). The spec explicitly requires resource-type-aware merge strategies, but the current implementation treats all subplan outputs as file maps (dict[str, str]), with no support for database resources, API resources, or other non-file resource types.

  • Discovered by: UAT tester (ca-uat-tester), feature area: Subplan and Parallel Execution
  • File: src/cleveragents/application/services/subplan_merge_service.py
  • Class: SubplanMergeService
  • Spec reference: docs/specification.md lines 18430–18437 — "The way child plan results are merged depends on the resource type"

What was tested

Code-level analysis of src/cleveragents/application/services/subplan_merge_service.py (entire file, 269 lines).

Expected behavior (from spec)

Per docs/specification.md lines 18430–18437:

The way child plan results are merged depends on the resource type:

  • Git-compatible resources (source code, text files): Git-style merge
  • Databases: Transaction coordination or sequential application
  • Other resources: Pluggable merge strategies based on resource type
  • Non-mergeable resources: May require sequential execution only

Actual behavior

SubplanMergeService only handles file-based merging:

def merge(
    self,
    base_files: dict[str, str],
    subplan_outputs: Sequence[tuple[str, dict[str, str]]],
) -> SubplanMergeResult:
    # Only handles file content (dict[str, str])
    # No resource type dispatch
    # No database merge support
    # No pluggable strategy interface

The SubplanMergeStrategy enum has GIT_THREE_WAY, SEQUENTIAL_APPLY, FAIL_ON_CONFLICT, and LAST_WINS — all of which are file-content strategies. There is no mechanism for database or API resource merging.

Impact

Plans that spawn subplans operating on database resources or other non-file resources cannot merge their results correctly. The merge service will either fail (if the resource type doesn't produce file outputs) or silently produce incorrect results (if database changes are represented as files but merged incorrectly).

Subtasks

  • Design resource-type-aware merge dispatch in SubplanMergeService
  • Implement database merge strategy (transaction coordination or sequential application)
  • Implement pluggable merge strategy interface for custom resource types
  • Add unit tests (behave) for resource-type-aware merging
  • Document the merge strategy selection algorithm

Definition of Done

  • SubplanMergeService.merge() dispatches to the correct strategy based on resource type
  • Database resources use transaction coordination or sequential application
  • Custom resource types can register pluggable merge strategies
  • Unit tests cover all resource type merge paths
  • No regression in existing file-based merge tests
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/subplan-merge-resource-type-aware-strategies` - **Commit Message**: `fix(subplan): implement resource-type-aware merge strategies in SubplanMergeService` - **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. ## Bug Description `SubplanMergeService` only supports file-content merging (git three-way, sequential apply, fail-on-conflict, last-wins). The spec explicitly requires resource-type-aware merge strategies, but the current implementation treats all subplan outputs as file maps (`dict[str, str]`), with no support for database resources, API resources, or other non-file resource types. - **Discovered by**: UAT tester (ca-uat-tester), feature area: Subplan and Parallel Execution - **File**: `src/cleveragents/application/services/subplan_merge_service.py` - **Class**: `SubplanMergeService` - **Spec reference**: `docs/specification.md` lines 18430–18437 — "The way child plan results are merged depends on the resource type" ### What was tested Code-level analysis of `src/cleveragents/application/services/subplan_merge_service.py` (entire file, 269 lines). ### Expected behavior (from spec) Per `docs/specification.md` lines 18430–18437: > The way child plan results are merged depends on the resource type: > * **Git-compatible resources** (source code, text files): Git-style merge > * **Databases**: Transaction coordination or sequential application > * **Other resources**: Pluggable merge strategies based on resource type > * **Non-mergeable resources**: May require sequential execution only ### Actual behavior `SubplanMergeService` only handles file-based merging: ```python def merge( self, base_files: dict[str, str], subplan_outputs: Sequence[tuple[str, dict[str, str]]], ) -> SubplanMergeResult: # Only handles file content (dict[str, str]) # No resource type dispatch # No database merge support # No pluggable strategy interface ``` The `SubplanMergeStrategy` enum has `GIT_THREE_WAY`, `SEQUENTIAL_APPLY`, `FAIL_ON_CONFLICT`, and `LAST_WINS` — all of which are file-content strategies. There is no mechanism for database or API resource merging. ### Impact Plans that spawn subplans operating on database resources or other non-file resources cannot merge their results correctly. The merge service will either fail (if the resource type doesn't produce file outputs) or silently produce incorrect results (if database changes are represented as files but merged incorrectly). ## Subtasks - [ ] Design resource-type-aware merge dispatch in `SubplanMergeService` - [ ] Implement database merge strategy (transaction coordination or sequential application) - [ ] Implement pluggable merge strategy interface for custom resource types - [ ] Add unit tests (behave) for resource-type-aware merging - [ ] Document the merge strategy selection algorithm ## Definition of Done - [ ] `SubplanMergeService.merge()` dispatches to the correct strategy based on resource type - [ ] Database resources use transaction coordination or sequential application - [ ] Custom resource types can register pluggable merge strategies - [ ] Unit tests cover all resource type merge paths - [ ] No regression in existing file-based merge tests - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:12:03 +00:00
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#4005
No description provided.