from __future__ import annotations

from fastapi import FastAPI
from fastapi.testclient import TestClient

from src.api.v1.agents import router


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

    response = client.get("/api/v1/agents/agent-interaction-learning-proof")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "ai_agent_interaction_learning_proof_v1"
    assert data["program_status"]["overall_completion_percent"] == 100
    assert data["program_status"]["current_task_id"] == "P2-403J"
    assert data["program_status"]["next_task_id"] == "P2-403K"
    assert data["program_status"]["read_only_mode"] is True
    assert data["live_truth"]["runtime_loop_enabled"] is False
    assert data["live_truth"]["active_live_agent_sessions"] == 0
    assert data["live_truth"]["live_learning_writes_24h"] == 0
    assert data["frontend_redaction"]["operator_conversation_display_allowed"] is False
    assert data["approval_boundaries"]["conversation_transcript_display_allowed"] is False
    assert data["approval_boundaries"]["telegram_direct_send_allowed"] is False
    assert data["rollups"]["proof_level_count"] == 9
    assert data["rollups"]["contract_ready_level_count"] == 7
    assert data["rollups"]["signal_count"] == 11
    assert data["rollups"]["live_signal_count"] == 0
    assert data["rollups"]["operator_surface_count"] == 5
    assert any(lane["agent_id"] == "openclaw" for lane in data["agent_lanes"])
    assert any(lane["agent_id"] == "hermes" for lane in data["agent_lanes"])
    assert any(lane["agent_id"] == "nemotron" for lane in data["agent_lanes"])
