gabriel / musehub public
feat patch mwp4/phase2 task/mwp-4-prebuild-after-index #4 / 6
AI Agent gabriel · 22 days ago · Jun 29, 2026 · Diff

feat(mwp4/phase2): claim-layer dependency barrier in claim_next_job

Add correlated NOT EXISTS barrier: fetch.mpack.prebuild is not claimable while any mpack.index for the same repo_id is pending or running.

Implementation: aliased subquery on MusehubBackgroundJob joined by repo_id, filtered to job_type='mpack.index' and status IN ('pending','running'). The EXISTS check is read-only; FOR UPDATE SKIP LOCKED locks only the outer selected row — no extra lock contention.

MWP4_04 GREEN: barrier blocks prebuild while index is pending (was MWP4_01 RED). MWP4_05 GREEN: done index does not gate the prebuild. MWP4_06 GREEN: running index gates the prebuild (claim returns None). MWP4_07 GREEN: failed/quarantined index does not gate the prebuild. MWP4_08 GREEN: barrier is scoped per repo_id — no cross-repo blocking. MWP4_09 GREEN: only fetch.mpack.prebuild is filtered; all other types unaffected. MWP4_01 GREEN: original RED test now passes with the barrier in place. 9/9 MWP4 tests green. 36 adjacent tests green, zero regressions.

Issue: musehub#109, master: muse#58

sha256:9e522d1d8fdb969514e26b71d13470b8f18e67ad010084764d67c1ac08b779de sha
+10 ~5 −1 symbols
sha256:897db74c5692d3c344941ca4d1a80ac781a8a93b501d36de94581c02ec9d4c44 snapshot
+10
symbols added
~5
symbols modified
−1
symbol removed
0
dead code introduced
Semantic Changes 16 symbols
~ docs/issues/mwp-4-prebuild-after-index.md .md 1 symbol added, 1 symbol removed, 2 symbols modified
Phase 2 — claim-layer dependency barrier (load-bearing) section Phase 2 — claim-layer dependency barrier (load-bearing) L263–283
+ Phase 2 — claim-layer dependency barrier (load-bearing) ✅ COMPLETE section Phase 2 — claim-layer dependency barrier (load-bearing) ✅ COMPLETE L263–287
~ Phases
~ musehub/services/musehub_jobs.py .py 3 symbols added, 3 symbols modified
+ aliased import import aliased L36–36
+ and_ import import and_ L35–35
+ exists import import exists L35–35
~ select
~ update
~ tests/test_mwp4_prebuild_ordering.py .py 6 symbols added
+ test_mwp4_04_prebuild_not_claimed_while_index_pending function async_function test_mwp4_04_prebuild_not_claimed_while_index_pending L439–477
+ test_mwp4_05_prebuild_claimable_after_index_done function async_function test_mwp4_05_prebuild_claimable_after_index_done L481–515
+ test_mwp4_06_prebuild_blocked_while_index_running function async_function test_mwp4_06_prebuild_blocked_while_index_running L519–558
+ test_mwp4_07_terminal_index_does_not_block_prebuild function async_function test_mwp4_07_terminal_index_does_not_block_prebuild L562–604
+ test_mwp4_08_barrier_is_per_repo function async_function test_mwp4_08_barrier_is_per_repo L608–658
+ test_mwp4_09_barrier_does_not_affect_other_job_types function async_function test_mwp4_09_barrier_does_not_affect_other_job_types L662–703

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