gabriel / musehub public
feat BREAKING security task/stream-security-phase2 #1 / 1
AI Agent gabriel · 125 days ago · May 11, 2026 · Diff

feat(security): daily byte limit + accounting in stream path — Phase 2 of issue #51

Pre-check: wire_push_stream now accepts identity_id; on entry (after auth, before the frame loop) it reads musehub_daily_push_bytes for today and yields an ERROR frame (429-equivalent) if bytes_today >= bundle_daily_upload_limit_bytes.

Accounting: _stream_bytes_received accumulates len(raw_content) for every object frame accepted; record_bundle_bytes_uploaded is called on successful push completion so the counter reflects both presign and stream pushes.

The route (wire.py) passes claims.identity_id as the new keyword arg.

4 TDD tests green (test_stream_security_phase2.py); 70 regression tests (test_wire_push_stream + phase1) still pass.

sha256:f5873efcc9d23e7b1d00f7ddce5ab0b559959aaa1ccb05b5b7ec3bf86cdb37dd sha
+36 ~2 symbols
sha256:cef10b0b820cf9df274b6a5d5a0aea9d1854fc6de7b4772a24590506e12cdd4f snapshot
+36
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 38 symbols
~ tests/test_stream_security_phase2.py .py 36 symbols added
+ _IDENTITY_A variable variable _IDENTITY_A L42–42
+ _IDENTITY_B variable variable _IDENTITY_B L43–43
+ _collect function async_function _collect L93–97
+ _commit_pack function function _commit_pack L71–74
+ _end function function _end L77–78
+ _fw variable variable _fw L40–40
+ _header function function _header L56–61
+ _make_commit function function _make_commit L81–90
+ _make_repo function async_function _make_repo L102–124
+ _obj function function _obj L64–68
+ _pack function function _pack L48–49
+ _stub_backend function function _stub_backend L127–145
+ _wrap function function _wrap L52–53
+ AsyncMock import import AsyncMock L25–25
+ AsyncSession import import AsyncSession L24–24
+ MuseWireFrameWriter import import MuseWireFrameWriter L38–38
+ MusehubBranch import import MusehubBranch L29–29
+ MusehubRepo import import MusehubRepo L29–29
+ SFRAME_COMMIT_PACK import import SFRAME_COMMIT_PACK L30–30
+ SFRAME_END import import SFRAME_END L30–30
+ SFRAME_ERROR import import SFRAME_ERROR L30–30
+ SFRAME_HEADER import import SFRAME_HEADER L30–30
+ SFRAME_OBJECT import import SFRAME_OBJECT L30–30
+ SFRAME_RESULT import import SFRAME_RESULT L30–30
+ annotations import import annotations L17–17
+ blob_id import import blob_id L27–27
+ datetime import import datetime L19–19
+ db import import db L28–28
+ msgpack import import msgpack L21–21
+ now_utc_iso import import now_utc_iso L27–27
+ pytest import import pytest L22–22
+ select import import select L23–23
+ test_daily_limit_is_per_user_stream function async_function test_daily_limit_is_per_user_stream L284–324
+ test_stream_push_increments_daily_bytes function async_function test_stream_push_increments_daily_bytes L153–204
+ test_stream_push_over_daily_limit_yields_error function async_function test_stream_push_over_daily_limit_yields_error L208–244
+ test_stream_push_under_daily_limit_completes function async_function test_stream_push_under_daily_limit_completes L248–280
~ musehub/api/routes/wire.py .py 1 symbol modified
← Older Oldest on task/stream-security-phase2
All commits
Newer → Latest on task/stream-security-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:f5873efcc9d23e7b1d00f7ddce5ab0b559959aaa1ccb05b5b7ec3bf86cdb37dd --body "your comment"