gabriel / musehub public

0078_add_superseded_at_to_background_jobs.py file-level

at sha256:3 · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:1 fix: getting-started page's muse --version sample output showed musehub… · gabriel · Oct 23, 2026
1 """Add superseded_at to musehub_background_jobs
2
3 musehub#108 (MWP9): dedup for self-coalescing job types (fetch.mpack.prebuild)
4 now treats an already-'running' row as covering a new trigger, on the
5 assumption that the running job will read fresh data before finishing. That
6 assumption breaks when the running job's data read already started before
7 the new trigger's write landed -- confirmed live: a bulk commit-signature
8 repair batch landed 20 fixes, but a concurrently-running prebuild job's read
9 only captured 1 of them, serving a stale cached mpack to the next clone
10 until a later, unrelated trigger happened to catch up.
11
12 superseded_at lets enqueue_job flag a running row when a new trigger arrives
13 for it, and lets the job's own handler (process_fetch_mpack_prebuild_job)
14 check that flag after building and redo the build once more before marking
15 done, instead of finishing with stale coverage.
16
17 Additive and nullable -- existing/historical rows get NULL (never superseded).
18
19 Revision ID: 0078
20 Revises: 0077
21 """
22 from __future__ import annotations
23
24 from typing import Sequence, Union
25
26 import sqlalchemy as sa
27 from alembic import op
28
29
30 # revision identifiers, used by Alembic.
31 revision: str = '0078'
32 down_revision: Union[str, None] = '0077'
33 branch_labels: Union[str, Sequence[str], None] = None
34 depends_on: Union[str, Sequence[str], None] = None
35
36
37 def upgrade() -> None:
38 op.add_column(
39 'musehub_background_jobs',
40 sa.Column('superseded_at', sa.DateTime(timezone=True), nullable=True),
41 )
42
43
44 def downgrade() -> None:
45 op.drop_column('musehub_background_jobs', 'superseded_at')