gabriel / musehub public

test_coord_record_id.py file-level

at sha256:a · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:b Merge 'docs/security-monitoring-verified' into 'dev' — proposal: docs+i… · gabriel · Aug 29, 2026
1 """MusehubCoordRecord.record_id must be String(128) not String(36).
2
3 record_uuid was a misnomer — the field stores sha256: genesis IDs
4 (71 chars for reservations/tasks/intents) and opaque run_id strings,
5 not random 36-char strings. This guards the rename and the column width.
6 """
7 from __future__ import annotations
8
9 import pytest
10 from sqlalchemy import String
11
12 from musehub.db.coord_models import MusehubCoordRecord
13
14
15 def _col(name: str) -> None:
16 return MusehubCoordRecord.__table__.columns[name]
17
18
19 def test_record_id_column_exists() -> None:
20 assert "record_id" in MusehubCoordRecord.__table__.columns
21
22
23 def test_record_uuid_column_gone() -> None:
24 assert "record_uuid" not in MusehubCoordRecord.__table__.columns
25
26
27 def test_record_id_is_string_128() -> None:
28 col = _col("record_id")
29 assert isinstance(col.type, String)
30 assert col.type.length == 128
31
32
33 def test_record_id_not_nullable() -> None:
34 assert _col("record_id").nullable is False
35
36
37 def test_unique_constraint_uses_record_id() -> None:
38 constraint_cols = {
39 col.name
40 for c in MusehubCoordRecord.__table__.constraints
41 for col in getattr(c, "columns", [])
42 }
43 assert "record_id" in constraint_cols
44 assert "record_uuid" not in constraint_cols