gabriel / muse public
feat patch show-ref task/supercharge-show-ref #1 / 1
AI Agent gabriel · 161 days ago · Apr 18, 2026 · Diff

feat(show-ref): add elapsed_ms/exit_code envelope, fix _FAKE_OID sha256: prefix bug

- Add import time + start_time/_elapsed()/_emit_error() closures in run() - Inject elapsed_ms + exit_code into all JSON output paths: listing, --head, --count, --verify (both exists=true and exists=false) - Fix format error: was emitting JSON to stderr (wrong channel, wrong format); now emits plain text to stderr via _emit_error() — consistent with show.py / rev-parse / shortlog pattern - Fix I/O error path: was emitting JSON to stderr; now uses _emit_error() which routes to stdout (--json) or stderr (text) - Update _ShowRefResult TypedDict: add elapsed_ms: float + exit_code: int - Update module docstring: add envelope fields to JSON schema, add error envelope example, extend output contract with elapsed_ms note

test_cmd_show_ref.py — fix 18 pre-existing failures: - _FAKE_OID was bare hex ('a'*64); validate_object_id requires sha256: prefix so every ref written with _FAKE_OID was silently skipped — all ref-listing assertions were testing an empty list - Import long_id from muse.core._types; replace all bare-hex OID constructions with long_id('a'*64), long_id('b'*64), etc. - stress test: long_id((hex_chars[i % 16]) * 64) - test_json_count_zero: drop exact-equality assert (breaks with envelope); use data['count'] == 0 instead - TestShowRefResultSchema: add elapsed_ms + exit_code assertions

test_cmd_show_ref_hardening.py — 21 new tests: - TestElapsedAndExitCode: envelope present on listing, --count, --head, --verify (exists and not-exists paths) - TestErrorJson: format error is plain text on stderr, stdout empty, stderr is not JSON - TestRequiredKeysUpdated: listing schema includes all required keys - TestValidOidFormat: sha256:-prefixed OID listed; bare hex silently skipped

sha256:d745e94c62f7bfb8cc75d139633ddc7b9431d573f07421e4caef1459a6a4e6f6 sha
+40 ~21 symbols
sha256:c100dd20a6777a76522ed2ef7b8312f038f170800b216c32f2339249a9964446 snapshot
+40
symbols added
~21
symbols modified
0
dead code introduced
Semantic Changes 61 symbols
~ tests/test_cmd_show_ref_hardening.py .py 38 symbols added
+ TestElapsedAndExitCode class class TestElapsedAndExitCode L70–153
+ test_count_json_has_count_field method method test_count_json_has_count_field L103–108
+ test_count_json_has_elapsed_ms method method test_count_json_has_elapsed_ms L93–96
+ test_count_json_has_exit_code_zero method method test_count_json_has_exit_code_zero L98–101
+ test_head_json_has_elapsed_ms method method test_head_json_has_elapsed_ms L110–114
+ test_head_json_has_exit_code_zero method method test_head_json_has_exit_code_zero L116–120
+ test_head_null_json_has_envelope method method test_head_null_json_has_envelope L122–127
+ test_listing_elapsed_ms_is_float method method test_listing_elapsed_ms_is_float L76–80
+ test_listing_has_elapsed_ms method method test_listing_has_elapsed_ms L71–74
+ test_listing_has_exit_code_zero method method test_listing_has_exit_code_zero L82–85
+ test_listing_with_refs_has_envelope method method test_listing_with_refs_has_envelope L87–91
+ test_verify_exists_json_has_elapsed_ms method method test_verify_exists_json_has_elapsed_ms L129–133
+ test_verify_exists_json_has_exit_code_zero method method test_verify_exists_json_has_exit_code_zero L135–139
+ test_verify_not_exists_json_has_elapsed_ms method method test_verify_not_exists_json_has_elapsed_ms L141–144
+ test_verify_not_exists_json_has_exit_code_nonzero method method test_verify_not_exists_json_has_exit_code_nonzero L146–153
+ TestErrorJson class class TestErrorJson L161–186
+ test_bad_format_stderr_has_message method method test_bad_format_stderr_has_message L169–174
+ test_bad_format_stderr_is_not_json method method test_bad_format_stderr_is_not_json L176–186
+ test_bad_format_stdout_is_empty method method test_bad_format_stdout_is_empty L162–167
+ TestRequiredKeysUpdated class class TestRequiredKeysUpdated L194–201
+ test_listing_schema_complete method method test_listing_schema_complete L197–201
+ TestValidOidFormat class class TestValidOidFormat L209–236
+ test_bare_hex_oid_is_silently_skipped method method test_bare_hex_oid_is_silently_skipped L220–227
+ test_sha256_prefixed_oid_appears_in_listing method method test_sha256_prefixed_oid_appears_in_listing L210–218
+ test_valid_and_invalid_oid_mixed method method test_valid_and_invalid_oid_mixed L229–236
+ _VALID_OID variable variable _VALID_OID L27–27
+ _assert_has_envelope function function _assert_has_envelope L57–62
+ _make_repo function function _make_repo L35–44
+ _sr function function _sr L51–54
+ _write_ref function function _write_ref L47–48
+ CliRunner import import CliRunner L23–23
+ InvokeResult import import InvokeResult L23–23
+ annotations import import annotations L15–15
+ json import import json L17–17
+ long_id import import long_id L22–22
+ pathlib import import pathlib L18–18
+ pytest import import pytest L20–20
+ runner variable variable runner L25–25
~ muse/cli/commands/show_ref.py .py 1 symbol added, 2 symbols modified
+ time import import time L80–80
~ run
← Older Oldest on task/supercharge-show-ref
All commits
Newer → Latest on task/supercharge-show-ref

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