"""Public and synthetic fixtures for a small Qaf-style benchmark."""


VERSE_TOOL = {
    "type": "function",
    "function": {
        "name": "get_quran_verses",
        "description": "Retrieve a verse or continuous range within one surah. Arabic is always returned. English adds a translation.",
        "parameters": {
            "type": "object",
            "properties": {
                "verseKey": {"type": "string", "description": "A key like 2:255 or 2:255-257"},
                "locale": {"type": "string", "enum": ["ar", "en"]},
            },
            "required": ["verseKey", "locale"],
            "additionalProperties": False,
        },
    },
}

SEARCH_TOOL = {
    "type": "function",
    "function": {
        "name": "search_library",
        "description": "Search the library for passages relevant to a topic. Use get_quran_verses for known verse references.",
        "parameters": {
            "type": "object",
            "properties": {"query": {"type": "string"}},
            "required": ["query"],
            "additionalProperties": False,
        },
    },
}

CASES = [
    {
        "id": "citation-grounding",
        "prompt": (
            "Use these paraphrased evidence cards. 49:12 cautions against excessive suspicion, "
            "spying, and backbiting. 49:13 says peoples and tribes were made to know one another. "
            "17:23 calls for kind speech toward parents. "
            "Return a JSON object with exactly two fields, 'backbiting' and 'meeting_other_peoples'. "
            "Set each value to the single verse key that most directly supports that topic."
        ),
        "expected": {"backbiting": "49:12", "meeting_other_peoples": "49:13"},
        "source_urls": [
            "https://qaf.ai/passages/dc667776-78b6-5dce-a714-610257ba5852",
            "https://qaf.ai/passages/55e49c7c-78a4-50e8-ab39-13ddff9dd15a",
            "https://qaf.ai/passages/369d729c-fdb7-5c55-b9c4-aa115689edf9",
        ],
    },
    {
        "id": "arabic-evidence",
        "prompt": (
            "اقرأ البطاقات التالية. 94:5-6 تذكر أن مع العسر يسرا. "
            "49:13 تذكر أن الشعوب والقبائل جعلت للتعارف. "
            "أرجع كائن JSON فقط بمفتاحين: 'الآية' و'الكلمة'. "
            "ضع في 'الآية' نطاق الآيات المرتبط بالعسر، وفي 'الكلمة' الاسم المقابل للعسر "
            "من البطاقة دون تشكيل أو تنوين ودون ألف التنوين."
        ),
        "expected": {"الآية": "94:5-6", "الكلمة": "يسر"},
        "source_urls": [
            "https://qaf.ai/passages/63893911-c065-5832-9dc7-89cdabad3cee",
            "https://qaf.ai/passages/55e49c7c-78a4-50e8-ab39-13ddff9dd15a",
        ],
    },
    {
        "id": "insufficient-evidence",
        "prompt": (
            "A reader asks whether the supplied excerpt fixes a specific cash amount for a charity payment. "
            "The sole evidence card, A, is a paraphrase of 2:261 about the reward for spending one's wealth. "
            "The excerpt contains no payment amount. Use this evidence only. "
            "Return JSON with exactly 'status' (one of 'supported' or 'insufficient_evidence') and 'amount' "
            "(a number only if established by the evidence; otherwise null)."
        ),
        "expected": {"status": "insufficient_evidence", "amount": None},
        "source_urls": ["https://qaf.ai/passages/26454100-6508-5d17-b22f-b6a8365d5bb6"],
    },
    {
        "id": "catalog-attribution",
        "prompt": (
            "Use this synthetic library catalog. Records: A, title 'Commentary', author 'Ahmad al-Basri', "
            "edition 2001; B, title 'Commentary', author 'Ahmad al-Basri', edition 2010; C, title 'Commentary', "
            "author 'Ahmad al-Kufi', edition 2010. An excerpt identifies itself as Ahmad al-Basri, edition 2010, "
            "printed page 73, scan image 81. Return JSON with exactly 'record_id' and 'printed_page' (integer)."
        ),
        "expected": {"record_id": "B", "printed_page": 73},
    },
    {
        "id": "retrieval-ranking",
        "prompt": (
            "These synthetic search results are triples of (id, source, relevance): "
            "(P6, A, 0.93), (P1, A, 0.90), (P3, B, 0.88), (P2, C, 0.88), "
            "(P4, D, 0.77), (P5, D, 0.85). Keep the result of highest relevance per source. "
            "Sort by decreasing relevance, breaking ties by ascending ID. "
            "Return exactly one JSON object with 'ranked_ids' set to the first four IDs in order."
        ),
        "expected": {"ranked_ids": ["P6", "P2", "P3", "P5"]},
    },
    {
        "id": "verse-window",
        "prompt": (
            "A library is displaying surah 112, which has exactly four verses. A reader selected verse 2. "
            "Expand by two verses on each side, but never cross a surah boundary or include verse zero. "
            "Return exactly a JSON object with the keys 'verse_key' (format surah:start-end) and 'count' "
            "(integer number of included verses)."
        ),
        "expected": {"verse_key": "112:1-4", "count": 4},
        "source_urls": ["https://qaf.ai/passages/993637c5-c268-53ac-9c2e-4b0c42d205b2"],
    },
    {
        "id": "verse-tool-routing",
        "prompt": (
            "Use the best available tool to fetch Quran 2:255 through 2:257 inclusive with an English "
            "translation. Make one tool call for the requested range."
        ),
        "tools": [VERSE_TOOL, SEARCH_TOOL],
        "expected": [{"name": "get_quran_verses", "arguments": {"verseKey": "2:255-257", "locale": "en"}}],
    },
]
