gabriel / musehub public
fix patch task/genesis-ops-backfill #1 / 1
AI Agent gabriel · 134 days ago · May 4, 2026 · Diff

fix: correct genesis op indexing and backfill missing content_ids from snapshots

Three-part fix for the genesis provenance timeline:

1. backfill_genesis_ops — sets op='add' on the oldest history entry for every symbol where the genesis bug caused it to be recorded as 'modify'. Ran on localhost: corrected 7,365 birth entries. Deploy script at deploy/backfill_genesis_ops.py.

2. backfill_content_ids_from_snapshots — fills missing content_id values on file-level history entries by reading the canonical source (snapshot manifests). Covers move/rename ops where the indexer recorded no new_content_id. Ran on localhost: filled 2,578 entries. Deploy script at deploy/backfill_content_ids_from_snapshots.py.

3. ui_symbols.py version boundary fix — replaces prev_cid is not None guard with entry_idx > 0 so the first real body is always flagged as a version boundary even when the birth entry has no content_id.

Tests: 6 tests for backfill_genesis_ops, 8 tests for backfill_content_ids_from_snapshots — all green.

sha256:f3fe82ccf0a82f7b44f8f25d4c0dfff00583525ce318c439557087f48c7d6e40 sha
+50 ~1 symbols
sha256:b5a24573403bf7478eab5a8f2bcc5b5ce4f4f27c3b7905d85d2226271e89ee34 snapshot
+50
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 51 symbols
+ AsyncSession import import AsyncSession L38–38
+ annotations import import annotations L30–30
+ argparse import import argparse L32–32
+ asyncio import import asyncio L33–33
+ backfill_content_ids_from_snapshots import import backfill_content_ids_from_snapshots L46–46
+ create_async_engine import import create_async_engine L38–38
+ db import import db L45–45
+ get_database_url import import get_database_url L44–44
+ sa import import sa L37–37
+ sessionmaker import import sessionmaker L39–39
+ sys import import sys L34–34
+ time import import time L35–35
+ main function function main L76–84
+ run function async_function run L49–73
~ deploy/backfill_genesis_ops.py .py 14 symbols added
+ AsyncSession import import AsyncSession L40–40
+ annotations import import annotations L32–32
+ argparse import import argparse L34–34
+ asyncio import import asyncio L35–35
+ backfill_genesis_ops import import backfill_genesis_ops L48–48
+ create_async_engine import import create_async_engine L40–40
+ db import import db L47–47
+ get_database_url import import get_database_url L46–46
+ sa import import sa L39–39
+ sessionmaker import import sessionmaker L41–41
+ sys import import sys L36–36
+ time import import time L37–37
+ main function function main L78–86
+ run function async_function run L51–75
~ musehub/api/routes/musehub/ui_symbols.py .py 1 symbol added, 1 symbol modified
+ difflib import import difflib L11–11
+ backfill_content_ids_from_snapshots function async_function backfill_content_ids_from_snapshots L760–860
+ backfill_genesis_ops function async_function backfill_genesis_ops L676–753
~ tests/test_snapshot_symbol_indexer.py .py 19 symbols added
+ TestBackfillContentIdsFromSnapshots class class TestBackfillContentIdsFromSnapshots L1169–1468
+ _seed_missing_entry method async_method _seed_missing_entry L1210–1229
+ _seed_snapshot_and_commit method async_method _seed_snapshot_and_commit L1173–1208
+ test_corrupt_manifest_blob_is_skipped_gracefully method async_method test_corrupt_manifest_blob_is_skipped_gracefully L1423–1468
+ test_dry_run_returns_count_without_writing method async_method test_dry_run_returns_count_without_writing L1232–1258
+ test_fills_content_id_from_manifest method async_method test_fills_content_id_from_manifest L1261–1286
+ test_idempotent method async_method test_idempotent L1404–1420
+ test_repo_id_none_fills_all_repos method async_method test_repo_id_none_fills_all_repos L1380–1401
+ test_skips_entries_already_with_content_id method async_method test_skips_entries_already_with_content_id L1317–1351
+ test_skips_entry_when_path_absent_from_manifest method async_method test_skips_entry_when_path_absent_from_manifest L1354–1377
+ test_skips_symbol_level_addresses method async_method test_skips_symbol_level_addresses L1289–1314
+ TestBackfillGenesisOps class class TestBackfillGenesisOps L1006–1162
+ _seed_bad_birth method async_method _seed_bad_birth L1010–1030
+ test_corrects_modify_to_add method async_method test_corrects_modify_to_add L1055–1073
+ test_dry_run_returns_count_without_writing method async_method test_dry_run_returns_count_without_writing L1033–1052
+ test_idempotent method async_method test_idempotent L1151–1162
+ test_only_corrects_oldest_entry_not_later_modifies method async_method test_only_corrects_oldest_entry_not_later_modifies L1087–1133
+ test_repo_id_none_corrects_all_repos method async_method test_repo_id_none_corrects_all_repos L1136–1148
+ test_skips_entries_already_add method async_method test_skips_entries_already_add L1076–1084
← Older Oldest on task/genesis-ops-backfill
All commits
Newer → Latest on task/genesis-ops-backfill

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