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

fix(checkout): Phase 6 — CHECKOUT_HEAD survives through write_head_branch

A process killed between _checkout_snapshot (which cleared CHECKOUT_HEAD on success) and write_head_branch left the working tree at the target branch but HEAD at the old branch, with no CHECKOUT_HEAD marker for muse status to detect the interrupted state.

Fix: add clear_marker=False parameter to _checkout_snapshot. Callers that follow with write_head_branch / write_head_commit now keep the marker alive through that write, then unlink it immediately after.

CHECKOUT_HEAD lifecycle after fix: 1. write CHECKOUT_HEAD (before first file mutation) 2. mutate working tree 3. write HEAD (write_head_branch / write_head_commit) 4. unlink CHECKOUT_HEAD

Kills at any point between 1 and 4 leave the marker — status always detects.

6-test suite in test_phase6_checkout_interruption.py: marker absent after clean checkout, marker present during write_head_branch, status detects planted marker, status shows target, clean after removal, re-checkout (with --force) clears the marker.

sha256:1568be18f671411b1d0a12b92634d9901467ad4cafac27bb5fcfa4b6e73ebbb9 sha
+20 ~3 symbols
sha256:d1aea942b69794a76feabe47161e315830b5dae490d072266e32483040e4aaa5 snapshot
+20
symbols added
~3
symbols modified
0
dead code introduced
Semantic Changes 23 symbols
+ TestCheckoutHeadLifecycle class class TestCheckoutHeadLifecycle L78–118
+ test_checkout_head_absent_after_successful_checkout method method test_checkout_head_absent_after_successful_checkout L79–89
+ test_checkout_head_present_during_head_write method method test_checkout_head_present_during_head_write L91–118
+ TestCrashRecovery class class TestCrashRecovery L168–186
+ test_re_checkout_after_interrupted_state_succeeds method method test_re_checkout_after_interrupted_state_succeeds L169–186
+ TestStatusDetectsInterrupt class class TestStatusDetectsInterrupt L125–161
+ test_status_clean_after_marker_removed method method test_status_clean_after_marker_ L153–161
+ test_status_shows_checkout_interrupted_when_marker_exists method method test_status_shows_checkout_interrupted_when_marker_exists L126–139
+ test_status_shows_checkout_target method method test_status_shows_checkout_target L141–151
+ _checkout_head_path function function _checkout_head_path L50–51
+ _run function function _run L43–47
+ _setup_two_branches function function _setup_two_branches L59–71
+ _status function function _status L54–56
+ CliRunner import import CliRunner L38–38
+ annotations import import annotations L30–30
+ json import import json L32–32
+ patch import import patch L34–34
+ pathlib import import pathlib L33–33
+ pytest import import pytest L36–36
+ runner variable variable runner L40–40
← 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:1568be18f671411b1d0a12b92634d9901467ad4cafac27bb5fcfa4b6e73ebbb9 --body "your comment"