from __future__ import annotations

from fastapi import FastAPI
from fastapi.testclient import TestClient

from src.api.v1.agents import router


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

    response = client.get("/api/v1/agents/agent-version-freshness-snapshot")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_version_freshness_snapshot_v1"
    assert data["program_status"]["overall_completion_percent"] == 42
    assert data["program_status"]["current_task_id"] == "P2-402B"
    assert data["program_status"]["next_task_id"] == "P2-402C"
    assert data["program_status"]["read_only_mode"] is True
    assert data["scan_boundaries"]["schedule_activation_allowed"] is False
    assert data["scan_boundaries"]["external_registry_lookup_allowed"] is False
    assert data["scan_boundaries"]["package_upgrade_allowed"] is False
    assert data["scan_boundaries"]["telegram_direct_send_allowed"] is False
    assert data["approval_boundaries"]["daily_schedule_enabled"] is False
    assert data["rollups"]["source_count"] == 12
    assert data["rollups"]["repo_only_source_count"] == 12
    assert data["rollups"]["mutation_allowed_source_count"] == 0
    assert data["rollups"]["schedule_enabled_count"] == 0
    assert any(
        source["source_id"] == "agent_model_governance_snapshots"
        for source in data["freshness_sources"]
    )
