"""MusehubCoordRecord.record_id must be String(128) not String(36). record_uuid was a misnomer — the field stores sha256: genesis IDs (71 chars for reservations/tasks/intents) and opaque run_id strings, not random 36-char strings. This guards the rename and the column width. """ from __future__ import annotations import pytest from sqlalchemy import String from musehub.db.coord_models import MusehubCoordRecord def _col(name: str) -> None: return MusehubCoordRecord.__table__.columns[name] def test_record_id_column_exists() -> None: assert "record_id" in MusehubCoordRecord.__table__.columns def test_record_uuid_column_gone() -> None: assert "record_uuid" not in MusehubCoordRecord.__table__.columns def test_record_id_is_string_128() -> None: col = _col("record_id") assert isinstance(col.type, String) assert col.type.length == 128 def test_record_id_not_nullable() -> None: assert _col("record_id").nullable is False def test_unique_constraint_uses_record_id() -> None: constraint_cols = { col.name for c in MusehubCoordRecord.__table__.constraints for col in getattr(c, "columns", []) } assert "record_id" in constraint_cols assert "record_uuid" not in constraint_cols