@tdd_issue @tdd_issue_8584
Feature: TDD Bug #8584 - plan correct JSON output missing spec-required envelope format
  As a developer
  I want plan correct --format json to return the standard CLI envelope
  So that JSON consumers receive the spec-required nested data structure

  The v3.2.0 specification (section CLI Commands - agents plan correct, line 14912 in
  docs/specification.md) defines the required JSON output envelope for
  agents plan correct --format json.

  The spec requires the correction data to be nested under data.correction:

      {
        "command": "plan correct",
        "status": "ok",
        "exit_code": 0,
        "data": {
          "correction": {
            "mode": "revert",
            "impact": "...",
            ...
          },
          "affected_subtree": {...},
          ...
        },
        "timing": {...},
        "messages": ["Correction applied"]
      }

  The current implementation places correction fields directly under data
  (data.mode, data.correction_id) instead of nesting them under data.correction.
  This means data.correction.mode is absent from the output.

  These scenarios assert the expected (correct) behaviour and validate
  that the fix is in place.

  All step text uses the tpcjo prefix to avoid collisions with other step files.

  @tdd_issue @tdd_issue_8584
  Scenario: plan correct --format json data.correction.mode is present in revert mode
    Given tpcjo a container with a plan and a correction service that succeeds in revert mode
    When tpcjo I invoke plan correct with --format json in revert mode
    Then tpcjo the JSON output data.correction.mode should be "revert"

  @tdd_issue @tdd_issue_8584
  Scenario: plan correct --format json data.correction.mode is present in append mode
    Given tpcjo a container with a plan and a correction service that succeeds in append mode
    When tpcjo I invoke plan correct with --format json in append mode
    Then tpcjo the JSON output data.correction.mode should be "append"

  @tdd_issue @tdd_issue_8584
  Scenario: plan correct --format json command field is set to plan correct
    Given tpcjo a container with a plan and a correction service that succeeds in revert mode
    When tpcjo I invoke plan correct with --format json in revert mode
    Then tpcjo the JSON output command field should be "plan correct"
