Implement file-level comparison and real patch preview for correction diff #10008

Open
opened 2026-04-16 12:07:29 +00:00 by hurui200320 · 1 comment
Member

Metadata

Field Value
Priority P3/Should
MoSCoW Should
Type enhancement
Ref #9085 (spawned from Cycle 3 PR review)

Summary

The correction_diff() output in PlanApplyService currently uses decision-level data
(reverted vs added decision IDs) in the comparison section, which deviates from the
spec definition that requires file-level objects.

Additionally, the patch_preview section never produces actual unified diff hunks — it
only surfaces a descriptive note or the archived artifacts path.

Both limitations are intentional stubs introduced in PR #9221 to unblock the primary
fix and are tracked here for follow-up alignment with the specification.

Problem

  1. comparison section — The spec defines comparison as file-level objects
    (files changed, lines added, lines deleted). The current implementation uses
    decision-level data (reverted/added decision IDs) which is a known deviation from
    spec §agents plan diff.

  2. patch_preview section — Full diff output requires the corrected execution's
    completed ChangeSet, which is only available after the correction finishes executing.
    The current implementation inserts a placeholder note. Real diff hunks (unified
    patch format) should be generated once the correction's ChangeSet is available.

Acceptance Criteria

  • comparison section outputs file-level objects matching the spec:
    { "path": "...", "operation": "create|modify|delete", "lines_added": N, "lines_removed": N }
  • patch_preview section generates real unified diff hunks when a completed correction
    ChangeSet is available (post-correction execution).
  • Both plain and rich renderers update to display the file-level comparison data.
  • Existing BDD scenarios (features/plan_correction_diff.feature) updated to cover
    file-level comparison output.
  • Robot Framework integration test updated with file-level comparison assertions.

Subtasks

  • Implement file-level comparison lookup via ChangeSet entries
  • Update _build_correction_diff_dict() to emit file-level comparison objects
  • Update _render_correction_diff_plain() and _render_correction_diff_rich() for file-level output
  • Generate real patch hunks in patch_preview when ChangeSet is available post-correction
  • Update BDD scenarios to assert file-level comparison fields
  • Update Robot Framework helper to verify file-level fields

Definition of Done

  • All acceptance criteria met
  • Unit tests (Behave) pass covering file-level comparison output
  • Integration tests (Robot Framework) pass
  • Coverage ≥ 97%
  • Pyright strict typecheck passes
  • Ruff lint passes
## Metadata | Field | Value | |-------|-------| | Priority | P3/Should | | MoSCoW | Should | | Type | enhancement | | Ref | #9085 (spawned from Cycle 3 PR review) | ## Summary The `correction_diff()` output in `PlanApplyService` currently uses decision-level data (reverted vs added decision IDs) in the `comparison` section, which deviates from the spec definition that requires **file-level objects**. Additionally, the `patch_preview` section never produces actual unified diff hunks — it only surfaces a descriptive note or the archived artifacts path. Both limitations are intentional stubs introduced in PR #9221 to unblock the primary fix and are tracked here for follow-up alignment with the specification. ## Problem 1. **`comparison` section** — The spec defines `comparison` as file-level objects (files changed, lines added, lines deleted). The current implementation uses decision-level data (reverted/added decision IDs) which is a known deviation from spec §agents plan diff. 2. **`patch_preview` section** — Full diff output requires the corrected execution's completed ChangeSet, which is only available after the correction finishes executing. The current implementation inserts a placeholder note. Real diff hunks (unified patch format) should be generated once the correction's ChangeSet is available. ## Acceptance Criteria - `comparison` section outputs file-level objects matching the spec: `{ "path": "...", "operation": "create|modify|delete", "lines_added": N, "lines_removed": N }` - `patch_preview` section generates real unified diff hunks when a completed correction ChangeSet is available (post-correction execution). - Both plain and rich renderers update to display the file-level comparison data. - Existing BDD scenarios (`features/plan_correction_diff.feature`) updated to cover file-level comparison output. - Robot Framework integration test updated with file-level comparison assertions. ## Subtasks - [ ] Implement file-level comparison lookup via ChangeSet entries - [ ] Update `_build_correction_diff_dict()` to emit file-level comparison objects - [ ] Update `_render_correction_diff_plain()` and `_render_correction_diff_rich()` for file-level output - [ ] Generate real patch hunks in `patch_preview` when ChangeSet is available post-correction - [ ] Update BDD scenarios to assert file-level comparison fields - [ ] Update Robot Framework helper to verify file-level fields ## Definition of Done - [ ] All acceptance criteria met - [ ] Unit tests (Behave) pass covering file-level comparison output - [ ] Integration tests (Robot Framework) pass - [ ] Coverage ≥ 97% - [ ] Pyright strict typecheck passes - [ ] Ruff lint passes
Owner

@hurui200320 — Thank you for filing issue #10008.

This is a well-structured follow-up enhancement from the PR #9085 review cycle. The two limitations identified are clear:

  1. The comparison section uses decision-level data instead of the spec-required file-level objects
  2. The patch_preview section produces placeholder notes instead of real unified diff hunks

Triage Assessment

  • Type: Enhancement (spec alignment follow-up)
  • Priority: Medium — important for spec compliance but not blocking
  • Milestone: v3.5.0 (Autonomy Hardening — plan diff/correction functionality)
  • MoSCoW: Should Have — improves spec alignment and user experience

Next Steps

The autonomous agent system will:

  1. Apply labels: Type/Enhancement, Priority/Medium, MoSCoW/Should have, State/Unverified
  2. Assign milestone: v3.5.0
  3. Queue for implementation

The acceptance criteria and subtasks are well-defined. The implementation path is clear: file-level comparison via ChangeSet entries and real patch hunks post-correction execution.


Automated by CleverAgents Bot
Supervisor: Human Liaison | Agent: human-liaison-pool-supervisor
Worker: [AUTO-HUMAN-5]

@hurui200320 — Thank you for filing issue #10008. This is a well-structured follow-up enhancement from the PR #9085 review cycle. The two limitations identified are clear: 1. The `comparison` section uses decision-level data instead of the spec-required file-level objects 2. The `patch_preview` section produces placeholder notes instead of real unified diff hunks ## Triage Assessment - **Type**: Enhancement (spec alignment follow-up) - **Priority**: Medium — important for spec compliance but not blocking - **Milestone**: v3.5.0 (Autonomy Hardening — plan diff/correction functionality) - **MoSCoW**: Should Have — improves spec alignment and user experience ## Next Steps The autonomous agent system will: 1. Apply labels: `Type/Enhancement`, `Priority/Medium`, `MoSCoW/Should have`, `State/Unverified` 2. Assign milestone: v3.5.0 3. Queue for implementation The acceptance criteria and subtasks are well-defined. The implementation path is clear: file-level comparison via ChangeSet entries and real patch hunks post-correction execution. --- **Automated by CleverAgents Bot** Supervisor: Human Liaison | Agent: human-liaison-pool-supervisor Worker: [AUTO-HUMAN-5]
HAL9000 added this to the v3.5.0 milestone 2026-04-16 13:17:22 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

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