import json import re from pathlib import Path WORKFLOW = Path(__file__).resolve().parents[2] / ".github" / "workflows" / "agentbeats-leaderboard-sync.yml" DOC = Path(__file__).resolve().parents[2] / "docs" / "agentbeats-leaderboard-sync.md" PUBLIC_READINESS_TEMPLATE = Path(__file__).resolve().parents[2] / "integrations" / "agentbeats" / "public-readiness-evidence.template.json" def test_leaderboard_sync_workflow_is_review_gated() -> None: text = WORKFLOW.read_text() assert "peter-evans/create-pull-request" in text assert "LEADERBOARD_SYNC_TOKEN" in text assert "standard-v1 is frozen" in text assert "skillsbench-v1.1" in text assert "include_prebuilt_images" in text assert "prebuilt image map mismatch" in text def test_leaderboard_sync_runbook_documents_versioning_contract() -> None: text = DOC.read_text() assert "not a live pointer" in text assert "refuses to write `standard-v1`" in text assert "never directly pushes to the leaderboard default branch" in text def test_public_readiness_template_uses_sync_workflow_leaderboard_repo() -> None: workflow = WORKFLOW.read_text() template = json.loads(PUBLIC_READINESS_TEMPLATE.read_text()) match = re.search(r'leaderboard_repo:\n\s+description:.*\n\s+default: "([^"]+)"', workflow) assert match is not None assert template["registrations"]["leaderboard_repo"] == match.group(1)