Skip to content

fix(pinecone): accept tie-level search reordering when qualifying partition copies - #24400

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/pinecone-search-parity-tolerance
Nov 2, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/pinecone-search-parity-tolerance

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why

The Pinecone owner-partition operator (#24315) ends each qualification by querying the owner's old
namespace and new bucket with a few of the owner's own vectors, and it required the two top-10 ID lists to
be identical in order. Pinecone scores the same record slightly differently in different namespaces, so
near-tied neighbours swap and the operator refuses copies that are complete and exactly verified.

Measured on memories-backend-dev with a loopback Firestore emulator and synthetic owners (dense random
3072-d vectors), after a complete copy whose payload digests all matched:

records probes with exact order same ID set same-ID score delta smallest adjacent gap
3 qualified
120 10/12 12/12 1.8-3.8e-4 2.8e-5
230 8/12 11/12 (one swap at the rank-10 cutoff) 1.8-4.0e-4 4e-6

The odds of a near-tie in a top-10 rise with an owner's vector count, so the check blocks exactly the
heavy owners whose queries cost the most. Production shows the same signature: the 11-02 rollout journal
recorded 29 bounded_search_convergence mismatches, and those 29 keys are exactly the routes it left in
qualification_failed.

What changes

  • search_parity() replaces the exact list comparison. IDs present in both lists must score within 1e-3
    (2.5x the largest drift measured). An ID may appear in only one list solely at the cutoff, tied with the
    other list's lowest score. Two IDs may rank in opposite order only when their scores are within 1e-3.
    Anything else still raises MigrationNotReady. query_checks records whether the order was exact.
  • The exact payload, inventory, freshness and revision checks are unchanged; they already prove every
    record byte-for-byte. This check only bounds ranking drift.
  • The operator CLI keeps the reason text of MigrationNotReady / PartitionConflict in receipts and owner
    journals. These are fixed strings from our own code, never provider text, and without them a failed batch
    can't be diagnosed.
  • The test provider fake now scores by dot product (it returned a constant 0.9, which made every order a
    tie) with per-namespace score jitter.

Only scripts/migrate_pinecone_partitions.py and scripts/qualify_pinecone_partitions.py import this
module. Serving code and every deployed runtime are unchanged, so no deploy is needed.

Verification

  • backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST = test_pinecone_partition_migration.py: 52 passed,
    including the new near-tie, drift and search_parity cases. The existing reversed-order case still fails
    closed.
  • test_migrate_pinecone_partitions.py: 23 passed. test_qualification_script_direct_execution_reaches_safety_gate
    timed out locally: the script reaches the expected gate error, but takes about 10s of wall time on a host at
    load 60 (about 1s CPU). That script is untouched here.
  • Dev qualification of this exact commit (6882b36) against memories-backend-dev with a loopback Firestore
    emulator, all steps passed (2026-11-02 14:59Z): qualify_pinecone_partitions.py (7 families x 3
    migrate/update/rollback cycles with a shared-bucket owner, cleanup verified); the operator CLI end to end on
    two colliding synthetic owners with 2-230 dense vectors per family (inventory, budget stop then --resume,
    apply, serving write after cutover, rollback, re-apply, idempotent rerun, cleanup verified); and the opt-in
    action-item user-path test (run with a deterministic local embedding in place of OpenAI, because this lane
    holds no OpenAI key; the router, Firestore, owner routing, migration and Pinecone calls were real). Before this change the same CLI run refused 6 of 7 families with
    Search result order differs.

Product invariants: none (operator-only module).

Failure-Class: none

Rationale: this is a parity-check tolerance in an operator tool, not a recurrence of a catalogued
serving failure class. The nearest entries (FC-split-mutation-authority, FC-test-double-accepts-payload-store-rejects)
do not describe it: the fake's constant score did hide the defect, but it accepted too little, not a payload
production rejects.

🤖 Generated with Claude Code

…tition copies

The partition operator compared the old namespace's and the new bucket's
top-10 IDs for exact order. Pinecone scores the same record slightly
differently in different namespaces (2-4e-4 measured on the dev index), so
near-tied neighbours swap and the check rejected complete, verified copies.
The chance grows with the owner's vector count, so heavy owners, whose
queries cost the most, could not be migrated.

Search parity now requires shared IDs to score within 1e-3, allows an ID in
only one list solely at the cutoff when tied with the other list's lowest
score, and allows opposite ranking only between pairs tied within 1e-3.
Exact payload and inventory parity are unchanged. The operator also keeps
the fixed reason text of MigrationNotReady/PartitionConflict in receipts and
journals; those messages are static strings from our own code.

Only the operator scripts import this module; serving code is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Confidence score: 3/5

  • A NaN provider score makes the parity comparison evaluate false, so backend/database/pinecone_partition_migration.py can accept mismatched or reversed results. Reject non-finite scores before the parity checks.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/database/pinecone_partition_migration.py">

<violation number="1" location="backend/database/pinecone_partition_migration.py:76">
P1: Non-finite provider scores bypass every parity check: `float('nan')` makes `abs(...) > tolerance` false, so a NaN score can qualify even when its counterpart differs or the order is reversed. Reject scores with `math.isfinite` before comparing them.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

the order was exactly identical.
"""
try:
old_scores = {match['id']: float(match['score']) for match in old}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Non-finite provider scores bypass every parity check: float('nan') makes abs(...) > tolerance false, so a NaN score can qualify even when its counterpart differs or the order is reversed. Reject scores with math.isfinite before comparing them.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/database/pinecone_partition_migration.py, line 76:

<comment>Non-finite provider scores bypass every parity check: `float('nan')` makes `abs(...) > tolerance` false, so a NaN score can qualify even when its counterpart differs or the order is reversed. Reject scores with `math.isfinite` before comparing them.</comment>

<file context>
@@ -58,6 +58,45 @@ def normalize(value: Any) -> Any:
+    the order was exactly identical.
+    """
+    try:
+        old_scores = {match['id']: float(match['score']) for match in old}
+        new_scores = {match['id']: float(match['score']) for match in new}
+    except (KeyError, TypeError, ValueError) as error:
</file context>

@Git-on-my-level
Git-on-my-level merged commit a69ddcb into main Nov 2, 2026
83 of 86 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/pinecone-search-parity-tolerance branch November 2, 2026 15:31
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.

1 participant