gabriel / musehub public
test bundle dev
AI Agent gabriel · 124 days ago · May 11, 2026 · Diff

test(bundle): Phase 3 idempotency and retry safety — 3 new TDD tests

Proves that process_bundle_index_job is fully retry-safe:

1. test_partial_minio_failure_retry_produces_correct_state — simulates a worker crash after 2 MinIO PUTs, rolls back the session, retries from scratch. All objects land in MinIO and DB with correct state (no orphan content_cache, no pending storage_uri).

2. test_worker_full_lifecycle_pending_to_done — exercises the full worker path: claim_next_job (pending→running), process_bundle_index_job, complete_job (→done). Verifies status transitions and done_at timestamp.

3. test_failed_job_resets_to_pending_for_retry — fail_job resets status to 'pending' for attempt < max (3). Retry claim increments attempt, retry run succeeds, final status is 'done'.

All three tests pass immediately — the ON CONFLICT DO UPDATE promotion, session rollback safety, and existing worker machinery (claim/fail/complete) already satisfy all Phase 3 invariants built during Phases 1 and 2.

sha256:bc2c5208155b1350ca6a5d3caa3a16f1eb1b8ed4b2467f0dc7fb4b833c4f5a99 sha
+44 symbols
sha256:10590e2b4c6836d0a1faf9e59aa678c8e607ea037ecc9103627f15fba7792f32 snapshot
+44
symbols added
0
dead code introduced
Semantic Changes 44 symbols
~ tests/test_bundle_index_job_phase3.py .py 44 symbols added
+ _AUTH_CTX variable variable _AUTH_CTX L49–54
+ _BLOB_SIZE variable variable _BLOB_SIZE L59–59
+ _FILES_CHANGED variable variable _FILES_CHANGED L58–58
+ _N_COMMITS variable variable _N_COMMITS L57–57
+ _N_FILES variable variable _N_FILES L56–56
+ _make_repo function function _make_repo L94–151
+ _push_bundle function async_function _push_bundle L154–185
+ client function async_function client L65–79
+ ASGITransport import import ASGITransport L25–25
+ AsyncClient import import AsyncClient L25–25
+ AsyncMock import import AsyncMock L28–28
+ AsyncSession import import AsyncSession L27–27
+ CommitRecord import import CommitRecord L39–39
+ MSignContext import import MSignContext L30–30
+ SnapshotRecord import import SnapshotRecord L39–39
+ annotations import import annotations L15–15
+ app import import app L33–33
+ asyncio import import asyncio L17–17
+ blob_id import import blob_id L46–46
+ build_mpack import import build_mpack L36–36
+ compute_commit_id import import compute_commit_id L38–38
+ compute_snapshot_id import import compute_snapshot_id L38–38
+ datetime import import datetime L18–18
+ db import import db L31–31
+ func function import func L26–26
+ get_db import import get_db L32–32
+ hashlib import import hashlib L19–19
+ msgpack import import msgpack L22–22
+ muse_dir import import muse_dir L37–37
+ optional_signed_request import import optional_signed_request L30–30
+ patch import import patch L28–28
+ pathlib import import pathlib L20–20
+ pytest import import pytest L23–23
+ pytest_asyncio import import pytest_asyncio L24–24
+ require_signed_request import import require_signed_request L30–30
+ select import import select L26–26
+ write_branch_ref import import write_branch_ref L39–39
+ write_commit import import write_commit L39–39
+ write_object import import write_object L35–35
+ write_snapshot import import write_snapshot L39–39
+ repo function async_function repo L83–91
+ test_failed_job_resets_to_pending_for_retry function async_function test_failed_job_resets_to_pending_for_retry L326–400
+ test_partial_minio_failure_retry_produces_correct_state function async_function test_partial_minio_failure_retry_produces_correct_state L191–264
+ test_worker_full_lifecycle_pending_to_done function async_function test_worker_full_lifecycle_pending_to_done L268–322
← Older Oldest on dev
All commits
Newer → Latest on dev

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