from __future__ import annotations

from src.services.agent_reference_adapter import build_reference_candidate_result


def test_reference_adapter_emits_candidate_result_contract():
    result = build_reference_candidate_result({
        "schema_version": "agent_replay_candidate_input_v1",
        "run_id": "run",
        "incident_id": "INC-1",
        "incident_context": {
            "severity": "P1",
            "affected_services": ["checkout"],
            "signals": [
                {
                    "labels": {"namespace": "prod"},
                    "annotations": {"summary": "pod CrashLoopBackOff"},
                }
            ],
        },
        "source_metadata": {},
    }).to_dict()

    assert result["schema_version"] == "agent_candidate_replay_result_v1"
    assert result["candidate_id"] == "reference_deterministic_adapter"
    assert result["incident_id"] == "INC-1"
    assert result["proposed_action"] == "kubectl rollout restart deployment checkout -n prod"
    assert result["risk_level"] == "medium"
    assert result["requires_human_approval"] is True
    assert result["trace_complete"] is True
    assert result["metadata"]["not_market_evidence"] is True
