Feature: Repo Indexing Persistence Coverage
  Additional scenarios that exercise previously uncovered code paths
  in the repo_indexing_persistence module.

  Background:
    Given the repo indexing persistence module is imported

  # -------------------------------------------------------------------
  # _safe_fromisoformat — corrupt timestamp fallback (lines 51-56)
  # -------------------------------------------------------------------
  Scenario: _safe_fromisoformat falls back to UTC now on corrupt timestamp
    When I parse a corrupt timestamp value "not-a-date-at-all"
    Then ripcov the result should be a UTC-aware datetime close to now
    And a warning about corrupt timestamp should be logged

  Scenario: _safe_fromisoformat falls back to UTC now on empty string
    When I parse an empty string as a timestamp
    Then ripcov the result should be a UTC-aware datetime close to now

  # -------------------------------------------------------------------
  # _safe_fromisoformat — naive datetime gets UTC attached (line 58)
  # -------------------------------------------------------------------
  Scenario: _safe_fromisoformat attaches UTC to naive datetime
    When I parse a naive ISO timestamp "2024-06-15T12:30:00"
    Then ripcov the result should be a UTC-aware datetime with the same wall-clock time

  # -------------------------------------------------------------------
  # persist_status — error_message validation (line 81)
  # -------------------------------------------------------------------
  Scenario: persist_status rejects error_message when status is not ERROR
    Given a mock session factory for persistence tests
    When I call persist_status with status READY and an error_message
    Then a ValueError should be raised about error_message

  # -------------------------------------------------------------------
  # persist_status — exception rollback path (lines 112-114)
  # -------------------------------------------------------------------
  Scenario: persist_status rolls back session on commit failure
    Given a mock session factory that raises on commit
    When I call persist_status and the session commit fails
    Then ripcov the session should have been rolled back
    And the original exception should be re-raised

  # -------------------------------------------------------------------
  # persist_index — exception rollback path (lines 181-183)
  # -------------------------------------------------------------------
  Scenario: persist_index rolls back session on commit failure
    Given a mock session factory that raises on commit for persist_index
    When I call persist_index and the session commit fails
    Then the persist_index session should have been rolled back
    And the persist_index original exception should be re-raised

  # -------------------------------------------------------------------
  # load_index — corrupt file record skip (lines 219-222)
  # -------------------------------------------------------------------
  Scenario: load_index skips corrupt file records with a warning
    Given a mock session factory with an index row and a corrupt file record
    When I call load_index for the resource
    Then ripcov the result should be a RepoIndex with zero files
    And a warning about skipping corrupt file record should be logged

  # -------------------------------------------------------------------
  # load_index_status — returns None for missing resource (line 259)
  # -------------------------------------------------------------------
  Scenario: load_index_status returns None for non-existent resource
    Given a mock session factory that returns no index row
    When I call load_index_status for a missing resource
    Then ripcov the result should be None
