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

supercharge(gravity): -j alias, exit_code, duration_ms, TypedDicts, docstring

- Add from muse.core.timing import start_timer - Add exit_code: int and duration_ms: float to _JsonOut TypedDict - Add _GravityExplainJson TypedDict with all explain-mode fields plus exit_code and duration_ms annotations - Add -j alias for --json; add dest='as_json' (idiomatic; was args.json) - Replace args.json with args.as_json in both JSON branches of run() - Add elapsed = start_timer() at top of run() - Emit exit_code=0 and duration_ms=elapsed() in both JSON paths: leaderboard (_JsonOut) and explain (_GravityExplainJson) - Expand run() docstring from one-liner to full JSON envelope section - Add 57-test supercharge suite (first gravity tests ever written)

sha256:47a0555e134d0d74b5b61e5f2e1229451d2643dda36ef47b79679e8c4aa1cfe8 sha
+78 ~3 symbols
sha256:fc68075bb6c184db649a1730d04e6425c82ed26c9bf988a07c878b44d030f353 snapshot
+78
symbols added
~3
symbols modified
0
dead code introduced
Semantic Changes 81 symbols
~ tests/test_gravity_supercharge.py .py 76 symbols added
+ TestAnsiSanitization class class TestAnsiSanitization L352–365
+ test_j_alias_output_no_ansi method method test_j_alias_output_no_ansi L359–361
+ test_json_output_no_ansi_explain method method test_json_output_no_ansi_explain L363–365
+ test_json_output_no_ansi_leaderboard method method test_json_output_no_ansi_leaderboard L355–357
+ TestDocstrings class class TestDocstrings L333–344
+ test_run_docstring_mentions_duration_ms method method test_run_docstring_mentions_duration_ms L341–344
+ test_run_docstring_mentions_exit_code method method test_run_docstring_mentions_exit_code L336–339
+ TestDurationMs class class TestDurationMs L192–228
+ test_duration_ms_explain_mode method method test_duration_ms_explain_mode L217–223
+ test_duration_ms_with_top_filter method method test_duration_ms_with_top_filter L211–215
+ test_j_alias_duration_ms_explain method method test_j_alias_duration_ms_explain L225–228
+ test_j_alias_duration_ms_present method method test_j_alias_duration_ms_present L207–209
+ test_json_duration_ms_is_float method method test_json_duration_ms_is_float L203–205
+ test_json_duration_ms_nonnegative method method test_json_duration_ms_nonnegative L199–201
+ test_json_has_duration_ms_leaderboard method method test_json_has_duration_ms_leaderboard L195–197
+ TestExitCode class class TestExitCode L236–278
+ test_exit_code_is_int_explain method method test_exit_code_is_int_explain L270–272
+ test_exit_code_mirrors_process_exit method method test_exit_code_mirrors_process_exit L256–258
+ test_exit_code_mirrors_process_exit_explain method method test_exit_code_mirrors_process_exit_explain L274–278
+ test_j_alias_exit_code_present method method test_j_alias_exit_code_present L252–254
+ test_json_exit_code_is_int_leaderboard method method test_json_exit_code_is_int_leaderboard L248–250
+ test_json_exit_code_zero_explain method method test_json_exit_code_zero_explain L265–268
+ test_json_exit_code_zero_leaderboard method method test_json_exit_code_zero_leaderboard L243–246
+ test_json_has_exit_code_explain method method test_json_has_exit_code_explain L260–263
+ test_json_has_exit_code_leaderboard method method test_json_has_exit_code_leaderboard L239–241
+ TestExplainSchema class class TestExplainSchema L423–449
+ test_explain_address_matches_flag method method test_explain_address_matches_flag L445–449
+ test_explain_has_address method method test_explain_has_address L426–429
+ test_explain_has_depth_distribution method method test_explain_has_depth_distribution L441–443
+ test_explain_has_direct_dependents method method test_explain_has_direct_dependents L437–439
+ test_explain_has_gravity_pct method method test_explain_has_gravity_pct L431–435
+ TestJsonAlias class class TestJsonAlias L132–184
+ test_j_alias_exits_zero method method test_j_alias_exits_zero L135–137
+ test_j_alias_has_filters_key method method test_j_alias_has_filters_key L151–153
+ test_j_alias_has_ref_key method method test_j_alias_has_ref_key L147–149
+ test_j_alias_has_symbols_key method method test_j_alias_has_symbols_key L143–145
+ test_j_alias_same_top_level_keys_as_json_flag method method test_j_alias_same_top_level_keys_as_json_flag L155–164
+ test_j_alias_symbol_count_matches_json_flag method method test_j_alias_symbol_count_matches_json_flag L166–173
+ test_j_alias_valid_json method method test_j_alias_valid_json L139–141
+ test_j_alias_with_min_gravity method method test_j_alias_with_min_gravity L180–184
+ test_j_alias_with_top_filter method method test_j_alias_with_top_filter L175–178
+ TestLeaderboardSchema class class TestLeaderboardSchema L373–415
+ test_has_include_tests_key method method test_has_include_tests_key L388–390
+ test_has_ref_key method method test_has_ref_key L376–378
+ test_has_snapshot_id_key method method test_has_snapshot_id_key L380–382
+ test_has_total_production_symbols_key method method test_has_total_production_symbols_key L384–386
+ test_include_tests_is_false_by_default method method test_include_tests_is_false_by_default L392–394
+ test_symbol_entries_have_address method method test_symbol_entries_have_address L406–410
+ test_symbol_entries_have_gravity_pct method method test_symbol_entries_have_gravity_pct L400–404
+ test_symbols_is_list method method test_symbols_is_list L396–398
+ test_top_filter_bounds_symbols method method test_top_filter_bounds_symbols L412–415
+ TestPerformance class class TestPerformance L457–470
+ test_duration_ms_is_float_not_int method method test_duration_ms_is_float_not_int L468–470
+ test_explain_duration_under_5000ms method method test_explain_duration_under_5000ms L464–466
+ test_leaderboard_duration_under_5000ms method method test_leaderboard_duration_under_5000ms L460–462
+ TestTypedDicts class class TestTypedDicts L286–325
+ test_gravity_explain_json_exists method method test_gravity_explain_json_exists L308–309
+ test_gravity_explain_json_has_address method method test_gravity_explain_json_has_address L319–321
+ test_gravity_explain_json_has_duration_ms method method test_gravity_explain_json_has_duration_ms L315–317
+ test_gravity_explain_json_has_exit_code method method test_gravity_explain_json_has_exit_code L311–313
+ test_gravity_explain_json_has_gravity_pct method method test_gravity_explain_json_has_gravity_pct L323–325
+ test_json_out_has_duration_ms_annotation method method test_json_out_has_duration_ms_annotation L296–298
+ test_json_out_has_exit_code_annotation method method test_json_out_has_exit_code_annotation L292–294
+ test_json_out_retains_filters_annotation method method test_json_out_retains_filters_annotation L304–306
+ test_json_out_retains_symbols_annotation method method test_json_out_retains_symbols_annotation L300–302
+ test_json_out_typeddict_exists method method test_json_out_typeddict_exists L289–290
+ _env function function _env L45–46
+ _run function function _run L49–50
+ gravity_repo function function gravity_repo L59–124
+ CliRunner import import CliRunner L35–35
+ annotations import import annotations L27–27
+ json import import json L29–29
+ pathlib import import pathlib L30–30
+ pytest import import pytest L33–33
+ textwrap import import textwrap L31–31
+ runner variable variable runner L37–37
~ muse/cli/commands/gravity.py .py 2 symbols added, 3 symbols modified
+ _GravityExplainJson class class _GravityExplainJson L229–258
+ start_timer import import start_timer L129–129
~ run
← 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:47a0555e134d0d74b5b61e5f2e1229451d2643dda36ef47b79679e8c4aa1cfe8 --body "your comment"