Skip to content

[MOD-14957] Normalize FLAT overwrites (1/3) - #1034

Open
dor-forer wants to merge 1 commit into
mainfrom
dor-forer-fix-flat-cosine-overwrite
Open

[MOD-14957] Normalize FLAT overwrites (1/3)#1034
dor-forer wants to merge 1 commit into
mainfrom
dor-forer-fix-flat-cosine-overwrite

Conversation

@dor-forer

@dor-forer dor-forer commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

Single-value FLAT overwrites bypassed storage preprocessing. A cosine vector such as [2, 2, 2, 2] could replace an existing vector without being normalized. Run the replacement through preprocessForStorage, as insertion already does, while keeping the label's internal ID.

Stack 1/3, based on main. #1035 adds tiered SQ8 with an immediate backend; #1029 adds accumulation and deferred backend creation on top. Merge #1034, then #1035, then #1029.

Which issues this PR fixes

Main objects this PR modified

  • BruteForceIndex_Single::addVector and its cosine overwrite regression test.

Validation

Built and tested on SSH dorer-intel at c26aa251: all 138 test_bruteforce tests passed, including the new regression. No local build was run.

GitHub validation checked on 2026-09-07: the sanitizer check passed. The coverage job failed after its self-hosted runner lost contact with GitHub. The underlying cause is not yet diagnosed, and coverage validation remains incomplete.

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Note

Low Risk
Small, localized fix to the overwrite branch in BruteForceIndex_Single::addVector; behavior aligns with existing insert preprocessing and is covered by a new regression test.

Overview
Single-label brute-force (FLAT) updates now run replacement vectors through preprocessForStorage before updateElement, matching the insert path in appendVector. Previously, re-adding under an existing label wrote raw input, so cosine indexes could store unnormalized values and return wrong distances.

A unit test asserts that overwriting a cosine label with [2,2,2,2] leaves one normalized vector in storage.

Reviewed by Cursor Bugbot for commit 22533ce. Bugbot is set up for automated code reviews on this repo. Configure here.

@dor-forer
dor-forer force-pushed the dor-forer-fix-flat-cosine-overwrite branch from c26aa25 to 22533ce Compare September 8, 2026 15:48
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.42%. Comparing base (fd9fe8d) to head (22533ce).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1034      +/-   ##
==========================================
+ Coverage   97.40%   97.42%   +0.02%     
==========================================
  Files         141      141              
  Lines        8698     8699       +1     
==========================================
+ Hits         8472     8475       +3     
+ Misses        226      224       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants