Feature: Issue 6323 coverage — _format_size edge cases and formatting helper paths

  Background:
    Given a project context CLI in-memory database is initialized

  @tdd_issue @tdd_issue_6323
  Scenario Outline: _format_size covers all size display branches
    When I invoke the _format_size helper with "<input>"
    Then the _format_size result should be "<expected>"

    Examples:
      | input         | expected    |
      | None          | (no limit)  |
      | 0             | 0 bytes     |
      | 1             | 1 byte      |
      | 500           | 500 bytes   |
      | 1024          | 1 KB        |
      | 1536          | 1.5 KB      |
      | 1572864       | 1.5 MB      |
      | 1073741824    | 1 GB        |
      | 2684354560    | 2.5 GB      |
      | 1099511627776 | 1 TB        |
      | 1649267441664 | 1.5 TB      |

  @tdd_issue @tdd_issue_6323
  Scenario: format_output wraps a dict message correctly in the json envelope
    When I invoke format_output json with dict message level "warn" text "dict-msg-test"
    Then the json envelope contains dict message with level "warn" text "dict-msg-test"

  @tdd_issue @tdd_issue_6323
  Scenario: format_output raises ValueError for a dict message missing required keys
    When I invoke format_output json with malformed dict message
    Then a ValueError is raised for the malformed message

  @tdd_issue @tdd_issue_6323
  Scenario: format_output plain output with empty-level dict message omits bracket prefix
    When I invoke format_output plain with empty-level dict message text "no-prefix-plain"
    Then the plain output contains "no-prefix-plain" without bracket prefix

  @tdd_issue @tdd_issue_6323
  Scenario: context show rich renders Execution Environment panel when policy blob has env set
    Given a project "local/cov-ee" exists for context CLI
    And issue 6323 project context sample is configured for "local/cov-ee"
    And the context tier service has sample usage data for "local/cov-ee"
    When I run context show rich on "local/cov-ee" with execution environment and integer depth gradient
    Then the context show command should succeed
    And the context show output contains "Execution Environment"

  @tdd_issue @tdd_issue_6323
  Scenario: context show rich handles depth gradient keys that cannot be parsed as integers
    Given a project "local/cov-dg" exists for context CLI
    And issue 6323 project context sample is configured for "local/cov-dg"
    And the context tier service has sample usage data for "local/cov-dg"
    When I run context show rich on "local/cov-dg" with non-integer depth gradient keys
    Then the context show command should succeed
    And the context show output contains "ACMS Pipeline"
