gabriel / musehub public
test_release_analysis_no_commit_meta.py python
79 lines 2.6 KB
Raw
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 121 days ago
1 """TDD — release_analysis must not access commit_meta (dropped in migration 0020)."""
2 from __future__ import annotations
3
4 import pytest
5 import msgpack
6 from datetime import datetime, timezone
7 from sqlalchemy.ext.asyncio import AsyncSession
8
9 from musehub.db import musehub_models as db
10 from musehub.types.json_types import JSONObject
11 from tests.factories import create_repo
12 from muse.core.types import blob_id
13
14
15 def _utc() -> datetime:
16 return datetime.now(tz=timezone.utc)
17
18
19 async def _add_snapshot(session: AsyncSession, repo_id: str, seed: str, manifest: JSONObject) -> str:
20 snap_id = blob_id(f"snap-{seed}".encode())
21 session.add(db.MusehubSnapshot(
22 snapshot_id=snap_id,
23 repo_id=repo_id,
24 directories=[],
25 manifest_blob=msgpack.packb(manifest, use_bin_type=True),
26 entry_count=len(manifest),
27 created_at=_utc(),
28 ))
29 await session.commit()
30 return snap_id
31
32
33 async def _add_commit(session: AsyncSession, repo_id: str, seed: str, snap_id: str | None = None, **kwargs) -> db.MusehubCommit:
34 row = db.MusehubCommit(
35 commit_id=blob_id(seed.encode()),
36 repo_id=repo_id,
37 branch="dev",
38 parent_ids=[],
39 message=f"feat: {seed}",
40 author="gabriel",
41 timestamp=_utc(),
42 snapshot_id=snap_id,
43 **kwargs,
44 )
45 session.add(row)
46 session.add(db.MusehubBranch(
47 branch_id=blob_id(f"br-{seed}".encode()),
48 repo_id=repo_id,
49 name="dev",
50 head_commit_id=row.commit_id,
51 ))
52 await session.commit()
53 return row
54
55
56 # ---------------------------------------------------------------------------
57 # RL1 — _load_commit_chain does not crash with AttributeError on commit_meta
58 # ---------------------------------------------------------------------------
59
60 @pytest.mark.asyncio
61 async def test_rl1_load_commit_chain_no_commit_meta(
62 db_session: AsyncSession,
63 ) -> None:
64 """_load_commit_chain must not raise AttributeError on commit_meta."""
65 from musehub.services.release_analysis import _walk_commits
66
67 repo = await create_repo(db_session, owner="gabriel", visibility="public")
68 snap_id = await _add_snapshot(db_session, repo.repo_id, "rl1", {"src/app.py": blob_id(b"content")})
69 commit = await _add_commit(
70 db_session, repo.repo_id, "rl1-c1", snap_id,
71 agent_id="claude-code", model_id="claude-sonnet-4-6",
72 sem_ver_bump="minor",
73 )
74
75 result = await _walk_commits(db_session, repo.repo_id, commit.commit_id, max_commits=10)
76 assert isinstance(result, list)
77 assert len(result) == 1
78 assert result[0]["agent_id"] == "claude-code"
79 assert result[0]["model_id"] == "claude-sonnet-4-6"
File History 1 commit
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef debug(push/stream): instrument O-frame decode path with INF… Sonnet 4.6 patch 121 days ago