gabriel / muse public
refactor BREAKING store task/store-phase2-refs #1 / 1
AI Agent gabriel · 117 days ago · May 21, 2026 · Diff

refactor(store): Phase 2 — extract ref and HEAD management into muse/core/refs.py

Expand muse/core/refs.py from 2 primitives to the full ref/HEAD module:

Moved from store.py → refs.py: - RefConflictError (exception) - write_branch_ref (atomic CAS ref write, advisory flock) - SymbolicHead, DetachedHead, HeadState (typed HEAD representations) - read_head, read_current_branch, write_head_branch, write_head_commit - get_head_commit_id, resolve_any_ref, get_all_branch_heads

store.py imports all moved symbols from refs.py and contains no HEAD/ref implementation. Direct callers updated: muse/core/migrate.py, muse/cli/commands/init.py, update_ref.py, worktree.py, bridge.py (inline), and 7 test files that own ref-specific test coverage.

sha256:37ed8fecaafe7d683537a0182d49132c06dcef1f9016d218281831d30d58ed01 sha
+36 ~39 −15 symbols
sha256:021473ac96b368d5cc5925ec9cd452ed52711c0a625d66b1372b38d407348b52 snapshot
+36
symbols added
~39
symbols modified
−15
symbols removed
0
dead code introduced
Semantic Changes 90 symbols
~ muse/cli/commands/bridge.py .py 1 symbol modified
~ muse/cli/commands/init.py .py 1 symbol modified
~ muse/core/refs.py .py 24 symbols added, 1 symbol modified
+ DetachedHead class class DetachedHead L265–269 ← moved from muse/core/store.py
+ HeadState variable variable HeadState L271–271 ← moved from muse/core/store.py
+ RefConflictError class class RefConflictError L63–66 ← moved from muse/core/store.py
+ SymbolicHead class class SymbolicHead L259–263 ← moved from muse/core/store.py
+ _SENTINEL variable variable _SENTINEL L57–57 ← moved from muse/core/store.py
+ get_all_branch_heads function function get_all_branch_heads L385–397 ← moved from muse/core/store.py
+ get_head_commit_id function function get_head_commit_id L348–351
+ BranchHeads import import BranchHeads L54–54
+ Literal import import Literal L50–50
+ TypedDict import import TypedDict L50–50
+ _head_path import import _head_path L53–53
+ _ref_path import import _ref_path L53–53
+ _remotes_dir import import _remotes_dir L53–53
+ annotations import import annotations L44–44
+ fcntl import import fcntl L46–46
+ re import import re L48–48
+ validate_branch_name import import validate_branch_name L55–55
+ write_text_atomic import import write_text_atomic L52–52
+ read_current_branch function function read_current_branch L303–316 ← moved from muse/core/store.py
+ read_head function function read_head L273–301 ← moved from muse/core/store.py
+ resolve_any_ref function function resolve_any_ref L353–383
+ write_branch_ref function function write_branch_ref L171–235
+ write_head_branch function function write_head_branch L318–328 ← moved from muse/core/store.py
+ write_head_commit function function write_head_commit L330–342 ← moved from muse/core/store.py
~ muse/core/store.py .py 12 symbols added, 15 symbols removed, 10 symbols modified
DetachedHead class class DetachedHead L463–467 → moved to muse/core/refs.py
HeadState variable variable HeadState L469–469 → moved to muse/core/refs.py
RefConflictError class class RefConflictError L323–326 → moved to muse/core/refs.py
SymbolicHead class class SymbolicHead L457–461 → moved to muse/core/refs.py
_SENTINEL variable variable _SENTINEL L130–130 → moved to muse/core/refs.py
get_all_branch_heads function function get_all_branch_heads L1428–1440 → moved to muse/core/refs.py
get_head_commit_id function function get_head_commit_id L1387–1391
_head_path import import _head_path L159–159
_heads_dir import import _heads_dir L159–159
read_current_branch function function read_current_branch L501–514 → moved to muse/core/refs.py
read_head function function read_head L471–499 → moved to muse/core/refs.py
resolve_any_ref function function resolve_any_ref L1393–1426
write_branch_ref function function write_branch_ref L338–407
write_head_branch function function write_head_branch L516–526 → moved to muse/core/refs.py
write_head_commit function function write_head_commit L528–540 → moved to muse/core/refs.py
+ DetachedHead import import DetachedHead L167–167
+ HeadState import import HeadState L167–167
+ RefConflictError import import RefConflictError L167–167
+ SymbolicHead import import SymbolicHead L167–167
+ get_all_branch_heads import import get_all_branch_heads L167–167
+ get_head_commit_id import import get_head_commit_id L167–167
+ read_current_branch import import read_current_branch L167–167
+ read_head import import read_head L167–167
+ resolve_any_ref import import resolve_any_ref L167–167
+ write_branch_ref import import write_branch_ref L167–167
+ write_head_branch import import write_head_branch L167–167
+ write_head_commit import import write_head_commit L167–167
← Older Oldest on task/store-phase2-refs
All commits
Newer → Latest on task/store-phase2-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:37ed8fecaafe7d683537a0182d49132c06dcef1f9016d218281831d30d58ed01 --body "your comment"