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.
0 comments
muse hub commit comment sha256:403c3d613fb4c6c7b0730424673516368301bb1ccad7d6c71fe403ec14d31a8b --body "your comment"
No comments yet. Be the first to start the discussion.