gabriel / musehub public
feat patch task/profile-snapshot-precompute #1 / 1
AI Agent gabriel · 156 days ago · Apr 21, 2026 · Diff

feat: pre-compute profile snapshots via background worker

Phase 1 — MusehubProfileSnapshot ORM model (handle PK, data_json, computed_at, is_stale) + Alembic migration profile_snapshot_precompute.

Phase 2 — ProfileSnapshotProvider: computes stats, repos, heatmap, agent_fleet, badges, footprint, activity_canvas and upserts musehub_profile_snapshots. Special worker handler for profile.snapshot jobs (like gc).

Phase 3 — enqueue_profile_snapshot() in musehub_jobs.py; wired into musehub_wire.py push path alongside enqueue_push_intel.

Phase 4 — SSR profile route reads snapshot first (24-hour TTL); falls back to live computation on miss/stale and enqueues a refresh job inline.

Phase 5 — 11 TDD tests: ORM persistence, provider compute/upsert/idempotency, no-op for unknown handles, enqueue idempotency, SSR fast-path, stale fallback, missing fallback, HTML 200 with snapshot.

sha256:dd74be8aa38b823ad1f95ba71db8b38de35a20405f36b36c654a2266119663bb sha
+43 ~4 symbols
sha256:f26774be908fe6221ed603abea3b22438d86adc17034ba2e0ce4699f7617dcad snapshot
+43
symbols added
~4
symbols modified
0
dead code introduced
Semantic Changes 47 symbols
+ branch_labels variable variable branch_labels L19–19
+ depends_on variable variable depends_on L20–20
+ down_revision variable variable down_revision L18–18
+ downgrade function function downgrade L48–49
+ Union import import Union L12–12
+ annotations import import annotations L10–10
+ op import import op L15–15
+ sa import import sa L14–14
+ revision variable variable revision L17–17
+ upgrade function function upgrade L23–45
+ _seed_identity function async_function _seed_identity L36–52
+ _seed_repo function async_function _seed_repo L55–75
+ _seed_snapshot function async_function _seed_snapshot L78–103
+ AsyncClient import import AsyncClient L19–19
+ AsyncSession import import AsyncSession L21–21
+ MusehubBackgroundJob import import MusehubBackgroundJob L23–23
+ MusehubIdentity import import MusehubIdentity L23–23
+ MusehubProfileSnapshot import import MusehubProfileSnapshot L23–23
+ MusehubRepo import import MusehubRepo L23–23
+ annotations import import annotations L13–13
+ datetime import import datetime L16–16
+ json import import json L15–15
+ pytest import import pytest L18–18
+ select import import select L20–20
+ timezone import import timezone L16–16
+ test_compute_and_persist_snapshot function async_function test_compute_and_persist_snapshot L156–177
+ test_compute_and_persist_snapshot_missing_identity function async_function test_compute_and_persist_snapshot_missing_identity L202–213
+ test_compute_and_persist_snapshot_upserts function async_function test_compute_and_persist_snapshot_upserts L180–199
+ test_enqueue_profile_snapshot function async_function test_enqueue_profile_snapshot L221–241
+ test_enqueue_profile_snapshot_is_idempotent function async_function test_enqueue_profile_snapshot_is_idempotent L244–257
+ test_missing_snapshot_falls_back_to_live function async_function test_missing_snapshot_falls_back_to_live L305–316
+ test_profile_snapshot_provider_returns_empty function async_function test_profile_snapshot_provider_returns_empty L138–153
+ test_snapshot_html_route_serves_200 function async_function test_snapshot_html_route_serves_200 L319–329
+ test_snapshot_is_read_by_profile_route function async_function test_snapshot_is_read_by_profile_route L265–282
+ test_snapshot_table_is_queryable function async_function test_snapshot_table_is_queryable L111–130
+ test_stale_snapshot_triggers_fallback function async_function test_stale_snapshot_triggers_fallback L285–302
~ musehub/api/routes/musehub/ui_user_profile.py .py 2 symbols added, 1 symbol modified
+ _SNAPSHOT_MAX_AGE_HOURS variable variable _SNAPSHOT_MAX_AGE_HOURS L946–946
+ _load_profile_snapshot function async_function _load_profile_snapshot L949–973
~ musehub/db/musehub_models.py .py 1 symbol added
+ MusehubProfileSnapshot class class MusehubProfileSnapshot L1344–1370
~ musehub/services/musehub_intel_providers.py .py 3 symbols added, 1 symbol modified
+ ProfileSnapshotProvider class class ProfileSnapshotProvider L236–276
+ compute method async_method compute L256–276
+ _compute_and_persist_profile_snapshot function async_function _compute_and_persist_profile_snapshot L279–351
~ musehub/services/musehub_jobs.py .py 1 symbol added
+ enqueue_profile_snapshot function async_function enqueue_profile_snapshot L123–135
~ musehub/worker.py .py 1 symbol modified
← Older Oldest on task/profile-snapshot-precompute
All commits
Newer → Latest on task/profile-snapshot-precompute

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