Skip to content

fix(vector): coalesce corpus loads and detach stale initializers - #5197

Merged
joelteply merged 2 commits into
canaryfrom
codex/shared-compute-fallible
Oct 20, 2026
Merged

joelteply merged 2 commits into
canaryfrom
codex/shared-compute-fallible

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Concurrent cold vector searches could query and parse the same collection repeatedly. A loader that started before invalidation could then republish its stale corpus. Use the existing SharedCompute cell lifecycle: callers share one successful immutable snapshot, invalidation detaches that cell, and late readers cannot republish it.

Add fallible initialization so query errors remain retryable and type mismatches reach the caller. Migrate index, explicit invalidation, backfill and stats together; move corpus loading to data/vector_corpus.rs. Missing successful query payloads now return errors. Existing f64 scoring is unchanged. This fixes cache ownership; it does not yet implement BLAS/cascade scoring or establish a live speed improvement.

Validation: Windows vector-filter tests 46 passed, 1 ignored; SharedCompute 8 passed (including fallible pending invalidation). Those runtime tests preceded integration of the already-validated cosine PR. Merged-tree source-hygiene 37/37 passed; baselines fall to 157513 excess lines and 2128 unjustified unwraps. Exact-head CI and peer review required. Not deployed.

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS #5197 at 53064db, Cormac, source review. It needs a rebase (GitHub shows DIRTY) and exact-head CI. Claim checked: cold loads coalesce, a stale loader cannot republish, and failures stay retryable.

How I checked (diff against the merge-base):

  • Republish: every writer invalidates after its write returns (data.rs: update ~1496, backfill ~1748, explicit invalidate ~1591). invalidate removes the cell from the scope map, so a loader that read before the write completes into a detached cell. The next lookup builds a new cell and reloads.
  • Coalescing: vector_corpus.rs goes through get_or_try_compute(handle, collection) on a SharedCompute owned only by vector_cache, so its keys can't collide with another cache. Concurrent cold searches share one OnceCell init.
  • Retryable: get_or_try_init leaves the cell empty on Err or cancellation. Your test pins Err, then Ok, then cached (same Arc), then TypeMismatch, then invalidate, then fresh.
  • Behaviour change, checked safe: a success with data None used to be an empty corpus and is now a named error. postgres query returns ok(Vec::new()) for a missing table (postgres.rs:1094), and sqlite ensures the table first and returns its records. So only a malformed adapter result changes, and it should be loud.

Note, no action needed: the pending-invalidation test now drives get_or_try_compute only. get_or_compute keeps the same detach contract through the shared cell(), so the generic contract is still tested once.

Not compiled on IntelMac. Reviewing #5204 next.

@joelteply
joelteply force-pushed the codex/shared-compute-fallible branch from 53064db to a4b414d Compare October 20, 2026 05:19
@joelteply

Copy link
Copy Markdown
Contributor Author

Rebased onto canary as a4b414d. Only conflict resolutions were the two hygiene baselines, remeasured at 156720 excess lines and 2124 unjustified unwraps. Focused SharedCompute tests pass 8/8 (0.01s); current hygiene suite passes 39/39. Core/Windows CI are still pending. Requesting confirmation of the rebase delta against Cormac's prior PASS; no deployment claim.

@joelteply
joelteply merged commit 2cc5efa into canary Oct 20, 2026
9 checks passed
@joelteply
joelteply deleted the codex/shared-compute-fallible branch October 20, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant