gabriel / musehub public
fix patch task/presign-preregister #1 / 1
AI Agent gabriel · 153 days ago · Apr 24, 2026 · Diff

fix: pre-register presigned object IDs in musehub_objects to fix push 422

Root cause: POST /presign issued R2 PUT URLs but wrote no DB rows. When push/stream checked snapshot referential integrity it found the presigned objects missing from musehub_objects and rejected with 422.

Fix: presign_and_register_objects(session, repo_id, oids) writes placeholder rows (storage_uri='pending', size_bytes=0) and ref rows before returning presigned URLs. The integrity check finds the rows and the push succeeds.

TDD: 4 new tests (PI-1 through PI-4) written first, all failing, then made green by the implementation.

sha256:156ce285c8b517e0d76bc47837eda3c24b0ba42095c4433a2e35ef74662b6c50 sha
+36 ~1 symbols
sha256:07267ef088b6e2a46589ae99965902d350df8b63c5c6327d4e0f96b9214007b8 snapshot
+36
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 37 symbols
~ tests/test_wire_presign_integrity.py .py 35 symbols added
+ _collect_frames function async_function _collect_frames L115–119
+ _commit_pack_frame function function _commit_pack_frame L99–104
+ _end_frame function function _end_frame L107–112
+ _fw variable variable _fw L54–54
+ _header_frame function function _header_frame L77–86
+ _make_commit function function _make_commit L122–138
+ _make_repo function async_function _make_repo L149–178
+ _make_snapshot function function _make_snapshot L141–146
+ _object_frame function function _object_frame L89–96
+ _pack function function _pack L69–70
+ _sha256_oid function function _sha256_oid L61–62
+ _stub_r2_backend function function _stub_r2_backend L181–202
+ _utc function function _utc L65–66
+ _wrap function function _wrap L73–74
+ Any import import Any L37–37
+ AsyncMock import import AsyncMock L38–38
+ AsyncSession import import AsyncSession L43–43
+ MuseWireFrameWriter import import MuseWireFrameWriter L45–45
+ SFRAME_COMMIT_PACK import import SFRAME_COMMIT_PACK L46–46
+ SFRAME_END import import SFRAME_END L46–46
+ SFRAME_HEADER import import SFRAME_HEADER L46–46
+ SFRAME_OBJECT import import SFRAME_OBJECT L46–46
+ SFRAME_RESULT import import SFRAME_RESULT L46–46
+ annotations import import annotations L33–33
+ datetime import import datetime L36–36
+ func function import func L42–42
+ hashlib import import hashlib L35–35
+ msgpack import import msgpack L40–40
+ pytest import import pytest L41–41
+ select import import select L42–42
+ timezone import import timezone L36–36
+ test_pi1_presign_register_inserts_pending_row function async_function test_pi1_presign_register_inserts_pending_row L210–233
+ test_pi2_push_succeeds_when_presigned_object_preregistered function async_function test_pi2_push_succeeds_when_presigned_object_preregistered L241–279
+ test_pi3_presign_register_is_idempotent function async_function test_pi3_presign_register_is_idempotent L287–310
+ test_pi4_presign_register_creates_object_ref function async_function test_pi4_presign_register_creates_object_ref L318–341
~ musehub/api/routes/wire.py .py 1 symbol modified
~ musehub/services/musehub_wire.py .py 1 symbol added
+ presign_and_register_objects function async_function presign_and_register_objects L127–163
← Older Oldest on task/presign-preregister
All commits
Newer → Latest on task/presign-preregister

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