gabriel / muse public
fix patch task/fix-apply-mpack-missing-snapshot #1 / 1
AI Agent gabriel · 5 days ago · Jun 4, 2026 · Diff

fix: apply_mpack refuses commits when their snapshot is absent from mpack and store

When wire_fetch returns snaps=0 for a commit, apply_mpack was still writing the commit to the local store. On retry the commit is in `have`, the server returns nothing new, and pull aborts with 'snapshot missing' indefinitely.

Fix: before writing a commit, verify its snapshot is either in written_snapshot_ids (received in this mpack) or already in the local store. If neither, skip the commit with a warning. The next pull re-requests the commit without it in `have`, and the server sends it together with its snapshot.

Four tests in TestApplyMpackMissingSnapshotGuard cover: - commit refused when snapshot absent from mpack and store (regression) - second apply with snapshot succeeds after first was refused - commit written when snapshot already in local store (no false positive) - happy path: both commit and snapshot in same mpack

sha256:2c59968e5fd34f1740180d630338fddfb8c465b71e150a0965f11dbdcba5dec7 sha
+7 ~1 symbols
sha256:4784ac878a082f6222ebdba20b65575106507331ad97bb7c26b4f65c86d2c1eb snapshot
+7
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 8 symbols
+ docs/
+ muse/
+ tests/
+ tools/
~ muse/core/mpack.py .py 1 symbol modified
~ tests/test_mpack_core.py .py 7 symbols added
+ TestApplyMpackMissingSnapshotGuard class class TestApplyMpackMissingSnapshotGuard L404–477
+ test_commit_not_written_when_snapshot_absent_from_mpack method method test_commit_not_written_when_snapshot_absent_from_mpack L408–425
+ test_commit_written_when_snapshot_already_in_local_store method method test_commit_written_when_snapshot_already_in_local_store L448–462
+ test_commit_written_when_snapshot_in_same_mpack method method test_commit_written_when_snapshot_in_same_mpack L464–477
+ test_next_pull_can_succeed_after_refused_commit method method test_next_pull_can_succeed_after_refused_commit L427–446
+ _wire_commit function function _wire_commit L374–401
+ _wire_snap function function _wire_snap L362–371
← Older Oldest on task/fix-apply-mpack-missing-snapshot
All commits
Newer → Latest on task/fix-apply-mpack-missing-snapshot

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