Feature: Plan apply correction diff rendering functions
  As a developer maintaining plan_apply_service.py
  I want to cover _build_correction_diff_dict, _render_correction_diff_plain, and _render_correction_diff_rich
  So that all output rendering branches are exercised

  @coverage
  Scenario: Build correction diff dict with full data including artifacts path
    Given I have a CorrectionAttemptRecord with mode="revert", original_decision_id="dec1", new_decision_id="dec2", guidance="Test fix", and archived_artifacts_path="/artifacts/zip"
    When I call _build_correction_diff_dict on the record
    Then the result should contain "correction_diff", "comparison", and "patch_preview" keys
    And the comparison should have 1 reverted decision and 1 added decision
    And the patch preview should include the artifacts path

  @coverage
  Scenario: Build correction diff dict without new_decision_id or archived artifacts
    Given I have a CorrectionAttemptRecord with mode="append", original_decision_id="dec3", no new_decision, guidance="Review needed", and no archived artifacts
    When I call _build_correction_diff_dict on the record
    Then the result should contain "correction_diff", "comparison", and "patch_preview" keys
    And the comparison counts are "1" reverted decisions and "0" new ones
    And the patch preview should indicate correction execution is pending

  @coverage
  Scenario: Render correction diff dict as plain text with artifacts
    Given I have a correction diff dict with mode="revert", original_decision_id="dec-100", guidance="Fix logic", completed_at present, and one added decision "dec-200"
    When I call _render_correction_diff_plain on the dict
    Then the output should contain "Correction Diff" heading
    And the output should contain the mode value "revert"
    And the output should contain "[OK] Correction diff generated" trailer
    And the output should contain "Completed:" timestamp
    And the output should contain the added decision line starting with "+ dec-200"

  @coverage
  Scenario: Render correction diff dict as plain text without completed_at or guidance
    Given I have a correction diff dict with mode="append", original_decision_id="dec-300", no guidance text, and patch preview note about pending execution
    When I call _render_correction_diff_plain on the dict
    Then the output should contain "Correction Diff" heading
    And the output should NOT contain "Completed:" line
    And the output should NOT contain a "Guidance:" line
    And the output should contain "[OK] Correction diff generated" trailer
    And the output should contain the pending-execution note text

  @coverage
  Scenario: Render correction diff dict as rich text with artifacts
    Given I have a correction diff dict with mode="revert", original_decision_id="dec-rc1", guidance="Patch rollback", completed_at present, and one added decision "dec-rc2"
    When I call _render_correction_diff_rich on the dict
    Then the output should contain "[bold]Correction Diff[/bold]" heading
    And the output should contain "[cyan]revert[/cyan]" mode color markup
    And the output should contain the rich green checkmark marker at end
    And the output should contain a red-colored reverted decision ID
    And the output should contain a green-colored added decision ID

  @coverage
  Scenario: Render correction diff dict as rich text without guidance or completion
    Given I have a correction diff dict with mode="append", original_decision_id="dec-rc3", no guidance, and patch preview note about pending execution
    When I call _render_correction_diff_rich on the dict
    Then the output should contain "[bold]Correction Diff[/bold]" heading
    And the output should NOT contain a "Guidance" line
    And the output should contain the pending-execution note in dim markup
