Skip to content

fix(knowledge): keep the GIN ranking for the rest of a search once a page was handed to it - #8110

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/keyword-ranker-stickiness
Sep 21, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/keyword-ranker-stickiness

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Tin and GIN order candidates differently, so a keyword search whose first page Tin could not fill, and which GIN supplied, must not resume Tin at GIN's offset on a later page. The leg now stays with GIN for the rest of that search. This closes the one remaining way the two rankers could interleave within one search, for large bounded sets and for resolved scopes alike
  • Follow-up to fix(knowledge): walk a large bounded set on the row before ranking it exactly #8106, raised in review of the release PR. The schema-level .concurrently() flag suggested alongside it is deliberately not added: drizzle would generate a drop-and-rebuild of the live index for a flag that only changes generated SQL, and the migration that created the index already builds it concurrently

Type of Change

  • Bug fix

Testing

  • New test: Tin cannot fill page one, GIN supplies it, hydration keeps half, and the second page goes to GIN again with no Tin statement issued; it fails with the stickiness removed
  • vitest over lib/knowledge and app/api/knowledge (191 files, 3304 tests), bun run lint, bun run check:audits and native tsc --noEmit pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…page was handed to it

Tin and GIN order candidates differently, so a keyword search whose first page Tin could not fill, and which GIN supplied, must not resume Tin at GIN's offset on a later page. The leg now stays with GIN for the rest of that search.
@vercel

vercel Bot commented Sep 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 21, 2026 5:53pm UTC

Request Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the ranking handoff is correctly scoped and the regression path is covered.

Summary

This PR preserves a single keyword-ranking strategy after Tin hands candidate selection to GIN, preventing subsequent authorization-refill pages from resuming Tin with an offset derived from GIN ordering.

  • Adds search-local state that makes a GIN fallback sticky for the remainder of the keyword search.
  • Adds a regression test where partial hydration requires another candidate page and verifies that the second page uses GIN without issuing more Tin statements.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Request next keyword candidate page] --> B{Previously handed to GIN?}
  B -- Yes --> G[Query GIN ranking]
  B -- No --> C{Tin scope available?}
  C -- No --> G
  C -- Yes --> D[Try Tin ranking]
  D --> E{Tin supplied a page?}
  E -- Yes --> H[Authorize and hydrate candidates]
  E -- No --> F[Mark search as handed to GIN]
  F --> G
  G --> H
  H --> I{More candidates needed?}
  I -- Yes --> A
  I -- No --> J[Return results]
Loading

Reviews (1) · Last reviewed commit: "fix(knowledge): keep the GIN ranking for..."

@waleedlatif1
waleedlatif1 merged commit d2a4e47 into staging Sep 21, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/keyword-ranker-stickiness branch September 21, 2026 17:59

This branch was previously deployed

1 inactive deployment
Preview 2c1cdb90 Deployed Sep 21, 2026 by vercel[bot]
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