import json from pathlib import Path from scripts.export_agent_contract import PACK, build_contract def test_pack_mcp_contract_matches_the_live_server_and_generated_schemas( tmp_path: Path, ) -> None: snapshot_path = PACK / "contracts" / "service-v1.json" snapshot = json.loads(snapshot_path.read_text(encoding="utf-8")) actual = build_contract(tmp_path) assert actual == snapshot assert (PACK / "contracts" / "catalog-v1.json").read_bytes() == ( Path(__file__).resolve().parents[2] / "schema" / "v1" / "catalog.json" ).read_bytes() packaged_schemas = PACK / "contracts" for schema in snapshot["record_schemas"]: schema_path = packaged_schemas / schema["path"] assert schema_path.is_file() assert ( schema_path.read_bytes() == ( Path(__file__).resolve().parents[2] / "schema" / "v1" / "records" / Path(schema["path"]).name ).read_bytes() )