gabriel / muse public
fix patch refs dev
AI Agent gabriel · 142 days ago · Apr 27, 2026 · Diff

fix(refs): CAS guards on merge, cherry-pick, revert, pull, rebase

Phase 1 of data integrity audit (issue #7): all write_branch_ref callers that advance an existing branch now pass expected_id for CAS protection. RefConflictError surfaced as a retryable user error on mismatch.

Commands fixed: merge (3 sites), cherry-pick (1), revert (1), pull (3), rebase/squash/continue (4). Abort path left unconditional (intentional restore).

11-test regression suite in test_phase1_cas_branch_ref_callers.py using race injection pattern: patches write_branch_ref to advance the branch just before the real write, proving CAS detection without threading.

sha256:8f54a2ad8f91a756ccce8819b0531f2f5b4309ce619ffae7b50bc9c56bd301f3 sha
+43 ~67 symbols
sha256:d1eafd5bce0dfbbc3d65d514a5f81a50505fc8306e1d8c57c93eadfc850d7150 snapshot
+43
symbols added
~67
symbols modified
0
dead code introduced
Semantic Changes 110 symbols
+ TestCASPerformance class class TestCASPerformance L241–258
+ test_write_branch_ref_cas_uncontested_under_50ms method method test_write_branch_ref_cas_uncontested_under_50ms L242–258
+ TestCherryPickCASGuard class class TestCherryPickCASGuard L156–193
+ cherry_repo method method cherry_repo L159–169
+ test_cherry_pick_branch_ref_unchanged_after_failed_cas method method test_cherry_pick_branch_ref_unchanged_after_failed_cas L186–193
+ test_cherry_pick_fails_when_branch_advances_concurrently method method test_cherry_pick_fails_when_branch_advances_concurrently L171–177
+ test_cherry_pick_succeeds_when_branch_has_not_moved method method test_cherry_pick_succeeds_when_branch_has_not_moved L179–184
+ TestMergeCASGuard class class TestMergeCASGuard L102–148
+ test_merge_branch_ref_unchanged_after_failed_cas method method test_merge_branch_ref_unchanged_after_failed_cas L139–148
+ test_merge_error_is_actionable method method test_merge_error_is_actionable L124–131
+ test_merge_fails_when_branch_advances_concurrently method method test_merge_fails_when_branch_advances_concurrently L117–122
+ test_merge_succeeds_when_branch_has_not_moved method method test_merge_succeeds_when_branch_has_not_moved L133–137
+ two_branch_repo method method two_branch_repo L106–115
+ TestRevertCASGuard class class TestRevertCASGuard L201–233
+ revert_repo method method revert_repo L204–211
+ test_revert_branch_ref_unchanged_after_failed_cas method method test_revert_branch_ref_unchanged_after_failed_cas L226–233
+ test_revert_fails_when_branch_advances_concurrently method method test_revert_fails_when_branch_advances_concurrently L213–218
+ test_revert_succeeds_when_branch_has_not_moved method method test_revert_succeeds_when_branch_has_not_moved L220–224
+ _CONCURRENT_ID variable variable _CONCURRENT_ID L53–53
+ _branch function function _branch L70–72
+ _head function function _head L65–67
+ _make_race_injector function function _make_race_injector L79–94
+ _ref function function _ref L75–76
+ _run function function _run L56–58
+ _try function function _try L61–62
+ CliRunner import import CliRunner L49–49
+ RefConflictError import import RefConflictError L47–47
+ _store import import _store L46–46
+ annotations import import annotations L37–37
+ fake_id import import fake_id L48–48
+ json import import json L39–39
+ patch import import patch L42–42
+ pathlib import import pathlib L40–40
+ pytest import import pytest L44–44
+ time import import time L41–41
+ write_branch_ref import import write_branch_ref L47–47
+ runner variable variable runner L51–51
~ muse/cli/commands/revert.py .py 1 symbol added, 10 symbols modified
~ muse/core/rebase.py .py 1 symbol added, 9 symbols modified
← Older Oldest on dev
All commits
Newer → Latest on dev

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:8f54a2ad8f91a756ccce8819b0531f2f5b4309ce619ffae7b50bc9c56bd301f3 --body "your comment"