Skip to content

fix(retrieval): match locator keyword queries to the trigram index - #69

Merged
777genius merged 3 commits into
mainfrom
fix/retrieval-keyword-index
Sep 12, 2026
Merged

777genius merged 3 commits into
mainfrom
fix/retrieval-keyword-index

Conversation

@777genius

@777genius 777genius commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Canonical locator keyword retrieval wrapped the already normalized text column in lower(), preventing the LIKE predicate from matching the existing trigram index. Query the normalized column directly while preserving scope, lifecycle, ranking and literal wildcard escaping.

Validation includes PostgreSQL 18.4 execution with Unicode and wildcard decoys, old/new result parity, and an index-condition assertion with the old predicate as a negative control. All 3 PostgreSQL tests passed. Repository lint, file-size boundaries, secret scan and seven deterministic evaluation suites passed.

Independent Sol/xhigh review approved commit f95d5cca4470430f76ccafa5c927e572cb206045. Retrieval latency and actual memory-answer quality still require separate measurement.

Summary by CodeRabbit

  • Bug Fixes

    • Improved keyword matching for mixed-case and non-ASCII text.
    • Literal % and _ characters in search terms are now matched as text instead of being treated as wildcards.
    • Corrected normalization across document titles and body content for more accurate retrieval.
  • Performance

    • Keyword retrieval now uses the canonical indexed text path, improving search efficiency while preserving matching behavior.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 075c528c-c274-4cdc-a833-45a69e86032e

📥 Commits

Reviewing files that changed from the base of the PR and between 9e06b31 and f95d5cc.

📒 Files selected for processing (5)
  • packages/infinity_context_adapters/infinity_context_adapters/postgres/locator_retrieval.py
  • tests/adapters/test_locator_parent_lifecycle.py
  • tests/adapters/test_locator_retrieval_adapters.py
  • tests/adapters/test_postgres_canonical_keyword_trigram.py
  • tests/adapters/test_projected_document_rendering.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The locator retrieval query now matches the indexed normalized_text column without lowercasing it. Tests cover Unicode, case, literal wildcard characters, ranking parity, normalized text, and canonical PostgreSQL trigram index usage.

Changes

Locator keyword matching

Layer / File(s) Summary
Indexed locator query matching
packages/infinity_context_adapters/.../postgres/locator_retrieval.py
The candidate statement no longer lowercases normalized_text before matching. Query terms remain normalized and escaped in Python.
Keyword matching semantics
tests/adapters/test_locator_parent_lifecycle.py, tests/adapters/test_locator_retrieval_adapters.py, tests/adapters/test_projected_document_rendering.py
Tests cover mixed-case Unicode text, literal % and _ characters, indexed-column SQL, configurable queries, and full title-plus-body normalization.
PostgreSQL index and ranking validation
tests/adapters/test_postgres_canonical_keyword_trigram.py
PostgreSQL tests validate locator ranking parity and confirm that the canonical trigram index is used without lower(normalized_text).

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f95d5

The indexed-column change preserves existing retrieval semantics, wildcard escaping, ranking, and tested PostgreSQL index usage.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: updating locator keyword retrieval to use the trigram index.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/retrieval-keyword-index

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the café trail,
Where wildcards keep their shape.
The trigram index hops ahead,
While lowercase stays in place.
Unicode leaves a shining trace.

Comment @coderabbitai help to get the list of available commands.

@777genius
777genius marked this pull request as ready for review September 12, 2026 18:37
@777genius 777genius changed the title fix(retrieval): use the trigram index for canonical locator keywords fix(retrieval): match locator keyword queries to the trigram index Sep 12, 2026
@777genius
777genius merged commit cee6739 into main Sep 12, 2026
16 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.

1 participant