gabriel / muse public
feat BREAKING task/diff-json-schema #1 / 1
gabriel · 162 days ago · Apr 16, 2026 · Diff

feat: symbol-aware diff --json + fix staged diff correctness

diff --json schema additions (Muse is a symbol-aware VCS — the JSON must be too): - renamed: {old_path: new_path} extracted from PatchOp.from_address - symbols: {file: {added,deleted,modified}} from PatchOp.child_ops - sem_ver_bump: classify_delta() run in-place (same data, missing call) - breaking_changes: classification.breaking_addresses from same classifier - total_changes: explicit len(added)+len(modified)+len(deleted)+len(renamed) - summary field removed (natural language, useless to agents)

Bug fix — muse diff --staged correctness: - plugin.snapshot(root) with empty stage falls through to full working-tree walk (correct for muse commit; wrong for diff --staged). Empty stage must produce staged-view == HEAD. Fixed by building staged_files explicitly from read_stage() entries overlaid on head_files, bypassing snapshot().

Naming consistency — op vocabulary aligned to core domain ops (domain.py): - RefactorEventSummary.kind comment: 'add' → 'insert' (matches InsertOp) - release_analysis.py: kind='add' → kind='insert' at both call sites

TDD: 26 new tests across test_diff_json_schema.py (20) and test_diff_staged_clean.py (6) covering schema invariants, file-level categorisation, symbol output, semantic fields, diff modes, and the empty-stage correctness regression.

sha256:1f29c0a37879bd3dade9e54dc0d4aaefd4033de95224aa18e959da004967790a sha
+54 ~2 symbols
sha256:8312ac124ffe52b049d59767e5d568f5653056fca7c90affe566cfb64c35edaf snapshot
+54
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 56 symbols
~ tests/test_diff_json_schema.py .py 37 symbols added
+ TestDiffModesV class class TestDiffModesV L327–361
+ test_V1_staged_flag_sets_to_ref method method test_V1_staged_flag_sets_to_ref L328–333
+ test_V2_staged_flag_shows_staged_changes method method test_V2_staged_flag_shows_staged_changes L335–340
+ test_V3_default_shows_working_tree method method test_V3_default_shows_working_tree L342–347
+ test_V4_commit_to_commit_diff_has_sha256_to_commit_id method method test_V4_commit_to_commit_diff_has_sha256_to_commit_id L349–361
+ TestFileLevelCategorizationII class class TestFileLevelCategorizationII L161–219
+ test_II1_added_file_in_added method method test_II1_added_file_in_ L162–170
+ test_II2_deleted_file_in_deleted method method test_II2_deleted_file_in_deleted L172–180
+ test_II3_modified_file_in_modified method method test_II3_modified_file_in_ L182–186
+ test_II4_total_changes_formula method method test_II4_total_changes_formula L188–201
+ test_II5_renamed_file_in_renamed_not_modified method method test_II5_renamed_file_in_renamed_not_ L203–219
+ TestSchemaInvariantsI class class TestSchemaInvariantsI L118–153
+ test_I1_clean_repo_all_keys_present method method test_I1_clean_repo_all_keys_present L119–123
+ test_I2_dirty_repo_all_keys_present method method test_I2_dirty_repo_all_keys_present L125–132
+ test_I3_from_commit_id_is_sha256_prefixed method method test_I3_from_commit_id_is_sha256_prefixed L134–140
+ test_I4_has_changes_reflects_dirty_state method method test_I4_has_changes_reflects_dirty_state L142–153
+ TestSemanticFieldsIV class class TestSemanticFieldsIV L293–319
+ test_IV1_sem_ver_bump_always_present method method test_IV1_sem_ver_bump_always_present L294–299
+ test_IV2_breaking_changes_always_present method method test_IV2_breaking_changes_always_present L301–305
+ test_IV3_sem_ver_bump_reflects_changes method method test_IV3_sem_ver_bump_reflects_changes L307–319
+ TestSymbolLevelOutputIII class class TestSymbolLevelOutputIII L227–285
+ test_III1_symbols_always_present method method test_III1_symbols_always_present L228–233
+ test_III2_new_function_in_symbols_added method method test_III2_new_function_in_symbols_ L235–251
+ test_III3_deleted_function_in_symbols_deleted method method test_III3_deleted_function_in_symbols_deleted L253–270
+ test_III4_added_file_symbols_in_symbols_or_omitted method method test_III4_added_file_symbols_in_symbols_or_omitted L272–285
+ _REQUIRED_KEYS variable variable _REQUIRED_KEYS L78–85
+ _SYMBOL_BUCKET_KEYS variable variable _SYMBOL_BUCKET_KEYS L87–87
+ _diff_json function function _diff_json L94–97
+ _env function function _env L90–91
+ cli variable variable cli L75–75
+ code_repo function function code_repo L101–110
+ CliRunner import import CliRunner L73–73
+ annotations import import annotations L66–66
+ json import import json L68–68
+ pathlib import import pathlib L69–69
+ pytest import import pytest L71–71
+ runner variable variable runner L76–76
~ tests/test_diff_staged_clean.py .py 16 symbols added
+ _diff_json function function _diff_json L35–38
+ _env function function _env L31–32
+ cli variable variable cli L27–27
+ CliRunner import import CliRunner L25–25
+ annotations import import annotations L18–18
+ json import import json L20–20
+ pathlib import import pathlib L21–21
+ pytest import import pytest L23–23
+ repo function function repo L42–52
+ runner variable variable runner L28–28
+ test_S1_empty_stage_after_commit_has_no_changes function function test_S1_empty_stage_after_commit_has_no_changes L55–65
+ test_S2_staged_modification_visible function function test_S2_staged_modification_visible L68–78
+ test_S3_staged_new_file_visible function function test_S3_staged_new_file_visible L81–90
+ test_S4_staged_deletion_visible function function test_S4_staged_deletion_visible L93–102
+ test_S5_unstaged_changes_not_visible_in_staged_diff function function test_S5_unstaged_changes_not_visible_in_staged_diff L105–115
+ test_S6_working_tree_diff_shows_unstaged_changes function function test_S6_working_tree_diff_shows_unstaged_changes L118–125
~ muse/cli/commands/diff.py .py 1 symbol added, 1 symbol modified
+ classify_delta class import classify_delta L71–71
~ run
← Older Oldest on task/diff-json-schema
All commits
Newer → Latest on task/diff-json-schema

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