Skip to content

test: QA integration tests + fix FTS5 query escaping#6

Merged
EtanHey merged 1 commit into
mainfrom
test/qa-think-recall
Feb 19, 2026
Merged

test: QA integration tests + fix FTS5 query escaping#6
EtanHey merged 1 commit into
mainfrom
test/qa-think-recall

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented Feb 19, 2026

Summary

  • 19 integration tests for Think/Recall/Sessions with real production DB
  • Fix: FTS5 syntax error when query contains special chars (dots, dashes)
    • Wrapped terms in double quotes, joined with OR for lenient matching
    • Without this fix, queries like "implementing authentication" crash with apsw.SQLError

Test breakdown

  • 5 session tests (no embedding, fast ~1s)
  • 2 file-recall tests (no embedding)
  • 6 think tests (with bge-large embedding, ~40s total)
  • 3 topic-recall tests (with embedding)
  • 3 MCP wiring verification tests

Test plan

  • All 19 new integration tests pass
  • All 48 existing tests still pass (no regressions)
  • FTS5 fix verified — special characters no longer crash

🤖 Generated with Claude Code


Note

Medium Risk
Touches query construction for FTS5 MATCH, which can affect search correctness and recall; the new tests also depend on a large “production” DB and embeddings, increasing CI/runtime fragility even though logic changes are small.

Overview
Fixes hybrid keyword search crashes by escaping user query_text before passing it to FTS5 MATCH (quotes each term, strips embedded quotes, joins with OR, and falls back to * for empty input).

Adds a new test_think_recall_integration.py suite that runs against the production SQLite DB to validate sessions(), think(), and recall() behavior end-to-end (including embedding-backed paths) and verifies MCP tool registration/annotations.

Written by Cursor Bugbot for commit 5e7aa23. This will update automatically on new commits. Configure here.

Add 19 integration tests verifying Think/Recall/Sessions with real
production DB (268K+ chunks):
- 5 session tests (no embedding, fast)
- 2 file-recall tests (no embedding)
- 6 think tests (with embedding)
- 3 topic-recall tests (with embedding)
- 3 MCP wiring tests

Fix FTS5 syntax error: raw query text with special characters (dots,
dashes) caused `apsw.SQLError: fts5: syntax error`. Now escapes
query terms by wrapping in double quotes and using OR semantics
for lenient matching.

67 total tests pass (48 existing + 19 new).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 19, 2026

Warning

Rate limit exceeded

@EtanHey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a297f7e and 5e7aa23.

📒 Files selected for processing (2)
  • src/brainlayer/vector_store.py
  • tests/test_think_recall_integration.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/qa-think-recall

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

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

@EtanHey EtanHey merged commit 2fc35e4 into main Feb 19, 2026
1 of 5 checks passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Empty/whitespace-only queries return a wildcard match-all.
"""
if not query or not query.strip():
return "*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Invalid FTS5 fallback * causes syntax error

Medium Severity

_escape_fts5_query returns a bare "*" for empty/whitespace queries and for inputs consisting entirely of double-quote characters. A standalone * is not valid FTS5 MATCH syntax — it's only valid as a suffix on a term (e.g. prefix*). Using it in WHERE chunks_fts MATCH '*' raises apsw.SQLError: fts5: syntax error, which is the same class of crash this PR aims to fix.

Additional Locations (1)

Fix in Cursor Fix in Web

@EtanHey EtanHey deleted the test/qa-think-recall branch February 19, 2026 20:22
EtanHey added a commit that referenced this pull request Feb 19, 2026
…#6)

Add 19 integration tests verifying Think/Recall/Sessions with real
production DB (268K+ chunks):
- 5 session tests (no embedding, fast)
- 2 file-recall tests (no embedding)
- 6 think tests (with embedding)
- 3 topic-recall tests (with embedding)
- 3 MCP wiring tests

Fix FTS5 syntax error: raw query text with special characters (dots,
dashes) caused `apsw.SQLError: fts5: syntax error`. Now escapes
query terms by wrapping in double quotes and using OR semantics
for lenient matching.

67 total tests pass (48 existing + 19 new).

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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