Skip to content

fix(store): stop unsorted lookups after the first namespace match - #747

Merged
earakely-scale merged 2 commits into
scaleapi:mainfrom
morningducke:fix/short-circuit-unsorted-store-lookups
Nov 20, 2026
Merged

earakely-scale merged 2 commits into
scaleapi:mainfrom
morningducke:fix/short-circuit-unsorted-store-lookups

Conversation

@morningducke

@morningducke morningducke commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What and why

An unsorted routed lookup already selects the first matching namespace, but it eagerly queries every backend before returning. Appending a local conversation turn can therefore scan an unrelated, unindexed shared conversation table and block before the first solver request.

Return immediately on the first match when no sort keys are specified. Preserve namespace precedence, fallback after a miss, and cross-store merging for sorted lookups. Regression tests cover local, Hub and configured-store precedence, empty sorts, misses, sorted results, and the real conversation append path.

How it was tested

  • The new regressions fail on the original code: 7 failed, 6 passed.
  • Store unit suite: 1,302 passed, 2 skipped (optional Smol SDK and Linux-only loopback behavior).
  • Conversation prompt tests: 17 passed.
  • Repository Ruff checks and git diff --check pass.
  • Plugin API compatibility check: no break to the plugin surface.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Unsorted routed lookups now stop at the first matching store, avoiding needless reads without changing which document wins.

  • Unsorted lookups stop once a namespace has a match.

No actionable issues found.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into fix/short-circu..." · Reviewed by Greptile

@morningducke
morningducke marked this pull request as ready for review November 17, 2026 21:11
@morningducke
morningducke requested a review from a team as a code owner November 17, 2026 21:11
@earakely-scale
earakely-scale merged commit 56fd883 into scaleapi:main Nov 20, 2026
33 of 35 checks passed
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