fix(git-history): prune orphaned commit vectors on HEAD rewinds#59
Merged
Conversation
Detect non-fast-forward HEAD moves in upload clients and emit snapshot git-history manifests (mode=snapshot). Tag commit points with git_history_run_id and, on snapshot ingests, delete older git_message points for the same repo that are not part of the latest run to avoid orphaned commit metadata after reset/force-push. Also add optional cleanup for .remote-git/git_history_*.json manifests via env (GIT_HISTORY_DELETE_MANIFEST / GIT_HISTORY_MANIFEST_MAX_FILES) and document the new knobs in .env.example.
Relaxes the type hint for the `model` parameter in the `_ingest_from_manifest` function. This change allows the function to accept a wider range of model types, promoting flexibility and avoiding potential type-related issues.
… ops When the watch loop detects no filesystem changes, still collect git history and upload a git-history-only delta bundle when HEAD/ref movement is detected. This ensures commit/undo operations emit git_history manifests so watcher can ingest and prune snapshot rewrites.
Contributor
Author
|
Confirmed working, orphaned commits are pruned. Need to write a pytest and bump extension version |
m1rl0k
added a commit
that referenced
this pull request
Mar 1, 2026
fix(git-history): prune orphaned commit vectors on HEAD rewinds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prunes orphaned git commit vectors in Qdrant when a non–fast-forward move of
HEADis detected (e.g., reset or force-push). Upload clients emit snapshot manifests on such events, points are tagged with a per-run identifier, and older commit metadata not in the latest snapshot is removed. Optional cleanup of localgit_history_*.jsonmanifests is included.Problem
After a
git resetor force-push, previous commit vectors can remain indexed even though those commits are no longer reachable. This creates stale search results and inconsistent commit timelines.Solution
git merge-base --is-ancestorand automatically switch tomode=snapshotfor the next upload.metadata.git_history_run_idandmetadata.git_history_mode.git_messagepoints for the same repo whosegit_history_run_iddoes not match the latest run..remote-git/git_history_*.jsonmanifests:Key Changes
modetosnapshotordelta.head,prev_head,base_headingit_history.json.upload_git_history_only(...)for cases with no file changes but updated history.git_history_run_idandgit_history_mode._prune_old_commit_points(...)deletes oldergit_messagevectors on snapshot ingest (guarded by env)._cleanup_manifest_files(...)deletes current manifest and enforces a max file retention, if configured.delta.GIT_HISTORY_PRUNE.Configuration
git_messagepoints.git_history_*.jsonmanifest(s) after successful ingest..remote-gitdir by mtime (0 disables).