"""Schema obligations from business-app-service-contract_v0.1 § 1.3.""" from __future__ import annotations from canned_prompts_service import models def test_every_owned_table_is_tenant_keyed() -> None: for table in models.Base.metadata.sorted_tables: assert "tenant" in table.c, f"{table.name} holds owned data without a tenant key" def test_uniqueness_is_scoped_by_tenant_and_registry() -> None: """Identity is registry-scoped (§ 3.2); two tenants may hold the same id.""" constraint = next( c for c in models.PackageVersion.__table__.constraints if getattr(c, "name", "") == "uq_package_version" ) assert [c.name for c in constraint.columns] == ["tenant", "registry", "package_id", "version"] def test_index_entry_records_arrival_not_authorship() -> None: columns = models.IndexEntry.__table__.c assert "included_at" in columns and "last_seen_at" in columns assert "source" in columns and "method" in columns