gabriel / muse public
fix patch dev
AI Agent gabriel · 161 days ago · Apr 19, 2026 · Diff

fix: muse code invariants — two bugs found via dog fooding

Bug 1: --commit HEAD~1 crashed with ValueError get_head_commit_id() called validate_branch_name() which rejects '~'. Fix: skip branch-name lookup when ref contains ref-syntax chars (~^@: etc). resolve_commit_ref() handles relative refs directly.

Bug 2: --rule filter no-match path emitted JSON without exit_code/duration_ms Both the no-match-filter and no-rules early-exit paths were missing the envelope fields that every other JSON path carries. Fix: add exit_code=0 and duration_ms=elapsed() to both paths.

Also: - Expand test_invariants_supercharge.py with 8 new tests covering both bugs (TestEarlyExitPaths, TestRelativeRefSyntax)

sha256:b013fd1234af86b3dfb8d852e9e98b10d11483c14f1ad09dc712765caa32078f sha
+11 ~1 symbols
sha256:717320a68ef2d9db9c4cdfe3781944933008c6df8808e3b75a95289915d77241 snapshot
+11
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 12 symbols
~ muse/cli/commands/invariants.py .py 1 symbol modified
~ run
~ tests/test_invariants_supercharge.py .py 11 symbols added
+ TestEarlyExitPaths class class TestEarlyExitPaths L275–299
+ test_no_match_rule_filter_has_duration_ms method method test_no_match_rule_filter_has_duration_ms L285–290
+ test_no_match_rule_filter_has_error_field method method test_no_match_rule_filter_has_error_field L292–295
+ test_no_match_rule_filter_has_exit_code method method test_no_match_rule_filter_has_exit_code L278–283
+ test_no_match_rule_filter_no_ansi method method test_no_match_rule_filter_no_ansi L297–299
+ TestRelativeRefSyntax class class TestRelativeRefSyntax L307–351
+ test_head_tilde_1_does_not_crash method method test_head_tilde_1_does_not_crash L333–336
+ test_head_tilde_1_emits_valid_json method method test_head_tilde_1_emits_valid_json L338–341
+ test_head_tilde_1_has_duration_ms method method test_head_tilde_1_has_duration_ms L347–351
+ test_head_tilde_1_has_exit_code method method test_head_tilde_1_has_exit_code L343–345
+ two_commit_repo method method two_commit_repo L311–331
← 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:b013fd1234af86b3dfb8d852e9e98b10d11483c14f1ad09dc712765caa32078f --body "your comment"