mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-09-12 04:01:35 +00:00
* fix(vector-store): prevent in-memory vector id reuse * fix(vector-store): synchronize in-memory mutations * fix(vector-store): clarify no-silent-overwrite guarantee for in-memory ID generation The while-loop in store_vectors() already prevents any generated candidate from landing on a live key: it breaks only when the candidate is absent from both pre_existing (the live store at lock-entry) and within_batch (IDs chosen earlier in the same call). This commit: - Renames 'existing' to 'pre_existing' and introduces 'within_batch' to make the two-level de-dupe explicit and self-documenting. - Tightens the break condition to 'not in pre_existing and not in within_batch' so within-batch duplicates are also guarded. - Adds test_auto_generated_id_never_silently_overwrites_live_vector: stores 5, deletes 3, stores 2 more and asserts none of the new IDs land on a surviving vec_N. - Adds test_collision_detection_no_silent_overwrite_even_with_corrupted_counter: rewinds _next_id to 0 with live vectors present and proves the loop finds a free slot without overwriting either existing vector or its metadata — the no-silent-overwrite invariant holds even under counter corruption. The skip-over-occupied-key behaviour for caller-inserted vec_N IDs is intentional and preserved (test_counter_skips_explicit_vec_n_ids), matching FAISSStore's identical pattern. Closes reviewer finding: 'Vector collisions do not fail writes'. * fix(vector-store): protect concurrent in-memory access --------- Co-authored-by: Sameer Kadam <sameerkadam@Mac.lan> Co-authored-by: Zohaib Hassnain <109234410+ZohaibHassan16@users.noreply.github.com>