"""Tests for the recipes seam: ``recipes_dir`` / ``list_recipes`` / ``read_recipe``.

The recipes corpus (``docs/recipes/``) is shipped as wheel data so a CLI can
surface a governance recipe — notably the ``/sync`` federation sync prompt —
from the version a consumer pins rather than a hand-copied command body that
drifts. These pin the resolver behaviour and the invariant that the sync
prompt is reachable.
"""

from __future__ import annotations

import pytest

import mgf.standard as ds


class TestRecipesSeam:
    def test_recipes_dir_resolves_to_a_dir_with_an_index(self) -> None:
        d = ds.recipes_dir()
        assert d.is_dir()
        assert (d / "README.md").is_file()

    def test_list_recipes_nonempty_and_sorted(self) -> None:
        recipes = ds.list_recipes()
        assert recipes, "recipes corpus resolved empty"
        assert recipes == sorted(recipes)
        assert all(isinstance(r, str) for r in recipes)

    def test_federation_sync_prompt_is_reachable(self) -> None:
        # The /sync prompt is the load-bearing recipe a CLI surfaces; pin
        # that it is present and carries the prompt block agents run.
        assert "federation-sync-prompt" in ds.list_recipes()
        text = ds.read_recipe("federation-sync-prompt")
        assert "federation-conformance engineer" in text

    def test_read_recipe_unknown_name_raises_with_available(self) -> None:
        with pytest.raises(FileNotFoundError) as exc:
            ds.read_recipe("no-such-recipe")
        # The error lists what *is* available, mirroring read_standard.
        assert "federation-sync-prompt" in str(exc.value)

    def test_recipes_and_standards_corpora_are_distinct(self) -> None:
        assert ds.recipes_dir() != ds.standards_dir()
