gabriel / muse public
fix patch task/fix-init-sentinel #1 / 1
AI Agent gabriel · 153 days ago · Apr 22, 2026 · Diff

fix: guard against init-sentinel refs from empty remote repos

A freshly created remote repo returns branch head values like 'init-sha256:<12-hex>' to signal the branch has no commits yet. The push command was passing these directly to commit_exists() → split_id(), which raised ValueError (hex portion not 64 chars).

Fix: add _is_valid_commit_id() which wraps split_id() in a try/except and returns False for any malformed ID. Guard both call sites in run() that pass remote ref values to commit_exists() — the candidate_have filter and the branch_have construction.

Tests: TestT13InitSentinel (4 tests) covering crash guard, sentinel filtering from have list, valid refs alongside sentinel, and empty branch_heads.

sha256:9e28bb3830e4cae4a4e709426bf311c0f9f0423d826798e3f2618cb2d15e3101 sha
+8 ~2 symbols
sha256:3ea38320d8f536678f99c42480e3f43f2c77773e2006e00cf31e8a96b3bf8d2d snapshot
+8
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 10 symbols
~ muse/cli/commands/push.py .py 2 symbols added, 2 symbols modified
+ _is_valid_commit_id function function _is_valid_commit_id L353–364
+ split_id import import split_id L86–86
~ run
~ tests/test_cli_stream_push.py .py 6 symbols added
+ TestT13InitSentinel class class TestT13InitSentinel L766–836
+ _setup method method _setup L779–785
+ test_empty_branch_heads_still_works method method test_empty_branch_heads_still_works L829–836
+ test_init_sentinel_not_included_in_have_list method method test_init_sentinel_not_included_in_have_list L798–810
+ test_other_valid_refs_still_included_in_have method method test_other_valid_refs_still_included_in_have L812–827
+ test_push_to_empty_remote_does_not_crash method method test_push_to_empty_remote_does_not_crash L787–796
← Older Oldest on task/fix-init-sentinel
All commits
Newer → Latest on task/fix-init-sentinel

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:9e28bb3830e4cae4a4e709426bf311c0f9f0423d826798e3f2618cb2d15e3101 --body "your comment"