gabriel / musehub public
feat patch phase3 task/phase3-on-disk-refs #1 / 1
AI Agent gabriel · 144 days ago · May 1, 2026 · Diff

feat(phase3): on-disk refs as canonical branch pointers

- Add musehub/storage/refs.py: write_ref() atomic POSIX rename + read_ref() - Wire push stream writes refs/heads/<branch> after DB commit (disk is canonical) - Add POST /api/repos/{repo_id}/branches/{name}/repair — heals DB from disk ref - 21 TDD tests across 7 tiers: write/read round-trip, atomicity, wire push integration, repair endpoint

sha256:ad64f2d2810bc6c74dbd642516bb8f102890b036b848a0da2c8c88aa162260b8 sha
+79 ~1 symbols
sha256:dad2a0f3c4a446c82d8467da09da259fd5f399fa6a8228571df6579d28eff484 snapshot
+79
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 80 symbols
~ musehub/storage/refs.py .py 6 symbols added
+ annotations import import annotations L15–15
+ pathlib import import pathlib L17–17
+ server_heads_dir import import server_heads_dir L19–19
+ server_ref_path import import server_ref_path L19–19
+ read_ref function function read_ref L45–59
+ write_ref function function write_ref L22–42
~ tests/test_on_disk_refs.py .py 72 symbols added
+ TestReadRefMissing class class TestReadRefMissing L242–269
+ test_read_ref_returns_none_after_branch_deleted_from_disk method method test_read_ref_returns_none_after_branch_deleted_from_disk L257–269
+ test_read_ref_returns_none_empty_repo method method test_read_ref_returns_none_empty_repo L250–255
+ test_read_ref_returns_none_for_unknown_branch method method test_read_ref_returns_none_for_unknown_branch L243–248
+ TestReadRefRoundTrips class class TestReadRefRoundTrips L191–237
+ test_read_ref_multiple_branches_independent method method test_read_ref_multiple_branches_independent L226–237
+ test_read_ref_returns_commit_id method method test_read_ref_returns_commit_id L192–201
+ test_read_ref_round_trips_feature_branch method method test_read_ref_round_trips_feature_branch L215–224
+ test_read_ref_strips_trailing_newline method method test_read_ref_strips_trailing_newline L203–213
+ TestRepairEndpoint class class TestRepairEndpoint L489–621
+ test_repair_404_when_no_disk_ref method async_method test_repair_404_when_no_disk_ref L588–604
+ test_repair_heals_db_from_disk method async_method test_repair_heals_db_from_disk L493–542
+ test_repair_noop_when_already_consistent method async_method test_repair_noop_when_already_consistent L545–585
+ test_repair_requires_auth method async_method test_repair_requires_auth L607–621
+ TestWirePushWritesDiskRef class class TestWirePushWritesDiskRef L442–484
+ test_push_disk_ref_matches_db_head method async_method test_push_disk_ref_matches_db_head L465–484
+ test_push_writes_disk_ref method async_method test_push_writes_disk_ref L446–462
+ TestWriteRefAtomic class class TestWriteRefAtomic L300–333
+ test_no_tmp_file_after_write method method test_no_tmp_file_after_write L301–312
+ test_partial_write_does_not_corrupt_existing_ref method method test_partial_write_does_not_corrupt_existing_ref L314–333
+ TestWriteRefCreatesFile class class TestWriteRefCreatesFile L136–186
+ test_write_ref_content_is_commit_id_with_newline method method test_write_ref_content_is_commit_id_with_newline L149–159
+ test_write_ref_creates_ref_file method method test_write_ref_creates_ref_file L137–147
+ test_write_ref_overwrites_existing method method test_write_ref_overwrites_existing L161–173
+ test_write_ref_supports_feature_branches method method test_write_ref_supports_feature_branches L175–186
+ TestWriteRefCreatesParentDirs class class TestWriteRefCreatesParentDirs L274–295
+ test_write_ref_creates_nested_branch_dirs method method test_write_ref_creates_nested_branch_dirs L287–295
+ test_write_ref_creates_refs_heads_dir method method test_write_ref_creates_refs_heads_dir L275–285
+ _IDENTITY_ID variable variable _IDENTITY_ID L49–49
+ _OWNER variable variable _OWNER L47–47
+ _SLUG variable variable _SLUG L48–48
+ _TEST_CONTEXT variable variable _TEST_CONTEXT L51–56
+ _fw variable variable _fw L348–348
+ _make_commit_wire function function _make_commit_wire L374–391
+ _make_snap_wire function function _make_snap_wire L394–400
+ _mwp_commit_pack function function _mwp_commit_pack L364–367
+ _mwp_end function function _mwp_end L370–371
+ _mwp_header function function _mwp_header L356–361
+ _mwp_wrap function function _mwp_wrap L351–353
+ _oid function function _oid L32–34
+ _repo_root function function _repo_root L37–42
+ _run_push function async_function _run_push L403–439
+ async_client function async_function async_client L66–71
+ async_session function async_function async_session L60–62
+ authed_headers function function authed_headers L125–131
+ ASGITransport import import ASGITransport L21–21
+ AsyncClient import import AsyncClient L21–21
+ AsyncGenerator import import AsyncGenerator L15–15
+ AsyncSession import import AsyncSession L22–22
+ MSignContext import import MSignContext L24–24
+ MusehubIdentity import import MusehubIdentity L26–26
+ MusehubRepo import import MusehubRepo L26–26
+ Path import import Path L16–16
+ SFRAME_COMMIT_PACK import import SFRAME_COMMIT_PACK L341–341
+ SFRAME_END import import SFRAME_END L341–341
+ SFRAME_HEADER import import SFRAME_HEADER L341–341
+ SFRAME_RESULT import import SFRAME_RESULT L341–341
+ _MuseWireFrameWriter import import _MuseWireFrameWriter L340–340
+ _blob_id import import _blob_id L339–339
+ _msgpack import import _msgpack L338–338
+ annotations import import annotations L12–12
+ app import import app L27–27
+ compute_identity_id import import compute_identity_id L25–25
+ optional_signed_request import import optional_signed_request L24–24
+ patch import import patch L17–17
+ pytest import import pytest L19–19
+ pytest_asyncio import import pytest_asyncio L20–20
+ require_signed_request import import require_signed_request L24–24
+ uuid import import uuid L14–14
+ owner function async_function owner L75–85
+ repo_id function async_function repo_id L94–121
+ slug function async_function slug L89–90
+ repair_branch function async_function repair_branch L395–464
← Older Oldest on task/phase3-on-disk-refs
All commits
Newer → Latest on task/phase3-on-disk-refs

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:ad64f2d2810bc6c74dbd642516bb8f102890b036b848a0da2c8c88aa162260b8 --body "your comment"