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

feat: supercharge muse code predict for agents

- Add -j alias for --json - Add exit_code + duration_ms to _PredictJson envelope - Add _ExplainJson TypedDict: structured signal breakdown for --explain --json Agents can now parse per-signal scores, reasons, and co-change partners for a single symbol without screen-scraping human output - Fill docstrings: _sanitise, _pct_bar, _confidence_label, _iter_symbol_ops, _build_predictions (already had one), _PredictJson, _ExplainJson, run() - Wire start_timer() throughout

TDD: 86 new tests in tests/test_predict_supercharge.py (zero prior coverage) Unit: _sanitise, _module_key, _pct_bar, _confidence_label, _iter_symbol_ops, _build_predictions (12 cases) Integration: json schema, -j alias, exit_code/duration_ms, filters, --explain human + json, empty repo Security: --min-confidence bounds, --explain format validation

sha256:58f652da30b4f96e52b7caaceb00e6532e6edf3802e80975f6d9b1d9df9c2993 sha
+123 ~7 symbols
sha256:39b38325a787b5c60a21610d57895451e6029fe6c4074bc3be0d149afc338a94 snapshot
+123
symbols added
~7
symbols modified
0
dead code introduced
Semantic Changes 130 symbols
~ tests/test_predict_supercharge.py .py 121 symbols added
+ TestBuildPredictions class class TestBuildPredictions L301–420
+ test_co_change_partners_populated method method test_co_change_partners_populated L388–400
+ test_commits_with_no_ops_returns_empty method method test_commits_with_no_ops_returns_empty L306–309
+ test_confidence_label_consistent_with_score method method test_confidence_label_consistent_with_score L334–344
+ test_empty_commits_returns_empty method method test_empty_commits_returns_empty L302–304
+ test_frequent_symbol_scores_higher method method test_frequent_symbol_scores_higher L353–367
+ test_horizon_window_controls_frequency_signal method method test_horizon_window_controls_frequency_signal L369–386
+ test_reasons_list_non_empty method method test_reasons_list_non_empty L346–351
+ test_required_fields_present method method test_required_fields_present L402–412
+ test_score_in_zero_one method method test_score_in_zero_one L318–323
+ test_signal_keys_present method method test_signal_keys_present L414–420
+ test_single_symbol_appears_in_predictions method method test_single_symbol_appears_in_predictions L311–316
+ test_sorted_by_score_descending method method test_sorted_by_score_descending L325–332
+ TestConfidenceLabel class class TestConfidenceLabel L222–239
+ test_high_above_threshold method method test_high_above_threshold L226–227
+ test_high_at_threshold method method test_high_at_threshold L223–224
+ test_low_at_zero method method test_low_at_zero L238–239
+ test_low_just_below_medium method method test_low_just_below_medium L235–236
+ test_medium_at_threshold method method test_medium_at_threshold L232–233
+ test_medium_just_below_high method method test_medium_just_below_high L229–230
+ TestIterSymbolOps class class TestIterSymbolOps L247–293
+ test_empty_ops_yields_nothing method method test_empty_ops_yields_nothing L251–254
+ test_multiple_ops_all_yielded method method test_multiple_ops_all_yielded L288–293
+ test_non_patch_op_with_symbol_address_yielded method method test_non_patch_op_with_symbol_address_yielded L256–262
+ test_non_symbol_op_filtered_out method method test_non_symbol_op_filtered_out L264–268
+ test_none_delta_yields_nothing method method test_none_delta_yields_nothing L248–249
+ test_patch_op_filters_non_symbol_children method method test_patch_op_filters_non_symbol_children L279–286
+ test_patch_op_yields_symbol_children method method test_patch_op_yields_symbol_children L270–277
+ TestJsonAlias class class TestJsonAlias L567–587
+ test_j_alias_emits_valid_json method method test_j_alias_emits_valid_json L572–575
+ test_j_alias_exits_zero method method test_j_alias_exits_zero L568–570
+ test_j_alias_matches_json_flag method method test_j_alias_matches_json_flag L577–587
+ TestModuleKey class class TestModuleKey L156–181
+ test_depth_1_single_dir method method test_depth_1_single_dir L157–159
+ test_depth_2_two_dirs method method test_depth_2_two_dirs L161–163
+ test_depth_3_deep method method test_depth_3_deep L165–167
+ test_depth_beyond_path_length method method test_depth_beyond_path_length L173–176
+ test_single_component_no_dir method method test_single_component_no_dir L169–171
+ test_strips_symbol_part method method test_strips_symbol_part L178–181
+ TestPctBar class class TestPctBar L189–214
+ test_above_one_clamps method method test_above_one_clamps L207–209
+ test_below_zero_clamps method method test_below_zero_clamps L203–205
+ test_half_half method method test_half_half L198–201
+ test_one_all_filled method method test_one_all_filled L194–196
+ test_width_respected method method test_width_respected L211–214
+ test_zero_all_empty method method test_zero_all_empty L190–192
+ TestPredictBasic class class TestPredictBasic L457–475
+ test_emits_some_output method method test_emits_some_output L462–465
+ test_empty_repo_exits_nonzero method method test_empty_repo_exits_nonzero L467–475
+ test_exits_zero method method test_exits_zero L458–460
+ TestPredictExplain class class TestPredictExplain L634–656
+ test_explain_human_output_for_known_symbol method method test_explain_human_output_for_known_symbol L647–656
+ test_explain_missing_separator_exits_one method method test_explain_missing_separator_exits_one L635–639
+ test_explain_unknown_address_exits_one method method test_explain_unknown_address_exits_one L641–645
+ TestPredictExplainJson class class TestPredictExplainJson L664–775
+ test_explain_json_exits_zero method method test_explain_json_exits_zero L665–674
+ test_explain_json_has_address method method test_explain_json_has_address L688–696
+ test_explain_json_has_duration_ms method method test_explain_json_has_duration_ms L755–764
+ test_explain_json_has_exit_code method method test_explain_json_has_exit_code L744–753
+ test_explain_json_has_reasons method method test_explain_json_has_reasons L722–731
+ test_explain_json_has_score method method test_explain_json_has_score L698–707
+ test_explain_json_has_signals method method test_explain_json_has_signals L709–720
+ test_explain_json_has_top_partners method method test_explain_json_has_top_partners L733–742
+ test_explain_json_importable_typeddict method method test_explain_json_importable_typeddict L766–775
+ test_explain_json_valid_json method method test_explain_json_valid_json L676–686
+ TestPredictFilters class class TestPredictFilters L595–626
+ test_file_filter method method test_file_filter L616–621
+ test_horizon_reflected_in_json method method test_horizon_reflected_in_json L623–626
+ test_min_confidence_filters method method test_min_confidence_filters L608–614
+ test_top_limits_predictions method method test_top_limits_predictions L596–599
+ test_top_zero_shows_all method method test_top_zero_shows_all L601–606
+ TestPredictJsonSchema class class TestPredictJsonSchema L483–559
+ test_json_exit_code_is_zero method method test_json_exit_code_is_zero L526–529
+ test_json_exits_zero method method test_json_exits_zero L484–486
+ test_json_has_commits_analysed method method test_json_has_commits_analysed L504–507
+ test_json_has_duration_ms method method test_json_has_duration_ms L531–536
+ test_json_has_exit_code method method test_json_has_exit_code L521–524
+ test_json_has_generated_at method method test_json_has_generated_at L493–496
+ test_json_has_horizon_commits method method test_json_has_horizon_commits L498–502
+ test_json_has_predictions_list method method test_json_has_predictions_list L515–519
+ test_json_has_truncated method method test_json_has_truncated L509–513
+ test_json_is_valid method method test_json_is_valid L488–491
+ test_prediction_record_schema method method test_prediction_record_schema L538–549
+ test_signal_set_schema method method test_signal_set_schema L551–559
+ TestPredictSecurity class class TestPredictSecurity L783–800
+ test_explain_without_double_colon_exits_one method method test_explain_without_double_colon_exits_one L796–800
+ test_min_confidence_above_one_exits_one method method test_min_confidence_above_one_exits_one L784–788
+ test_min_confidence_below_zero_exits_one method method test_min_confidence_below_zero_exits_one L790–794
+ TestSanitise class class TestSanitise L119–148
+ test_empty_string method method test_empty_string L147–148
+ test_exact_length_no_truncation method method test_exact_length_no_truncation L136–139
+ test_passthrough_normal_string method method test_passthrough_normal_string L120–121
+ test_strips_ansi_escape method method test_strips_ansi_escape L126–128
+ test_strips_control_chars method method test_strips_control_chars L123–124
+ test_strips_leading_trailing_whitespace method method test_strips_leading_trailing_whitespace L141–142
+ test_truncates_at_max_len method method test_truncates_at_max_len L130–134
+ test_unicode_passthrough method method test_unicode_passthrough L144–145
+ TestTypedDicts class class TestTypedDicts L808–818
+ test_explain_json_typeddict_importable method method test_explain_json_typeddict_importable L816–818
+ test_predict_json_typeddict_importable method method test_predict_json_typeddict_importable L809–814
+ _fake_commit function function _fake_commit L68–93
+ _patch_op function function _patch_op L101–111
+ _sym_op function function _sym_op L96–98
+ cli variable variable cli L59–59
+ CliRunner import import CliRunner L57–57
+ CommitRecord import import CommitRecord L56–56
+ _build_predictions import import _build_predictions L48–48
+ _confidence_label import import _confidence_label L48–48
+ _iter_symbol_ops import import _iter_symbol_ops L48–48
+ _module_key import import _module_key L48–48
+ _pct_bar import import _pct_bar L48–48
+ _sanitise import import _sanitise L48–48
+ annotations import import annotations L38–38
+ datetime import import datetime L40–40
+ json import import json L41–41
+ pathlib import import pathlib L42–42
+ pytest import import pytest L46–46
+ textwrap import import textwrap L43–43
+ typing import import typing L44–44
+ repo function function repo L429–449
+ runner variable variable runner L60–60
~ muse/cli/commands/predict.py .py 2 symbols added, 7 symbols modified
+ _ExplainJson class class _ExplainJson L229–260
+ start_timer import import start_timer L133–133
~ 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:58f652da30b4f96e52b7caaceb00e6532e6edf3802e80975f6d9b1d9df9c2993 --body "your comment"