gabriel / musehub public
feat patch quota task/phase4-quota-via-refs #1 / 1
gabriel · 164 days ago · Apr 13, 2026 · Diff

feat(quota): phase 4 — all storage accounting joins through musehub_object_refs

Three quota sites updated to JOIN through musehub_object_refs instead of filtering on musehub_objects.repo_id (legacy column, wrong for dedup):

- wire_push per-repo quota: JOIN object_refs WHERE ref.repo_id = ? - musehub_mcp_executor per-user quota: JOIN object_refs JOIN repos WHERE owner_user_id = ? - get_repo_home_stats object count + size: JOIN object_refs WHERE ref.repo_id = ?

Also updated docs/db-query-runbook.md Q8 and Q10 to reflect the new query shapes.

Added 5-test suite in tests/test_quota_via_refs.py covering: - shared object counted independently per repo - idempotent push does not inflate quota - push rejected when quota exceeded (wire_push direct call) - get_repo_home_stats uses refs join for total_objects and total_size_bytes - shared object appears correctly in each repo's stats

sha256:4e36235e03452e7bd80851b2fea5fdd72a5a929a712d4464f70af2b36314f487 sha
+22 ~10 −1 symbols
sha256:913c88152164f88a3079c8d9e7e731631f946298c8969e7dbe80b5a1fbbfff0a snapshot
+22
symbols added
~10
symbols modified
−1
symbol removed
0
dead code introduced
Semantic Changes 33 symbols
~ tests/test_quota_via_refs.py .py 21 symbols added
+ _mp function function _mp L35–36
+ _oid function function _oid L31–32
+ _zlib function function _zlib L39–40
+ AsyncClient import import AsyncClient L24–24
+ AsyncMock import import AsyncMock L19–19
+ AsyncSession import import AsyncSession L25–25
+ MagicMock import import MagicMock L19–19
+ annotations import import annotations L15–15
+ create_repo import import create_repo L28–28
+ db import import db L27–27
+ hashlib import import hashlib L17–17
+ msgpack import import msgpack L21–21
+ patch import import patch L19–19
+ pytest import import pytest L22–22
+ sa import import sa L23–23
+ zlib import import zlib L18–18
+ test_push_rejected_when_quota_exceeded function async_function test_push_rejected_when_quota_exceeded L164–188
+ test_quota_counts_shared_object_per_repo function async_function test_quota_counts_shared_object_per_repo L48–111
+ test_quota_idempotent_push_no_double_count function async_function test_quota_idempotent_push_no_double_count L119–156
+ test_repo_stats_shared_object_per_repo function async_function test_repo_stats_shared_object_per_repo L228–257
+ test_repo_stats_uses_refs_join function async_function test_repo_stats_uses_refs_join L196–220
~ docs/db-query-runbook.md .md 1 symbol added, 1 symbol removed, 7 symbols modified
~ musehub/services/musehub_wire.py .py 1 symbol modified
← Older Oldest on task/phase4-quota-via-refs
All commits
Newer → Latest on task/phase4-quota-via-refs

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