gabriel / muse public
refactor BREAKING store task/store-phase1-io #1 / 1
AI Agent gabriel · 124 days ago · May 21, 2026 · Diff

refactor(store): Phase 1 — extract raw I/O primitives into muse/core/io.py

Move all I/O primitives with no domain knowledge out of the 2571-line store.py god object into a new focused module:

muse/core/io.py — MAX_MSGPACK_BYTES, MAX_PACK_MSGPACK_BYTES, safe_unpackb, _read_msgpack, _read_msgpack_dict, write_text_atomic, zstd_decompress_if_needed, _zstd_compress, _ZSTD_*, _validated_store_parents, read_msgpack_file, _write_json_atomic, _write_shelf_header_atomic, _fsync_robust

store.py retains all domain types and business logic; it now imports the above from muse.core.io. All 15 source callers and 9 test files updated. Patches in tests updated to target muse.core.io.* since that is where the constants live at runtime. Fixes missing json/_json/tempfile/fcntl imports in store.py after extraction.

sha256:b561b3dbe85d8f76917476655c0b39e77f247f795a9eb924ff614cdb550e505e sha
+47 ~128 −20 symbols
sha256:0647b6d2ba90a8400b69fd55920bcaee3397fa67ce13e189766e0fd6c8308be5 snapshot
+47
symbols added
~128
symbols modified
−20
symbols removed
0
dead code introduced
Semantic Changes 195 symbols
~ muse/core/io.py .py 32 symbols added
+ MAX_MSGPACK_BYTES variable variable MAX_MSGPACK_BYTES L36–36 ← moved from muse/core/store.py
+ MAX_PACK_MSGPACK_BYTES variable variable MAX_PACK_MSGPACK_BYTES L40–40 ← moved from muse/core/store.py
+ _MSGPACK_MAX_ARRAY_LEN variable variable _MSGPACK_MAX_ARRAY_LEN L46–46 ← moved from muse/core/store.py
+ _MSGPACK_MAX_BIN_LEN variable variable _MSGPACK_MAX_BIN_LEN L44–44 ← moved from muse/core/store.py
+ _MSGPACK_MAX_BIN_LEN_PACK variable variable _MSGPACK_MAX_BIN_LEN_PACK L45–45 ← moved from muse/core/store.py
+ _MSGPACK_MAX_MAP_LEN variable variable _MSGPACK_MAX_MAP_LEN L47–47 ← moved from muse/core/store.py
+ _MSGPACK_MAX_STR_LEN variable variable _MSGPACK_MAX_STR_LEN L43–43 ← moved from muse/core/store.py
+ _ZSTD_COMPRESS_THRESHOLD variable variable _ZSTD_COMPRESS_THRESHOLD L59–59 ← moved from muse/core/store.py
+ _ZSTD_MAGIC variable variable _ZSTD_MAGIC L55–55 ← moved from muse/core/store.py
+ _fsync_robust function function _fsync_robust L245–257
+ _read_msgpack function function _read_msgpack L177–191
+ _read_msgpack_dict function function _read_msgpack_dict L194–205
+ _validated_store_parents variable variable _validated_store_parents L91–91 ← moved from muse/core/store.py
+ _write_json_atomic function function _write_json_atomic L260–282
+ _write_shelf_header_atomic function function _write_shelf_header_atomic L285–309
+ _zstd_compress function function _zstd_compress L62–70
+ MsgpackValue import import MsgpackValue L29–29
+ _json import import _json L20–20
+ annotations import import annotations L15–15
+ assert_not_symlink import import assert_not_symlink L28–28
+ contextlib import import contextlib L17–17
+ errno import import errno L18–18 ← moved from muse/core/store.py
+ fcntl import import fcntl L19–19
+ msgpack import import msgpack L26–26
+ os import import os L21–21
+ pathlib import import pathlib L22–22
+ sys import import sys L23–23
+ tempfile import import tempfile L24–24
+ read_msgpack_file function function read_msgpack_file L144–174
+ safe_unpackb function function safe_unpackb L97–141
+ write_text_atomic function function write_text_atomic L211–242
+ zstd_decompress_if_needed function function zstd_decompress_if_needed L73–82
~ muse/cli/config.py .py 1 symbol modified
~ muse/core/coordination.py .py 1 symbol modified
~ muse/core/dag.py .py 1 symbol modified
~ muse/core/merge_engine.py .py 1 symbol modified
~ muse/core/migrate.py .py 1 symbol modified
~ muse/core/op_log.py .py 1 symbol modified
~ muse/core/store.py .py 15 symbols added, 20 symbols removed
MAX_MSGPACK_BYTES variable variable MAX_MSGPACK_BYTES L122–122 → moved to muse/core/io.py
MAX_PACK_MSGPACK_BYTES variable variable MAX_PACK_MSGPACK_BYTES L127–127 → moved to muse/core/io.py
_MSGPACK_MAX_ARRAY_LEN variable variable _MSGPACK_MAX_ARRAY_LEN L139–139 → moved to muse/core/io.py
_MSGPACK_MAX_BIN_LEN variable variable _MSGPACK_MAX_BIN_LEN L137–137 → moved to muse/core/io.py
_MSGPACK_MAX_BIN_LEN_PACK variable variable _MSGPACK_MAX_BIN_LEN_PACK L138–138 → moved to muse/core/io.py
_MSGPACK_MAX_MAP_LEN variable variable _MSGPACK_MAX_MAP_LEN L140–140 → moved to muse/core/io.py
_MSGPACK_MAX_STR_LEN variable variable _MSGPACK_MAX_STR_LEN L136–136 → moved to muse/core/io.py
_ZSTD_COMPRESS_THRESHOLD variable variable _ZSTD_COMPRESS_THRESHOLD L693–693 → moved to muse/core/io.py
_ZSTD_MAGIC variable variable _ZSTD_MAGIC L688–688 → moved to muse/core/io.py
_read_msgpack function function _read_msgpack L565–587
_read_msgpack_dict function function _read_msgpack_dict L589–601
_validated_store_parents variable variable _validated_store_parents L468–468 → moved to muse/core/io.py
_write_json_atomic function function _write_json_atomic L603–636
_write_shelf_header_atomic function function _write_shelf_header_atomic L638–672
_zstd_compress function function _zstd_compress L695–709
errno import import errno L68–68 → moved to muse/core/io.py
read_msgpack_file function function read_msgpack_file L526–563
safe_unpackb function function safe_unpackb L470–524
write_text_atomic function function write_text_atomic L333–377
zstd_decompress_if_needed function function zstd_decompress_if_needed L711–727
+ MAX_MSGPACK_BYTES import import MAX_MSGPACK_BYTES L83–83
+ MAX_PACK_MSGPACK_BYTES import import MAX_PACK_MSGPACK_BYTES L83–83
+ _ZSTD_COMPRESS_THRESHOLD import import _ZSTD_COMPRESS_THRESHOLD L83–83
+ _ZSTD_MAGIC import import _ZSTD_MAGIC L83–83
+ _read_msgpack import import _read_msgpack L83–83
+ _read_msgpack_dict import import _read_msgpack_dict L83–83
+ _validated_store_parents import import _validated_store_parents L83–83
+ _write_json_atomic import import _write_json_atomic L83–83
+ _write_shelf_header_atomic import import _write_shelf_header_atomic L83–83
+ _zstd_compress import import _zstd_compress L83–83
+ contextlib import import contextlib L67–67
+ read_msgpack_file import import read_msgpack_file L83–83
+ safe_unpackb import import safe_unpackb L83–83
+ write_text_atomic import import write_text_atomic L83–83
+ zstd_decompress_if_needed import import zstd_decompress_if_needed L83–83
~ muse/core/task_queue.py .py 1 symbol modified
← Older Oldest on task/store-phase1-io
All commits
Newer → Latest on task/store-phase1-io

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