gabriel / musehub public
perf patch task/bundle-push-async #1 / 1
AI Agent gabriel · 127 days ago · May 11, 2026 · Diff

perf: async bundle indexing — sync path returns in < 1s

unpack-bundle now does exactly three things synchronously: 1. GET bundle + verify sha256(wire_bytes)==bundle_key 2. Advance branch pointer (one PG row) 3. Enqueue bundle.index job (one PG row)

All commit and snapshot indexing is deferred to process_bundle_index_job, called by the background worker. bundle.index is always inserted as a fresh row (no dedup) since each push has a unique bundle_key.

Tests: test_bundle_push_async.py — 3 tests, all passing: - unpack-bundle returns < 1s for 1031 commits × 700 files - bundle.index job correctly writes all commits and snapshots - branch pointer is set before worker runs

sha256:b97b1d8a2da3e3f001a43a0b8157cc0f6a3abaad9468f363ced0ac6c00b5f693 sha
+45 ~2 symbols
sha256:d6aec5845051869f6086c6b1da26f8601f7fe84348f7c016b52f73745cd45755 snapshot
+45
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 47 symbols
~ tests/test_bundle_push_async.py .py 44 symbols added
+ _AUTH_CTX variable variable _AUTH_CTX L76–81
+ _BLOB_SIZE variable variable _BLOB_SIZE L66–66
+ _FILES_CHANGED variable variable _FILES_CHANGED L65–65
+ _N_COMMITS variable variable _N_COMMITS L64–64
+ _N_FILES variable variable _N_FILES L63–63
+ _SYNC_GATE_S variable variable _SYNC_GATE_S L69–69
+ _make_repo function function _make_repo L118–128
+ _populate function function _populate L131–189
+ _upload_bundle function async_function _upload_bundle L196–214
+ client function async_function client L85–99
+ ASGITransport import import ASGITransport L36–36
+ AsyncClient import import AsyncClient L36–36
+ AsyncSession import import AsyncSession L38–38
+ CommitRecord import import CommitRecord L49–49
+ MSignContext import import MSignContext L40–40
+ SnapshotRecord import import SnapshotRecord L49–49
+ annotations import import annotations L25–25
+ app import import app L43–43
+ blob_id import import blob_id L56–56
+ build_mpack import import build_mpack L46–46
+ compute_commit_id import import compute_commit_id L48–48
+ compute_snapshot_id import import compute_snapshot_id L48–48
+ datetime import import datetime L27–27
+ db import import db L41–41
+ get_db import import get_db L42–42
+ hashlib import import hashlib L28–28
+ httpx import import httpx L32–32
+ msgpack import import msgpack L33–33
+ muse_dir import import muse_dir L47–47
+ optional_signed_request import import optional_signed_request L40–40
+ pathlib import import pathlib L29–29
+ pytest import import pytest L34–34
+ pytest_asyncio import import pytest_asyncio L35–35
+ require_signed_request import import require_signed_request L40–40
+ select import import select L37–37
+ time import import time L30–30
+ write_branch_ref import import write_branch_ref L49–49
+ write_commit import import write_commit L49–49
+ write_object import import write_object L45–45
+ write_snapshot import import write_snapshot L49–49
+ repo function async_function repo L103–111
+ test_branch_head_correct_before_indexing function async_function test_branch_head_correct_before_indexing L333–362
+ test_bundle_index_job_populates_commits_and_snapshots function async_function test_bundle_index_job_populates_commits_and_snapshots L280–329
+ test_unpack_bundle_returns_fast function async_function test_unpack_bundle_returns_fast L222–276
~ musehub/services/musehub_wire.py .py 1 symbol added, 1 symbol modified
+ process_bundle_index_job function async_function process_bundle_index_job L1269–1434
~ musehub/worker.py .py 1 symbol modified
← Older Oldest on task/bundle-push-async
All commits
Newer → Latest on task/bundle-push-async

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