"""Documentation checks for MCP-native commit path rules (#260)."""
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parent.parent
RUNBOOK = REPO_ROOT / "docs" / "llm-workflow-runbooks.md"
SAFETY = REPO_ROOT / "docs" / "safety-model.md"


def test_runbook_requires_mcp_native_commit_path():
    text = RUNBOOK.read_text(encoding="utf-8")
    assert "MCP-native commit path" in text
    assert "gitea_commit_files" in text
    assert "gitea.repo.commit" in text
    assert "only" in text.lower() and "approved" in text.lower()
    lower = text.lower()
    for forbidden in ("webfetch", "playwright", "manual llm-generated base64"):
        assert forbidden in lower


def test_runbook_forbids_fallback_loops():
    lower = RUNBOOK.read_text(encoding="utf-8").lower()
    assert "retry shell encoding" in lower
    assert "loop" in lower
    assert "recovery report" in lower


def test_safety_model_documents_commit_fallback_ban():
    text = SAFETY.read_text(encoding="utf-8")
    assert "Agent Commit Path" in text
    assert "gitea_commit_files" in text
    assert "WebFetch" in text
    assert "Playwright" in text
    assert "llm-workflow-runbooks.md" in text