gabriel / muse public
refactor BREAKING core task/content-hash-sweep #1 / 1
AI Agent gabriel · 162 days ago · Apr 17, 2026 · Diff

refactor(core): unify all entity ID derivation under content_hash()

- Add content_hash(obj) to _types.py as the single canonical primitive (sort_keys, compact separators, ensure_ascii=True, sha256: prefix) - Wire content_hash into every compute_*_id function: store.py (tag/release), task_queue.py (task), coordination.py (reservation/intent), op_log.py (op), harmony.py (pattern/resolution/ escalation/audit), patch_record.py (patch) - Convert inline hashlib patterns in init.py, clone.py, shelf.py, test_history.py, test_runner.py to content_hash() - Fix shelf.py ensure_ascii=False bug (now ensure_ascii=True via content_hash) - Fix harmony: clear_all passes long_id(entry.name) to forget_pattern - Fix harmony: plugin fingerprint validator accepts sha256: format (len 71) - Remove all stale hashlib/json imports left by the conversion - Add tests/test_core_types.py (22 tests covering long_id/short_id/content_hash) - Update test_harmony_comprehensive.py: all ID assertions use sha256: format

sha256:c6bbf1a26ea88a2356f944487d722fe218cbfcbc36f5b1d021e9eebcd78a786c sha
+69 ~52 −19 symbols
sha256:2de494870c24d40153aea9e89123f0d73f87c10c91eb06e3ef9647ddfbbd15c8 snapshot
+69
symbols added
~52
symbols modified
−19
symbols removed
0
dead code introduced
Semantic Changes 140 symbols
~ tests/test_core_types.py .py 32 symbols added
+ TestContentHash class class TestContentHash L73–134
+ test_ascii_safe_non_ascii_key method method test_ascii_safe_non_ascii_key L104–111
+ test_compact_separators_no_whitespace method method test_compact_separators_no_whitespace L113–117
+ test_deterministic_for_same_input method method test_deterministic_for_same_input L81–83
+ test_differs_for_different_keys method method test_differs_for_different_keys L94–95
+ test_differs_for_different_values method method test_differs_for_different_values L91–92
+ test_empty_dict method method test_empty_dict L128–131
+ test_key_order_independent method method test_key_order_independent L85–89
+ test_list_input method method test_list_input L119–122
+ test_matches_manual_sha256 method method test_matches_manual_sha256 L97–102
+ test_nested_dict method method test_nested_dict L124–126
+ test_none_value method method test_none_value L133–134
+ test_returns_sha256_prefixed_id method method test_returns_sha256_prefixed_id L76–79
+ TestLongId class class TestLongId L18–41
+ test_adds_sha256_prefix method method test_adds_sha256_prefix L19–21
+ test_custom_algo method method test_custom_algo L35–37
+ test_idempotent_on_already_prefixed method method test_idempotent_on_already_prefixed L23–25
+ test_result_length_for_sha256 method method test_result_length_for_sha256 L39–41
+ test_strip_on_bare_hex_is_noop method method test_strip_on_bare_hex_is_noop L31–33
+ test_strip_removes_prefix method method test_strip_removes_prefix L27–29
+ TestShortId class class TestShortId L49–65
+ test_bare_hex_returns_first_12 method method test_bare_hex_returns_first_12 L59–61
+ test_custom_algo method method test_custom_algo L63–65
+ test_strip_removes_prefix method method test_strip_removes_prefix L55–57
+ test_truncates_prefixed_id method method test_truncates_prefixed_id L50–53
+ annotations import import annotations L3–3
+ content_hash import import content_hash L10–10
+ hashlib import import hashlib L5–5
+ json import import json L6–6
+ long_id import import long_id L10–10
+ pytest import import pytest L8–8
+ short_id import import short_id L10–10
~ muse/cli/commands/clone.py .py 1 symbol added, 2 symbols removed, 2 symbols modified
− hashlib import import hashlib L55–55
− long_id import import long_id L67–67
+ content_hash import import content_hash L66–66
~ run
~ muse/cli/commands/init.py .py 1 symbol added, 2 symbols removed, 1 symbol modified
− hashlib import import hashlib L61–61
− long_id import import long_id L71–71
+ content_hash import import content_hash L70–70
~ run
~ muse/cli/commands/shelf.py .py 1 symbol added, 2 symbols removed, 2 symbols modified
− hashlib import import hashlib L76–76
− long_id import import long_id L85–85
+ content_hash import import content_hash L84–84
~ muse/core/_types.py .py 3 symbols added
+ content_hash function function content_hash L84–114
+ hashlib import import hashlib L9–9 ← moved from muse/core/test_runner.py
+ json import import json L10–10
~ muse/core/coordination.py .py 1 symbol added, 1 symbol removed, 2 symbols modified
− long_id import import long_id L108–108
+ content_hash import import content_hash L108–108
~ muse/core/harmony.py .py 5 symbols added, 1 symbol removed, 22 symbols modified
− _HEX64_RE variable variable _HEX64_RE L142–142
+ _BARE_HEX64_RE variable variable _BARE_HEX64_RE L145–145
+ _SHA256_ID_RE variable variable _SHA256_ID_RE L142–142
+ _id_hex function function _id_hex L151–164
+ _resolution_path function function _resolution_path L618–624
+ content_hash import import content_hash L95–95
~ muse/core/op_log.py .py 1 symbol added, 1 symbol removed, 2 symbols modified
− long_id import import long_id L65–65
+ content_hash import import content_hash L65–65
~ muse/core/patch_record.py .py 1 symbol added, 2 symbols removed, 1 symbol modified
− hashlib import import hashlib L55–55
− long_id import import long_id L60–60
+ content_hash import import content_hash L59–59
~ muse/core/store.py .py 1 symbol added, 10 symbols modified
~ muse/core/task_queue.py .py 1 symbol added, 2 symbols removed, 1 symbol modified
− hashlib import import hashlib L96–96
− long_id import import long_id L105–105
+ content_hash import import content_hash L104–104
~ muse/core/test_history.py .py 1 symbol added, 2 symbols removed, 3 symbols modified
− hashlib import import hashlib L34–34
− long_id import import long_id L45–45
+ content_hash import import content_hash L44–44
~ muse/core/test_runner.py .py 1 symbol added, 2 symbols removed, 2 symbols modified
− hashlib import import hashlib L51–51 → moved to muse/core/_types.py
− long_id import import long_id L62–62
+ content_hash import import content_hash L60–60
~ tests/test_harmony_comprehensive.py .py 19 symbols added, 2 symbols removed, 4 symbols modified
− test_returns_hex64 method method test_returns_hex64 L263–268
− test_returns_hex64 method method test_returns_hex64 L298–300
+ test_returns_sha256_id method method test_returns_sha256_id L268–273
+ test_returns_sha256_id method method test_returns_sha256_id L303–307
+ TestHarmonyIdFormat class class TestHarmonyIdFormat L2311–2427
+ _obj_id method method _obj_id L2314–2315
+ test_append_audit_id_sha256_prefix method method test_append_audit_id_sha256_prefix L2415–2427
+ test_blob_fingerprint_commutative method method test_blob_fingerprint_commutative L2324–2326
+ test_blob_fingerprint_deterministic method method test_blob_fingerprint_deterministic L2328–2330
+ test_blob_fingerprint_differs_by_inputs method method test_blob_fingerprint_differs_by_inputs L2332–2334
+ test_blob_fingerprint_sha256_prefix method method test_blob_fingerprint_sha256_prefix L2319–2322
+ test_compute_escalation_id_deterministic method method test_compute_escalation_id_deterministic L2399–2404
+ test_compute_escalation_id_differs_by_reason method method test_compute_escalation_id_differs_by_reason L2406–2411
+ test_compute_escalation_id_sha256_prefix method method test_compute_escalation_id_sha256_prefix L2392–2397
+ test_compute_pattern_id_deterministic method method test_compute_pattern_id_deterministic L2344–2346
+ test_compute_pattern_id_differs_by_path method method test_compute_pattern_id_differs_by_path L2348–2350
+ test_compute_pattern_id_semantic_differs_from_blob method method test_compute_pattern_id_semantic_differs_from_blob L2352–2357
+ test_compute_pattern_id_sha256_prefix method method test_compute_pattern_id_sha256_prefix L2338–2342
+ test_compute_resolution_id_deterministic method method test_compute_resolution_id_deterministic L2374–2380
+ test_compute_resolution_id_differs_by_outcome method method test_compute_resolution_id_differs_by_outcome L2382–2388
+ test_compute_resolution_id_sha256_prefix method method test_compute_resolution_id_sha256_prefix L2361–2372
~ _hex64
← Older Oldest on task/content-hash-sweep
All commits
Newer → Latest on task/content-hash-sweep

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