Repository navigation
fix(serve): skip the redundant tail build_index on the adopt path - #359
Merged
Merged
Conversation
POST /repos adoption runs perform_incremental_refresh_with_stores, which already rebuilds the HNSW once after its last batch under the job gate (manager.rs), and leaves the existing valid graph untouched when nothing changed. The add-repo task tail then re-acquired a permit and called build_index() again - a second full graph build per adopted registration, serialized behind the process-wide job gate, for an identical result. That tail is load-bearing only on the force path (force_reindex builds no HNSW internally), so it now runs only there. Closes the Design finding from the PR #357 audit ledger (audit/audit.md). No dedicated test: the observable difference is work done, not resulting state - the adopt e2e (chunk/file survival) passes unchanged, which is exactly the equivalence this fix must preserve.
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.
Problem
Follow-up to #357, from its audit ledger (audit/audit.md, Design finding): on the
POST /reposadoption path the add-repo task tail re-acquired a job permit and calledbuild_index()again afterperform_incremental_refresh_with_storeshad already completed.Why it is redundant on adopt
The incremental refresh already rebuilds the HNSW graph once after its last batch, under the same process-wide job gate (src/index/manager.rs,
build the HNSW index once, after every batch has been inserted). When nothing changed it leaves the existing valid graph untouched. The tail build is load-bearing only on the force path —force_reindex_with_storesbuilds no HNSW internally.Fix
Wrap the tail permit-acquire +
build_index()inif !adopt_existing. The pre-restart_fsw liveness re-check stays on both paths; the cancellation-aware permit semantics on the force path are unchanged.Tests
The adopt e2e (
add_repo_handler_adopts_existing_index_instead_of_rebuilding) and the otheradd_repo_handler_*tests pass unchanged — the observable difference is work done, not resulting state, which is the equivalence this fix must preserve. clippy-D warningsandcargo fmt --checkclean; pre-push QC gate green.