gabriel / muse public
fix patch apply_mpack dev
AI Agent gabriel · 123 days ago · May 16, 2026 · Diff

fix(apply_mpack): propagate object write failures to prevent dangling references

When write_object raises ValueError (content/ID mismatch) or an object exceeds the size cap, the failed object_id is now tracked in failed_object_ids. Any snapshot whose manifest references a failed object is added to skipped_snapshot_ids and not written. Any commit referencing a skipped snapshot is also not written.

Without this fix: commit → snapshot → (missing object) chains were silently written, corrupting the local store. The write ordering (objects → snapshots → commits) was necessary but not sufficient — failure propagation up the chain was the missing piece.

TDD: tests/test_apply_mpack_partial_failure.py covers four cases: PF-1 poisoned object (hash mismatch) → snapshot + commit not written PF-2 OSError mid-write → caller exception propagates (no snapshots/commits written) PF-3 unaffected commits in same mpack still write when one chain is poisoned PF-4 happy path regression guard — all objects succeed, all commits written

sha256:32e34ef9ced726fbea989672b30c0b835cbb44f8c8e57c6d207a2c88d80cda6d sha
+29 ~1 symbols
sha256:c90cadc6b4d07a3727a17b80a5a2334442dc03f261963868cd93131fbbf567c3 snapshot
+29
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 30 symbols
+ _DT variable variable _DT L49–49
+ _init_repo function function _init_repo L52–60
+ _make_mpack_with_poisoned_object function function _make_mpack_with_poisoned_object L63–105
+ CommitRecord import import CommitRecord L37–37
+ MPack import import MPack L33–33
+ SnapshotRecord import import SnapshotRecord L37–37
+ annotations import import annotations L24–24
+ apply_mpack import import apply_mpack L33–33
+ blob_id import import blob_id L46–46
+ build_mpack import import build_mpack L33–33
+ compute_commit_id import import compute_commit_id L36–36
+ compute_snapshot_id import import compute_snapshot_id L36–36
+ datetime import import datetime L26–26
+ has_object import import has_object L34–34
+ json import import json L27–27
+ muse_dir import import muse_dir L35–35
+ patch import import patch L29–29
+ pathlib import import pathlib L28–28
+ pytest import import pytest L31–31
+ read_commit import import read_commit L37–37
+ read_snapshot import import read_snapshot L37–37
+ write_branch_ref import import write_branch_ref L37–37
+ write_commit import import write_commit L37–37
+ write_object import import write_object L34–34
+ write_snapshot import import write_snapshot L37–37
+ test_pf1_poisoned_object_prevents_commit_write function function test_pf1_poisoned_object_prevents_commit_write L112–138
+ test_pf2_oserror_on_object_write_aborts_cleanly function function test_pf2_oserror_on_object_write_aborts_cleanly L145–181
+ test_pf3_clean_commits_write_when_one_chain_is_poisoned function function test_pf3_clean_commits_write_when_one_chain_is_poisoned L188–250
+ test_pf4_happy_path_unaffected function function test_pf4_happy_path_unaffected L257–291
~ muse/core/mpack.py .py 1 symbol modified
← 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:32e34ef9ced726fbea989672b30c0b835cbb44f8c8e57c6d207a2c88d80cda6d --body "your comment"