gabriel / muse public
fix BREAKING fix/222-guard-hint-nonexistent-flags #1 / 1
AI Agent gabriel · 1 day ago · Oct 22, 2026 · Diff

fix: require_clean_workdir hint suggests nonexistent flags (musehub#222)

Audit: found during an incident investigation where an agent passed muse reset --hard --force and discarded uncommitted changes (later fully recovered -- a separate commit had already captured the same content). The --force override itself was correct, intentional guard-bypass behavior; this is a different, smaller bug found during that investigation.

require_clean_workdir()'s remediation hint unconditionally suggested --merge and --autoshelf regardless of which command was calling it. Neither flag exists on `muse reset` (confirmed: only ref, --hard, --soft, --force, --dry-run/-n, --json/-j are registered) -- reproduced running the tool's own suggested remediation, `muse reset --autoshelf`, which fails immediately with an argparse "unrecognized arguments" error. Same gap affects revert and cherry-pick, which also have neither flag.

Fix: added supports_merge/supports_autoshelf keyword parameters to require_clean_workdir, defaulting to False. Both text and JSON hints now build their remediation list conditionally. Updated call sites to the real flag matrix: checkout (supports both), merge (supports --autoshelf only -- you can't "merge --merge"), reset/revert/cherry-pick (support neither, so their defaults needed no call-site change).

TDD: wrote 6 new tests in test_guard_supercharge.py first -- hint omits --merge/--autoshelf by default (text + JSON), hint includes both when supported, hint includes only --autoshelf when only that's supported, and an end-to-end test reproducing the exact reported incident (`muse reset --hard` on a dirty tree must not suggest --merge/--autoshelf). Confirmed genuine RED via muse-dev shelf save/pop isolation across all 3 touched source files.

Regression: 506 passed across guard/checkout/merge/reset/revert/ cherry-pick test files -- no regressions in any command this change touches.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

sha256:bfc21f3dbc254adc9136d5a21679d26d118f37bff6996147372461e2e2d51184 sha
+6 ~6 symbols
4 changed · 1259 in snapshot files
sha256:1a9c12bcfbc596398bd3942e07418bf65daf29f1d83833e733a45c4ccb854ad1 snapshot
+6
symbols added
~6
symbols modified
4
files changed
1259
files in snapshot
0
dead code introduced
Semantic Changes 12 symbols
~ muse/cli/commands/checkout.py .py 1 symbol modified
~ run
~ muse/cli/guard.py .py 1 symbol modified
~ tests/test_guard_supercharge.py .py 6 symbols added, 2 symbols modified
+ test_reset_hard_blocked_message_does_not_suggest_nonexistent_flags method method test_reset_hard_blocked_message_does_not_suggest_nonexistent_flags L341–350
+ test_hint_autoshelf_only_when_only_autoshelf_supported method method test_hint_autoshelf_only_when_only_autoshelf_supported L289–299
+ test_hint_includes_merge_and_autoshelf_when_supported method method test_hint_includes_merge_and_autoshelf_when_supported L274–287
+ test_hint_omits_merge_and_autoshelf_by_default method method test_hint_omits_merge_and_autoshelf_by_default L258–272
+ test_json_hint_includes_merge_and_autoshelf_when_supported method method test_json_hint_includes_merge_and_autoshelf_when_supported L313–325
+ test_json_hint_omits_merge_and_autoshelf_by_default method method test_json_hint_omits_merge_and_autoshelf_by_default L301–311
Files Changed
~4
1259 in snapshot
← Older Oldest on fix/222-guard-hint-nonexistent-flags
All commits
Newer → Latest on fix/222-guard-hint-nonexistent-flags

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