test_ui_commits_no_commit_meta.py
python
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595
fix: typing audit — 0 violations, 0 untyped defs across all…
Sonnet 4.6
minor
⚠ breaking
21 days ago
| 1 | """TDD — ui_commits must not read commit_meta.""" |
| 2 | from __future__ import annotations |
| 3 | |
| 4 | import pytest |
| 5 | from datetime import datetime, timezone |
| 6 | from sqlalchemy.ext.asyncio import AsyncSession |
| 7 | |
| 8 | from muse.core.types import blob_id |
| 9 | from musehub.db import musehub_repo_models as db |
| 10 | from tests.factories import create_repo |
| 11 | |
| 12 | |
| 13 | def _utc() -> datetime: |
| 14 | return datetime.now(tz=timezone.utc) |
| 15 | |
| 16 | |
| 17 | async def _add_commit(session: AsyncSession, repo_id: str, seed: str, **kwargs: typing.Any) -> db.MusehubCommit: |
| 18 | row = db.MusehubCommit( |
| 19 | commit_id=blob_id(seed.encode()), |
| 20 | branch="dev", |
| 21 | parent_ids=[], |
| 22 | message=f"feat: {seed}", |
| 23 | author="gabriel", |
| 24 | timestamp=_utc(), |
| 25 | **kwargs, |
| 26 | ) |
| 27 | session.add(row) |
| 28 | session.add(db.MusehubCommitRef(repo_id=repo_id, commit_id=row.commit_id)) |
| 29 | await session.commit() |
| 30 | await session.refresh(row) |
| 31 | return row |
| 32 | |
| 33 | |
| 34 | # --------------------------------------------------------------------------- |
| 35 | # C1 — ORM row exposes all fields used by the provenance block |
| 36 | # --------------------------------------------------------------------------- |
| 37 | |
| 38 | @pytest.mark.asyncio |
| 39 | async def test_c1_commit_orm_has_provenance_columns( |
| 40 | db_session: AsyncSession, |
| 41 | ) -> None: |
| 42 | """MusehubCommit has all fields the commit detail provenance block reads.""" |
| 43 | repo = await create_repo(db_session, owner="gabriel", visibility="public") |
| 44 | row = await _add_commit( |
| 45 | db_session, repo.repo_id, "commits-prov-c1", |
| 46 | agent_id="claude-code", model_id="claude-sonnet-4-6", |
| 47 | sem_ver_bump="patch", breaking_changes=["src/main.py::Fn"], |
| 48 | signature="ed25519:SIG", signer_key_id="key-1", |
| 49 | toolchain_id="muse-1", prompt_hash="abc", test_runs=1, |
| 50 | reviewed_by=["alice"], |
| 51 | ) |
| 52 | |
| 53 | assert not hasattr(row, "commit_meta") |
| 54 | |
| 55 | # These are the exact reads the provenance block in ui_commits.py must use |
| 56 | provenance = { |
| 57 | "sem_ver_bump": row.sem_ver_bump or "none", |
| 58 | "agent_id": row.agent_id or "", |
| 59 | "model_id": row.model_id or "", |
| 60 | "toolchain_id": row.toolchain_id or "", |
| 61 | "prompt_hash": row.prompt_hash or "", |
| 62 | "signature": row.signature or "", |
| 63 | "signer_key_id": row.signer_key_id or "", |
| 64 | "format_version": 1, |
| 65 | "reviewed_by": list(row.reviewed_by or []), |
| 66 | "test_runs": int(row.test_runs or 0), |
| 67 | "breaking_changes": list(row.breaking_changes or []), |
| 68 | "is_agent": bool(row.agent_id), |
| 69 | } |
| 70 | |
| 71 | assert provenance["agent_id"] == "claude-code" |
| 72 | assert provenance["sem_ver_bump"] == "patch" |
| 73 | assert provenance["breaking_changes"] == ["src/main.py::Fn"] |
| 74 | assert provenance["test_runs"] == 1 |
| 75 | assert provenance["signature"] == "ed25519:SIG" |
| 76 | assert provenance["is_agent"] is True |
File History
1 commit
sha256:ef10830ce231e0a20efcb0e2586cb879471247e916616e6fdd0d51df459e2595
fix: typing audit — 0 violations, 0 untyped defs across all…
Sonnet 4.6
minor
⚠
21 days ago