gabriel / musehub public
feat patch task/snapshot-diff-backfill #1 / 1
AI Agent gabriel · 136 days ago · May 4, 2026 · Diff

feat: backfill_history_from_snapshots — infer full op history from snapshot diffs

For commits never covered by structured_delta, diffs adjacent snapshot manifests to reconstruct insert/replace/delete/move ops for every file.

Algorithm: - Walk all commits oldest-first - Diff child manifest vs parent manifest (or empty for genesis) - Unambiguous rename: one removed + one added path share same object_id → move - Ambiguous (multiple candidates): fall back to insert + delete - Skip (repo_id, address, commit_id) pairs already in history table - Mark inferred entries: op_payload.inferred_from = 'snapshot_diff'

This recovers symbol history for files that predate structured_delta indexing (e.g. static/js/app.ts before the src/ts migration).

Tests (12 in TestBackfillHistoryFromSnapshots): genesis_all_inserts, new_file_is_insert, changed_content_is_replace, removed_file_is_delete, unambiguous_rename_is_move, ambiguous_rename_falls_back, skips_existing_entries, unchanged_files_no_entries, dry_run, idempotent, repo_id_filter, inferred_op_payload_marks_source

sha256:661a8359960bf93cb7bff10f15c16f8df25f666114518c982ca9ec2cb9c2099a sha
+30 symbols
sha256:44cc00ff0a5c2b6e9a815a93b3c5933a29668f8ccf3bbeb9fdc587573d6d3972 snapshot
+30
symbols added
0
dead code introduced
Semantic Changes 30 symbols
+ AsyncSession import import AsyncSession L19–19
+ annotations import import annotations L12–12
+ argparse import import argparse L14–14
+ asyncio import import asyncio L15–15
+ backfill_history_from_snapshots import import backfill_history_from_snapshots L23–23
+ create_async_engine import import create_async_engine L19–19
+ get_database_url import import get_database_url L22–22
+ sessionmaker import import sessionmaker L20–20
+ sys import import sys L16–16
+ time import import time L17–17
+ main function function main L44–55
+ run function async_function run L26–41
+ _Manifest variable variable _Manifest L963–963
+ _diff_manifests function function _diff_manifests L966–1027
+ backfill_history_from_snapshots function async_function backfill_history_from_snapshots L1030–1144
~ tests/test_snapshot_symbol_indexer.py .py 15 symbols added
+ TestBackfillHistoryFromSnapshots class class TestBackfillHistoryFromSnapshots L1959–2269
+ test_ambiguous_rename_falls_back_to_insert_delete method async_method test_ambiguous_rename_falls_back_to_insert_delete L2098–2127
+ test_changed_content_is_replace method async_method test_changed_content_is_replace L2013–2037
+ test_dry_run_returns_count_without_writing method async_method test_dry_run_returns_count_without_writing L2187–2206
+ test_genesis_commit_all_inserts method async_method test_genesis_commit_all_inserts L1965–1982
+ test_idempotent method async_method test_idempotent L2209–2221
+ test_inferred_op_payload_marks_source method async_method test_inferred_op_payload_marks_source L2250–2269
+ test_new_file_in_child_is_insert method async_method test_new_file_in_child_is_insert L1985–2010
+ test_removed_file_is_delete method async_method test_removed_file_is_delete L2040–2064
+ test_repo_id_filter method async_method test_repo_id_filter L2224–2247
+ test_skips_addresses_already_covered_by_structured_delta method async_method test_skips_addresses_already_covered_by_structured_delta L2130–2157
+ test_unambiguous_rename_is_move method async_method test_unambiguous_rename_is_move L2067–2095
+ test_unchanged_files_produce_no_entries method async_method test_unchanged_files_produce_no_entries L2160–2184
+ _seed_commit_with_snapshot function async_function _seed_commit_with_snapshot L1914–1956
+ msgpack import import msgpack L1911–1911
← Older Oldest on task/snapshot-diff-backfill
All commits
Newer → Latest on task/snapshot-diff-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:661a8359960bf93cb7bff10f15c16f8df25f666114518c982ca9ec2cb9c2099a --body "your comment"