gabriel / muse public
fix patch store dev
AI Agent gabriel · 144 days ago · Apr 27, 2026 · Diff

fix(store): Phase 2 — parent existence validation in write_commit

Adds MissingParentError(ValueError) and a pre-write guard that rejects any commit whose parent_commit_id or parent2_commit_id does not exist in the local object store.

A dangling parent pointer silently truncates history traversal: walks (log, rebase, push) stop at the gap rather than reaching the true root. Catching it at write time surfaces the corruption with a clear, actionable error instead of letting the bad commit land in the store.

Guard runs before hash verification so callers receive MissingParentError specifically rather than a generic hash-mismatch ValueError.

8-test suite in test_phase2_parent_existence.py: root commits, known parents, unknown parent, unknown parent2, merge commits with both parents, data integrity, ValueError subclass.

sha256:82fa3aa298016896d7b730256d206781e05ee85bbb63ed66c22223917a4117ea sha
+29 ~1 symbols
sha256:ced3fc0193731e1b67353d8852767abe4bea06573720ebcb0cee55be94f1f1ae snapshot
+29
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 30 symbols
~ tests/test_phase2_parent_existence.py .py 28 symbols added
+ TestDataIntegrity class class TestDataIntegrity L175–195
+ test_commit_id_not_in_store_after_missing_parent_reject method method test_commit_id_not_in_store_after_missing_parent_reject L176–186
+ test_missing_parent_error_is_value_error_subclass class method test_missing_parent_error_is_value_error_subclass L188–195
+ TestMissingParent2Rejected class class TestMissingParent2Rejected L143–168
+ test_both_parents_known_does_not_raise_missing_parent_error method method test_both_parents_known_does_not_raise_missing_parent_error L155–168
+ test_unknown_parent2_raises_missing_parent_error method method test_unknown_parent2_raises_missing_parent_error L144–153
+ TestMissingParentRejected class class TestMissingParentRejected L102–136
+ test_known_parent_does_not_raise_missing_parent_error method method test_known_parent_does_not_raise_missing_parent_error L124–136
+ test_unknown_parent_produces_no_file method method test_unknown_parent_produces_no_file L111–122
+ test_unknown_parent_raises_missing_parent_error method method test_unknown_parent_raises_missing_parent_error L103–109
+ TestRootCommitNeverRaisesParentError class class TestRootCommitNeverRaisesParentError L84–95
+ test_none_parents_not_rejected_for_parent_reason method method test_none_parents_not_rejected_for_parent_reason L85–95
+ _BRANCH variable variable _BRANCH L41–41
+ _REPO_ID variable variable _REPO_ID L40–40
+ _SNAP_ID variable variable _SNAP_ID L42–42
+ _fake_commit_id function function _fake_commit_id L45–46
+ _make_commit function function _make_commit L49–63
+ _plant_commit_file function function _plant_commit_file L66–77
+ CommitRecord import import CommitRecord L27–27
+ MissingParentError import import MissingParentError L27–27
+ annotations import import annotations L19–19
+ commit_exists import import commit_exists L27–27
+ commit_path import import commit_path L27–27
+ datetime import import datetime L21–21
+ msgpack import import msgpack L24–24
+ pathlib import import pathlib L22–22
+ pytest import import pytest L25–25
+ write_commit import import write_commit L27–27
~ muse/core/store.py .py 1 symbol added, 1 symbol modified
+ MissingParentError class class MissingParentError L407–415
← 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:82fa3aa298016896d7b730256d206781e05ee85bbb63ed66c22223917a4117ea --body "your comment"