from __future__ import annotations

from fastapi import FastAPI
from fastapi.testclient import TestClient

from src.api.v1.agents import router


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

    response = client.get("/api/v1/agents/market-governance-snapshot")

    assert response.status_code == 200
    data = response.json()
    assert data["schema_version"] == "agent_market_governance_snapshot_v1"
    assert data["current_decision"] == "openclaw_remains_production_decision_core"
    assert data["summary"]["candidate_count"] == 13
    assert data["summary"]["replacement_decisions_approved"] == 0
    assert data["policy"]["replacement_decision_allowed"] is False
