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]>
Semantic Changes
12 symbols
Files Changed
~4
1259 in snapshot
0 comments
muse hub commit comment sha256:bfc21f3dbc254adc9136d5a21679d26d118f37bff6996147372461e2e2d51184 --body "your comment"
No comments yet. Be the first to start the discussion.