gabriel / muse public
feat patch log task/log-supercharge #1 / 1
AI Agent gabriel · 163 days ago · Apr 17, 2026 · Diff

feat(log): supercharge JSON output with typed envelope, error schema, sha256: ref, timing

Envelope additions (always present, no dict.get guards needed): - status: 'ok' | 'error' - error: '' on success, message on error - branch: branch that was walked - repo_id: stable identifier for cross-referencing - total: len(commits) — replaces manual len(data['commits']) - duration_ms: float wall-clock timing - exit_code: 0 on success, non-zero on error

Error payloads: - Add _LogErrorJson TypedDict {status, error, exit_code} - _emit_error() helper centralises error emission; suppresses prose in --json mode - All error paths (invalid --since, --until, bad limit) emit clean JSON, no ❌ emoji leaking

sha256: ref resolution: - _is_known_ref() now accepts sha256: prefixed commit IDs and abbreviated prefixes - run() detects commit ID refs and walks from that commit via resolve_commit_ref instead of passing the sha256: ID as a branch name (which would fail validation)

Truncation warning: - Text mode only emits the '⚠️ History truncated' warning when the DEFAULT limit was silently hit; explicit -n means the user knows they asked for N commits

TypedDicts: - Add _LogJson (9 fields) and _LogErrorJson (3 fields)

Test updates: - Fix 3 pre-existing failures: agent_id/model_id in expected keys, duration_ms excluded from format-alias equality, repo_id assertion flipped - Add 50 new tests in test_log_supercharge.py

