from __future__ import annotations

from fastapi import FastAPI
from fastapi.testclient import TestClient

from src.api.v1.agents import router


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

    response = client.get("/api/v1/agents/agent-deployment-layout")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_deployment_layout_v1"
    assert data["program_status"]["overall_completion_percent"] == 45
    assert data["program_status"]["current_task_id"] == "P1-402"
    assert data["program_status"]["next_task_id"] == "P1-403"
    assert data["program_status"]["read_only_mode"] is True
    assert data["rollups"]["total_targets"] == 42
    assert data["rollups"]["by_domain"]["hosts"] == 6
    assert data["rollups"]["by_domain"]["websites"] == 5
    assert data["rollups"]["by_primary_agent"]["nemotron"] == 2
    assert data["approval_boundaries"]["telegram_direct_send_allowed"] is False
    assert data["approval_boundaries"]["autonomous_host_mutation_allowed"] is False
    assert data["collaboration_contract"]["frontend_redaction"]["operator_conversation_display_allowed"] is False
    assert any(target["target_id"] == "telegram_gateway" for target in data["deployment_targets"])
    assert any(target["target_id"] == "nemotron_replay_pipeline" for target in data["deployment_targets"])
