gabriel / musehub public
fix BREAKING phase8 task/issue-7-phase-8 #1 / 1
AI Agent gabriel · 53 days ago · Apr 27, 2026 · Diff

fix(phase8): atomic _write() + ingest_push parent validation with regression tests

Gap 1 — ingest_push() parent existence validation - New commits in a push whose parent_id is neither in the bundle nor already in the DB are now rejected with ValueError('missing_parent_commits: …'). - Mirrors the same guard in wire_push_stream() (musehub_wire.py) so both ingest paths are equally safe. - 4 new tests in test_data_integrity.py cover: bogus parent rejected, parent-in-bundle accepted, parent-already-in-DB accepted, genesis accepted.

Gap 2 — LocalBackend._write() atomic crash safety - Replaced path.write_bytes(data) with mkstemp → os.write → os.fsync → os.close → os.replace. Readers see either the old file or the fully-written new file — never a partial write. - Temp file is unlinked on any failure (fsync error, replace error). - Final chmod 0o444 makes objects immutable after storage. - 7 new tests in TestAtomicWrite cover: complete file left, no orphan temp, immutable permissions, fsync-failure cleanup, idempotent skip, repair- corrupted, concurrent safety.

sha256:403c3d613fb4c6c7b0730424673516368301bb1ccad7d6c71fe403ec14d31a8b sha
sha256:e7929482ef5dc45339eace4d1885db8fed57530838ce03fa6746d6591488d195 snapshot
← Older Oldest on task/issue-7-phase-8
All commits
Newer → Latest on task/issue-7-phase-8

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