gabriel / musehub public
feat BREAKING feat/object-pack-endpoint #1 / 1
AI Agent gabriel · 167 days ago · Apr 12, 2026 · Diff

feat: add pack-based object upload endpoint (POST /push/object-pack)

Replace N per-object TLS round-trips with M = ceil(N/1000) batched POSTs. For a 7 000-object push this is 7 requests instead of 7 000 connections.

Server changes: - WireObjectPackRequest / WireObjectPackResponse added to models/wire.py with PACK_MAX_OBJECTS=1_000 and PACK_MAX_BYTES=50_000_000 DoS limits. model_validator enforces total-byte budget before any storage write. - wire_push_object_pack() in services/musehub_wire.py: same auth/hash/ storage/DB pattern as wire_push_objects but accepts a full pack of objects in one msgpack POST. Bulk IN existence check, parallel asyncio storage puts, and a single bulk pg_insert on_conflict_do_nothing. - POST /{owner}/{slug}/push/object-pack route registered in api/routes/wire.py with the standard WIRE_PUSH_LIMIT rate limiter. - 10 new tests in tests/test_wire_protocol.py: happy path, idempotency, mixed new/existing, hash integrity, auth, non-owner rejection, count DoS limit, total-size DoS limit, collaborator auth, path traversal. All 99 wire protocol tests green. - docs/reference/type-contracts.md updated with the two new models.

sha256:dfa20cd4754ee9450bdf275ec73b78f137dae8f8076a7ac27595d3c828ac42d3 sha
+28 ~46 symbols
sha256:c27e5424def14f8645ab6b465847ff7d0e03095e25a74b270ef14aa159b788ca snapshot
+28
symbols added
~46
symbols modified
0
dead code introduced
Semantic Changes 74 symbols
~ docs/reference/type-contracts.md .md 5 symbols added, 7 symbols modified
+ py`@L3765 section MyModel — `tests/test_api_contracts_section37.py` L3765–3773
+ py`@L3774 section MyModel — `tests/test_api_contracts_section37.py` L3774–3782
+ py`@L3783 section MyModel — `tests/test_api_contracts_section37.py` L3783–3791
+ py` section WireObjectPackRequest — `musehub/models/wire.py` L3564–3584
+ py` section WireObjectPackResponse — `musehub/models/wire.py` L3585–3596
~ musehub/api/routes/wire.py .py 3 symbols added, 17 symbols modified
~ musehub/models/wire.py .py 7 symbols added, 3 symbols modified
+ PACK_MAX_BYTES variable variable PACK_MAX_BYTES L409–409
+ PACK_MAX_OBJECTS variable variable PACK_MAX_OBJECTS L408–408
+ WireObjectPackRequest class class WireObjectPackRequest L412–462
+ _check_total_size method method _check_total_size L448–462
+ _validate_object_ids method method _validate_object_ids L442–445
+ WireObjectPackResponse class class WireObjectPackResponse L465–473
+ model_validator import import model_validator L33–33
~ Field
~ tests/test_wire_protocol.py .py 10 symbols added
+ test_push_object_pack_idempotent function async_function test_push_object_pack_idempotent L2321–2341
+ test_push_object_pack_mixed_new_and_existing function async_function test_push_object_pack_mixed_new_and_existing L2345–2370
+ test_push_object_pack_path_traversal_rejected function async_function test_push_object_pack_path_traversal_rejected L2530–2549
+ test_push_object_pack_rejects_invalid_hash function async_function test_push_object_pack_rejects_invalid_hash L2374–2395
+ test_push_object_pack_rejects_non_owner function async_function test_push_object_pack_rejects_non_owner L2417–2434
+ test_push_object_pack_rejects_over_limit_count function async_function test_push_object_pack_rejects_over_limit_count L2438–2456
+ test_push_object_pack_requires_auth function async_function test_push_object_pack_requires_auth L2399–2413
+ test_push_object_pack_respects_total_size_limit function async_function test_push_object_pack_respects_total_size_limit L2460–2496
+ test_push_object_pack_stores_objects function async_function test_push_object_pack_stores_objects L2299–2317
+ test_push_object_pack_write_collaborator_allowed function async_function test_push_object_pack_write_collaborator_allowed L2500–2526
← Older Oldest on feat/object-pack-endpoint
All commits
Newer → Latest on feat/object-pack-endpoint

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