gabriel / musehub public
fix BREAKING fix/prebuild-supersede-retry #1 / 1
AI Agent gabriel · 20 hours ago · Oct 21, 2026 · Diff

fix: fetch.mpack.prebuild rebuilds when superseded mid-build

Found live during the Bug B bulk commit-signature repair (musehub#108): a single coalesced prebuild job was already mid-build when 20 repair-commit calls landed; only 1 of 20 made it into the job's cached mpack, because its data read had started before the other 19 writes committed. The next fresh clone served that stale-but-cached mpack, silently missing 19 real repairs even though every one of them was correctly persisted server-side (verified directly against musehub_commits -- the repair script and wire_repair_commit are not at fault here).

This is the sharp edge of MWP9's own dedup fix: treating a 'running' fetch.mpack.prebuild as already covering a new trigger is only true if the running job's read happens *after* the trigger's write -- not guaranteed once a build can take 30-100+s.

Fix: enqueue_job now stamps superseded_at on the existing 'running' row when it dedup-skips a new trigger against it. process_fetch_mpack_prebuild_job checks its own superseded_at after each build attempt (bounded at 3 tries) and forces one more full rebuild if it was stamped during the build it just finished, before writing the final cache entry. A sustained stream of concurrent triggers can still exhaust the retry budget -- that's accepted and self-heals via the next unrelated trigger, same as any eventually- consistent cache.

Migration 0078 adds the nullable superseded_at column (additive, no backfill needed -- historical rows default to never-superseded).

sha256:388b0d5926748aed8e7b2941523f5fb2b6991d500eea4c3aac01c5e1e07d2d86 sha
+14 ~3 symbols
6 changed · 1085 in snapshot files
sha256:e923c36482ae6074308f43d943378048d1b1d5aee60203df9abd27281a6f3dee snapshot
+14
symbols added
~3
symbols modified
6
files changed
1085
files in snapshot
0
dead code introduced
Semantic Changes 17 symbols
+ branch_labels variable variable branch_labels L33–33
+ depends_on variable variable depends_on L34–34
+ down_revision variable variable down_revision L32–32
+ downgrade function function downgrade L44–45
+ Sequence import import Sequence L24–24
+ Union import import Union L24–24
+ annotations import import annotations L22–22
+ op import import op L27–27
+ sa import import sa L26–26
+ revision variable variable revision L31–31
+ upgrade function function upgrade L37–41
~ musehub/services/musehub_jobs.py .py 1 symbol modified
~ tests/test_fetch_mpack_prebuild.py .py 2 symbols added
+ test_mwp9_prebuild_does_not_rebuild_when_not_superseded function async_function test_mwp9_prebuild_does_not_rebuild_when_not_superseded L677–696
+ test_mwp9_prebuild_rebuilds_when_superseded_during_build function async_function test_mwp9_prebuild_rebuilds_when_superseded_during_build L598–673
+ test_mwp9_07_dedup_skip_against_running_job_stamps_superseded_at function async_function test_mwp9_07_dedup_skip_against_running_job_stamps_superseded_at L97–114
Files Changed
+1 ~5
1085 in snapshot
← Older Oldest on fix/prebuild-supersede-retry
All commits
Newer → Latest on fix/prebuild-supersede-retry

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