Feature: Plan correction diff command As a developer using the v3 plan lifecycle I want to view a structured diff for a correction attempt So that I can understand what changes a correction will introduce # ---------- All 4 output formats ---------- Scenario: correction diff returns rich format output Given correction-diff a mocked apply service returning rich correction diff When correction-diff I run plan diff for "PLAN-001" with correction "CORR-001" format "rich" Then correction-diff the exit code should be 0 And correction-diff the output should contain "Correction Diff" And correction-diff the output should contain "CORR-001" Scenario: correction diff returns plain format output Given correction-diff a mocked apply service returning plain correction diff When correction-diff I run plan diff for "PLAN-002" with correction "CORR-002" format "plain" Then correction-diff the exit code should be 0 And correction-diff the output should contain "Correction Diff" And correction-diff the output should contain "CORR-002" Scenario: correction diff returns json format output Given correction-diff a mocked apply service returning json correction diff for "CORR-003" When correction-diff I run plan diff for "PLAN-003" with correction "CORR-003" format "json" Then correction-diff the exit code should be 0 And correction-diff the output should contain "correction_diff" And correction-diff the output should contain "CORR-003" And correction-diff the service was called with format "json" Scenario: correction diff returns yaml format output Given correction-diff a mocked apply service returning yaml correction diff for "CORR-004" When correction-diff I run plan diff for "PLAN-004" with correction "CORR-004" format "yaml" Then correction-diff the exit code should be 0 And correction-diff the output should contain "correction_diff" And correction-diff the output should contain "CORR-004" And correction-diff the service was called with format "yaml" # ---------- Error paths ---------- Scenario: correction diff raises PlanError when plan not found Given correction-diff the apply service correction_diff raises PlanError "Plan PLAN-999 not found" When correction-diff I run plan diff for "PLAN-999" with correction "CORR-999" format "rich" Then correction-diff the exit code should be nonzero And correction-diff the output should contain "Diff Error" And correction-diff the output should contain "Plan PLAN-999 not found" Scenario: correction diff raises PlanError when correction not found Given correction-diff the apply service correction_diff raises PlanError "Correction attempt CORR-404 not found" When correction-diff I run plan diff for "PLAN-001" with correction "CORR-404" format "rich" Then correction-diff the exit code should be nonzero And correction-diff the output should contain "Diff Error" And correction-diff the output should contain "Correction attempt CORR-404 not found" Scenario: correction diff raises PlanError when attempt does not belong to the plan Given correction-diff the apply service correction_diff raises PlanError "Correction attempt CORR-001 does not belong to plan PLAN-999" When correction-diff I run plan diff for "PLAN-999" with correction "CORR-001" format "rich" Then correction-diff the exit code should be nonzero And correction-diff the output should contain "Diff Error" And correction-diff the output should contain "does not belong to plan" Scenario: correction diff raises error when plan_id is empty Given correction-diff the apply service correction_diff raises ValidationError "plan_id must not be empty" When correction-diff I run plan diff for "" with correction "CORR-001" format "rich" Then correction-diff the exit code should be nonzero And correction-diff the output should contain "Error" And correction-diff the output should contain "plan_id must not be empty" Scenario: correction diff raises error when correction_attempt_id is empty (service guard) # The CLI passes --correction through to correction_diff() only when it is non-empty. # The service-level ValidationError guard for empty correction_attempt_id is tested # here by mocking the service to raise the error and asserting the CLI surfaces it. Given correction-diff the apply service correction_diff raises ValidationError "correction_attempt_id must not be empty" When correction-diff I run plan diff for "PLAN-001" with correction "CORR-001" format "rich" Then correction-diff the exit code should be nonzero And correction-diff the output should contain "Error" And correction-diff the output should contain "correction_attempt_id must not be empty"