@tdd_issue @tdd_issue_680 @tdd_issue_4177
Feature: TDD Issue #680 — session list with missing database
  As a developer
  I want to verify that `agents session list` handles a missing database
  gracefully
  So that the bug is captured and will be caught by a regression test

  The CLI `session list` command should work even when no database file
  exists.  Currently `_get_session_service()` calls `container.db()`,
  but the Container class has no `db` provider, causing an
  AttributeError at runtime.  Even after the DI wiring is fixed, the
  database file itself must be auto-created so the command returns an
  empty list rather than crashing.

  Scenario: Session list with missing database exits successfully
    Given a CLI runner with no database file present
    When I invoke session list with missing db
    Then the session list missing db command should exit successfully
    And the session list missing db output should not contain "AttributeError"

  Scenario: Session list with missing database produces valid JSON
    Given a CLI runner with no database file present
    When I invoke session list with missing db and format json
    Then the session list missing db command should exit successfully
    And the session list missing db output should be valid JSON

  Scenario: Session list with missing database shows empty list
    Given a CLI runner with no database file present
    When I invoke session list with missing db
    Then the session list missing db command should exit successfully
    And the session list missing db output should indicate no sessions