sha256:199343e431bf2bfa34197873ae32a481233febedafa94510dae7335cc13f5914 sha
+79 ~14 −1 symbols
sha256:24c84628026b57df41741d03304459736fd2b5ef7f2bc4184931dcdc99de44b3 snapshot
+79
symbols added
~14
symbols modified
−1
symbol removed
0
dead code introduced
Semantic Changes 94 symbols
~ tests/test_log_supercharge.py .py 73 symbols added
+ TestDataIntegrity class class TestDataIntegrity L266–321
+ test_agent_id_is_string method method test_agent_id_is_string L313–316
+ test_all_commit_ids_sha256_prefixed method method test_all_commit_ids_sha256_prefixed L267–272
+ test_committed_at_is_iso8601 method method test_committed_at_is_iso8601 L290–296
+ test_files_added_is_list method method test_files_added_is_list L298–301
+ test_files_modified_is_list method method test_files_modified_is_list L303–306
+ test_files_removed_is_list method method test_files_removed_is_list L308–311
+ test_model_id_is_string method method test_model_id_is_string L318–321
+ test_parent_commit_id_sha256_or_null method method test_parent_commit_id_sha256_or_null L274–280
+ test_snapshot_id_sha256_or_null method method test_snapshot_id_sha256_or_null L282–288
+ TestDocstring class class TestDocstring L428–451
+ test_module_docstring_documents_branch method method test_module_docstring_documents_branch L433–435
+ test_module_docstring_documents_duration_ms method method test_module_docstring_documents_duration_ms L445–447
+ test_module_docstring_documents_exit_code method method test_module_docstring_documents_exit_code L449–451
+ test_module_docstring_documents_repo_id method method test_module_docstring_documents_repo_id L437–439
+ test_module_docstring_documents_status method method test_module_docstring_documents_status L429–431
+ test_module_docstring_documents_total method method test_module_docstring_documents_total L441–443
+ TestErrorPayloadShape class class TestErrorPayloadShape L178–221
+ test_error_payload_has_exactly_three_keys method method test_error_payload_has_exactly_three_keys L198–202
+ test_invalid_format_returns_error_payload method method test_invalid_format_returns_error_payload L194–196
+ test_invalid_since_returns_error_payload method method test_invalid_since_returns_error_payload L179–185
+ test_invalid_until_returns_error_payload method method test_invalid_until_returns_error_payload L187–192
+ test_no_prose_on_stderr_for_invalid_since_in_json_mode method method test_no_prose_on_stderr_for_invalid_since_in_json_mode L204–213
+ test_no_prose_on_stderr_for_invalid_until_in_json_mode method method test_no_prose_on_stderr_for_invalid_until_in_json_mode L215–221
+ TestJsonEnvelopeSchema class class TestJsonEnvelopeSchema L93–170
+ test_all_required_envelope_keys_present method method test_all_required_envelope_keys_present L94–98
+ test_branch_field_matches_current_branch method method test_branch_field_matches_current_branch L118–120
+ test_branch_field_respects_explicit_ref method method test_branch_field_respects_explicit_ref L122–135
+ test_commits_is_a_list method method test_commits_is_a_list L156–158
+ test_duration_ms_is_nonnegative_float method method test_duration_ms_is_nonnegative_float L151–154
+ test_empty_repo_returns_empty_commits method method test_empty_repo_returns_empty_commits L164–170
+ test_error_is_empty_string_on_success method method test_error_is_empty_string_on_success L110–112
+ test_exit_code_is_zero_on_success method method test_exit_code_is_zero_on_success L114–116
+ test_no_extra_undocumented_keys method method test_no_extra_undocumented_keys L100–104
+ test_repo_id_is_nonempty_string method method test_repo_id_is_nonempty_string L137–140
+ test_status_is_ok_on_success method method test_status_is_ok_on_success L106–108
+ test_total_matches_len_commits method method test_total_matches_len_commits L142–144
+ test_total_reflects_limit method method test_total_reflects_limit L146–149
+ test_truncated_is_bool method method test_truncated_is_bool L160–162
+ TestNoProsePollution class class TestNoProsePollution L459–490
+ test_ansi_in_commit_message_is_json_escaped method method test_ansi_in_commit_message_is_json_escaped L478–490
+ test_no_emoji_in_json_error_output method method test_no_emoji_in_json_error_output L471–476
+ test_no_emoji_in_json_success_output method method test_no_emoji_in_json_success_output L466–469
+ test_success_stdout_is_valid_json method method test_success_stdout_is_valid_json L460–464
+ TestSha256RefResolution class class TestSha256RefResolution L229–258
+ test_sha256_full_commit_id_as_ref method method test_sha256_full_commit_id_as_ref L230–240
+ test_sha256_prefix_as_ref method method test_sha256_prefix_as_ref L242–250
+ test_sha256_ref_not_treated_as_pathspec method method test_sha256_ref_not_treated_as_pathspec L252–258
+ TestTruncationBehaviour class class TestTruncationBehaviour L329–390
+ test_default_limit_truncation_warning_fires_in_text method method test_default_limit_truncation_warning_fires_in_text L370–390
+ test_explicit_n_does_not_emit_warning_in_text method method test_explicit_n_does_not_emit_warning_in_text L330–347
+ test_truncated_false_when_all_commits_returned method method test_truncated_false_when_all_commits_returned L364–368
+ test_truncated_true_in_json_when_limit_hit method method test_truncated_true_in_json_when_limit_hit L349–362
+ TestTypedDicts class class TestTypedDicts L398–420
+ test_log_error_json_has_required_annotations method method test_log_error_json_has_required_annotations L415–420
+ test_log_error_json_typed_dict_exists method method test_log_error_json_typed_dict_exists L403–405
+ test_log_json_has_required_annotations method method test_log_json_has_required_annotations L407–413
+ test_log_json_typed_dict_exists method method test_log_json_typed_dict_exists L399–401
+ _REQUIRED_ENVELOPE_KEYS variable variable _REQUIRED_ENVELOPE_KEYS L31–34
+ _env function function _env L37–38
+ _invoke function function _invoke L41–47
+ _log function function _log L50–51
+ _log_json function function _log_json L54–57
+ CliRunner import import CliRunner L23–23
+ annotations import import annotations L14–14
+ json import import json L16–16
+ os import import os L17–17
+ pathlib import import pathlib L18–18
+ pytest import import pytest L21–21
+ sys import import sys L19–19
+ repo function function repo L61–74
+ runner variable variable runner L25–25
+ single_commit_repo function function single_commit_repo L78–85
~ muse/cli/commands/log.py .py 5 symbols added, 9 symbols modified
+ _LogErrorJson class class _LogErrorJson L244–248
+ _LogJson class class _LogJson L227–241
+ _emit_error function function _emit_error L724–739
+ resolve_commit_ref import import resolve_commit_ref L117–117
+ time import import time L109–109
~ run
~ tests/test_cmd_log.py .py 1 symbol added, 1 symbol removed, 5 symbols modified
− test_no_repo_id_in_json_output method method test_no_repo_id_in_json_output L752–756
+ test_repo_id_in_json_envelope method method test_repo_id_in_json_envelope L760–766
← Older Oldest on task/log-supercharge
All commits
Newer → Latest on task/log-supercharge

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