gabriel / musehub public
fix patch task/timing-instrumentation #4 / 5
AI Agent gabriel · 126 days ago · May 10, 2026 · Diff

fix: batch enqueue_push_intel from O(N) to O(1) DB round-trips

Phase 10 was adding ~1.4s to every push (18 sequential SELECT+INSERT pairs at ~80ms Docker postgres latency). Replace the per-job loop in enqueue_push_intel with a single SELECT … IN to find already-pending types, then session.add_all for the missing ones — two round-trips total regardless of job count.

Also remove autouse=True from _stub_push_background_tasks so tests declare their dependencies explicitly. test_push_enqueues_intel_jobs now opts in via an explicit fixture parameter; enqueue unit tests call the real implementation and verify DB state directly.

sha256:34844ccdc278ce0371354d4b298302848ce48f8399946af20d41dd7a1ef5d8cd sha
+16 ~3 symbols
sha256:c10f13af59dea93995b3c8d4410d84b1f42080ffecc98cd6719f07dba3d5dc2b snapshot
+16
symbols added
~3
symbols modified
0
dead code introduced
Semantic Changes 19 symbols
~ tests/test_enqueue_batch.py .py 16 symbols added
+ AsyncSession import import AsyncSession L26–26
+ annotations import import annotations L19–19
+ create_repo import import create_repo L31–31
+ db import import db L28–28
+ enqueue_profile_snapshot import import enqueue_profile_snapshot L29–29
+ enqueue_push_intel import import enqueue_push_intel L29–29
+ func function import func L25–25
+ inspect import import inspect L21–21
+ job_types_for_push import import job_types_for_push L30–30
+ pytest import import pytest L24–24
+ select import import select L25–25
+ time import import time L22–22
+ test_B1_no_enqueue_job_loop function function test_B1_no_enqueue_job_loop L38–62
+ test_B2_idempotent function async_function test_B2_idempotent L70–98
+ test_B3_fast function async_function test_B3_fast L106–119
+ test_B4_all_job_types_inserted function async_function test_B4_all_job_types_inserted L127–145

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