gabriel / musehub public
feat BREAKING phase2 task/object-refs-phase2 #1 / 1
gabriel · 164 days ago · Apr 13, 2026 · Diff

feat(phase2): wire all push paths to write musehub_object_refs

_upsert_object_refs(session, repo_id, object_ids) — single helper that bulk-upserts (repo_id, object_id) rows ON CONFLICT DO NOTHING. Called at all 6 push entry points:

- wire_push (inline bundle objects) - wire_push_objects (chunked pre-upload) - wire_push_object_pack (small-object pack — primary CLI path) - wire_repair_object - wire_confirm_objects (presigned PUT confirm) - worker_register_objects (Cloudflare Worker callback)

Key correctness invariant: refs are upserted for ALL incoming object_ids (new + already-present/deduplicated). A repo that deduplicates an object from another repo still gets a ref row so per-repo quota, GC, and audit queries return correct results.

Also: object_id FK on musehub_object_refs gains ondelete=CASCADE so deleting a musehub_objects row cascades to its refs cleanly.

Tests (6 new): pack new, pack dedup, push/objects, wire_push bundle, confirm, idempotent re-push. 162 wire-path tests pass.

sha256:c99042c649dd3f16bf9f914be5f9d147aafa35fe16e497f4da3088e5e525b2f2 sha
+27 ~8 symbols
sha256:f5b9da8604ba523c27932257579fa525d2e5df5b3c204e118ec39229a9d9eb7d snapshot
+27
symbols added
~8
symbols modified
0
dead code introduced
Semantic Changes 35 symbols
~ tests/test_object_refs.py .py 26 symbols added
+ _bare_hex function function _bare_hex L39–40
+ _mp function function _mp L43–44
+ _object_count function async_function _object_count L72–79
+ _ref_count function async_function _ref_count L62–69
+ _ref_exists function async_function _ref_exists L51–59
+ _utc_now function function _utc_now L32–33
+ _zlib function function _zlib L47–48
+ AsyncClient import import AsyncClient L25–25
+ AsyncSession import import AsyncSession L26–26
+ annotations import import annotations L15–15
+ datetime import import datetime L20–20
+ db import import db L28–28
+ factory_create_repo import import factory_create_repo L29–29
+ hashlib import import hashlib L17–17
+ msgpack import import msgpack L22–22
+ pytest import import pytest L23–23
+ sa import import sa L24–24
+ timezone import import timezone L20–20
+ uuid import import uuid L18–18
+ zlib import import zlib L19–19
+ test_confirm_objects_writes_refs function async_function test_confirm_objects_writes_refs L241–267
+ test_idempotent_push_does_not_duplicate_refs function async_function test_idempotent_push_does_not_duplicate_refs L275–296
+ test_pack_push_writes_ref_for_deduplicated_object function async_function test_pack_push_writes_ref_for_deduplicated_object L116–157
+ test_pack_push_writes_ref_for_new_object function async_function test_pack_push_writes_ref_for_new_object L87–108
+ test_push_objects_endpoint_writes_refs function async_function test_push_objects_endpoint_writes_refs L165–184
+ test_wire_push_bundle_objects_writes_refs function async_function test_wire_push_bundle_objects_writes_refs L192–233
~ musehub/services/musehub_wire.py .py 1 symbol added, 5 symbols modified
+ _upsert_object_refs function async_function _upsert_object_refs L97–127
← Older Oldest on task/object-refs-phase2
All commits
Newer → Latest on task/object-refs-phase2

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