from __future__ import annotations

from fastapi import FastAPI
from fastapi.testclient import TestClient

from src.api.v1.agents import router


def test_ai_agent_redis_dry_run_gate_endpoint_returns_committed_snapshot():
    app = FastAPI()
    app.include_router(router, prefix="/api/v1")
    client = TestClient(app)

    response = client.get("/api/v1/agents/agent-redis-dry-run-gate")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_redis_dry_run_gate_v1"
    assert data["program_status"]["overall_completion_percent"] == 65
    assert data["program_status"]["current_task_id"] == "P2-403C"
    assert data["program_status"]["next_task_id"] == "P2-403D"
    assert data["dry_run_truth"]["redis_connection_allowed"] is False
    assert data["dry_run_truth"]["consumer_group_created"] is False
    assert data["dry_run_truth"]["live_dry_run_event_count"] == 0
    assert data["consumer_group_dry_run_contract"]["fixture_only"] is True
    assert data["consumer_group_dry_run_contract"]["redis_network_call_allowed"] is False
    assert data["ack_dead_letter_replay_contract"]["runtime_replay_allowed"] is False
    assert data["approval_boundaries"]["consumer_group_creation_allowed"] is False
    assert data["approval_boundaries"]["telegram_send_allowed"] is False
    assert data["rollups"]["dry_run_step_count"] == 5
    assert data["rollups"]["handoff_lane_count"] == 3
    assert data["rollups"]["live_truth_count_total"] == 0
