Feature: Fix-then-Revalidate coverage round 3
  As a developer
  I want to cover remaining uncovered lines in FixThenRevalidateOrchestrator
  So that code coverage meets the target threshold

  # Covers line 354: get_retry_count returns value from existing plan entry
  Scenario: ftrcov3 get_retry_count returns count when plan has existing retries
    Given a ftrcov3 orchestrator with max_retries 3
    And the ftrcov3 internal retry count for plan "P-SEED" validation "check-seed" resource "RES0001" is set to 2
    Then the ftrcov3 get_retry_count for plan "P-SEED" validation "check-seed" resource "RES0001" should be 2

  # Covers line 576: break when current >= max_retries inside _fix_single_validation
  # Covers lines 765-769, 771: not-attempted warning path
  # Also covers line 354 via get_retry_count call at line 768
  Scenario: ftrcov3 pre-exhausted retry budget causes immediate break and warning
    Given a ftrcov3 orchestrator with max_retries 1
    And the ftrcov3 internal retry count for plan "P-PREEX" validation "check-preex" resource "RES0001" is set to 1
    And a ftrcov3 required validation "check-preex" that fails
    And a ftrcov3 fix callback that always succeeds
    And a ftrcov3 revalidate callback that never passes
    When the ftrcov3 fix loop runs for plan "P-PREEX"
    Then the ftrcov3 result should have final_passed False
    And the ftrcov3 result should need user escalation
    And the ftrcov3 result should have validation_attempts 0

  # Covers line 650: non-string fix_description is coerced via str()
  Scenario: ftrcov3 fix callback returning non-string value is coerced to string
    Given a ftrcov3 orchestrator with max_retries 1
    And a ftrcov3 required validation "check-coerce" that fails
    And a ftrcov3 fix callback that returns an integer
    And a ftrcov3 revalidate callback that passes after 1 fix
    When the ftrcov3 fix loop runs for plan "P-COERCE"
    Then the ftrcov3 result should have final_passed True
    And the ftrcov3 result should have validation_attempts 1
    And the ftrcov3 fix history record 1 fix_description should contain "42"

  # Covers lines 765-769, 771 via max_retries=0 path (range(0) never enters loop)
  Scenario: ftrcov3 max retries zero means no fix attempts and logs warning
    Given a ftrcov3 orchestrator with max_retries 0
    And a ftrcov3 required validation "check-zero" that fails
    And a ftrcov3 fix callback that always succeeds
    And a ftrcov3 revalidate callback that never passes
    When the ftrcov3 fix loop runs for plan "P-ZERO"
    Then the ftrcov3 result should have final_passed False
    And the ftrcov3 result should need user escalation
    And the ftrcov3 result should have validation_attempts 0

  # Covers line 808: circuit breaker return in _emit_event after 5 consecutive failures
  Scenario: ftrcov3 event bus circuit breaker silences emissions after consecutive failures
    Given a ftrcov3 orchestrator with max_retries 3 and a failing event bus
    And a ftrcov3 required validation "check-cb1" that fails
    And a ftrcov3 required validation "check-cb2" that fails
    And a ftrcov3 fix callback that always succeeds
    And a ftrcov3 revalidate callback that never passes
    When the ftrcov3 fix loop runs for plan "P-CIRCUIT"
    Then the ftrcov3 result should have final_passed False
    And the ftrcov3 event bus consecutive failures should be at least 5
