Skip to content

fix(core): reuse semantic query vectors and bound inference batches - #192

Merged
jb-thery merged 1 commit into
developfrom
feature/retrieval-efficiency
Oct 11, 2026
Merged

jb-thery merged 1 commit into
developfrom
feature/retrieval-efficiency

Conversation

@jb-thery

Copy link
Copy Markdown
Member

Repeated semantic searches currently run model inference for every request, and the embedding adapter relies on its caller to keep input arrays within the configured batch limit. Cache single-query vectors in memory by project and exact model identity, and enforce the existing batch limit inside the adapter. Search results still come from the current index generation, with unchanged ranking and citation behavior.

The cache is bounded by both entries and vector values, returns independent arrays, and retires with its model. Failed or cancelled inference is not cached. Semantic batches preserve input order and check cancellation between calls.

Refresh the workspace's affected transitive dependencies, remove the repaired HTTP-cache audit exception, and replace Mammoth's CLI-only argparse chain with its compatible version 2 to remove sprintf-js from the workspace graph.

Validation:

  • pnpm validate: 481 Core tests, 24 landing tests, coverage, builds, public API, CLI/MCP, packaging, licenses and release smoke checks passed.
  • Three alternating comparisons using the pinned local mxbai model: 288 repeated embeddings, 288 unique embeddings and 144 searches per variant; all vector and search fingerprints match.
  • Repeated search median: 29.43 ms to 25.32 ms on the local reference corpus. This is a scoped benchmark, not a guarantee for other models or corpora.
  • Cache eviction, vector budgets, mutation isolation, project/model isolation, cancellation, model disposal and fresh evidence after an atomic ingestion rebuild are covered.
  • Mammoth CLI help and existing document extraction tests pass with the workspace override.

Release highlights:
- reduce repeated semantic retrieval work while preserving results and citations
- keep every semantic model call within the configured batch limit

Release details:
- **Core:** cache query vectors by project and exact model identity within bounded memory
- **Core:** preserve input order and cancellation across semantic batches
- **Toolchain:** update Handlebars and HTTP cache semantics; replace Mammoth CLI argparse
  to remove sprintf-js from the workspace dependency graph
- **Documentation:** explain model cache scope and batch guarantees

Verification:
- pass pnpm validate with 481 Core tests and 24 landing tests
- compare 288 repeated and 288 unique embeddings plus 144 searches per variant
  across three alternating runs with identical vector and search fingerprints
- verify cache eviction, cancellation, model lifecycle, and fresh evidence after ingestion
@jb-thery
jb-thery merged commit 27e2024 into develop Oct 11, 2026
10 checks passed
@jb-thery
jb-thery deleted the feature/retrieval-efficiency branch October 11, 2026 05:28
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