Repository navigation
feat(query): execute Boolean FTS predicates (#2006) - #2012
Conversation
|
Warning Review limit reached
More reviews will be available in 35 minutes and 49 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@codex review |
0206a10 to
2455dab
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0206a108c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return _field_token_to_predicate(_QUERY_TRANSFORMER.field_clause(token)) | ||
|
|
||
| def fts_quoted_leaf(self, token: Token) -> QueryPredicate: | ||
| return QueryTextPredicate(text=_decode_escaped_string(Token("ESCAPED_STRING", str(token)[1:]))) |
There was a problem hiding this comment.
Preserve phrase semantics for quoted FTS predicates
For ~"timeout failure", this decodes the token to timeout failure and drops any marker that it was quoted. _fts_predicate_clause later passes that through normalize_fts5_query, which leaves timeout failure unquoted; in FTS5 that matches rows containing both terms anywhere, so a session with timeout ... failure satisfies a query documented as a quoted phrase. Preserve the quoted form or a quoted flag through QueryTextPredicate so MATCH receives an exact phrase query.
Useful? React with 👍 / 👎.
| FROM messages_fts | ||
| JOIN blocks filter_fts_blocks | ||
| ON filter_fts_blocks.rowid = messages_fts.rowid | ||
| WHERE filter_fts_blocks.session_id = {table_alias}.session_id | ||
| AND messages_fts MATCH ? |
There was a problem hiding this comment.
Guard Boolean FTS filters with index readiness checks
This new subquery is reached from list_summaries and count_sessions via _session_filter_clause, but those paths do not call _ensure_messages_fts_ready before referencing messages_fts (unlike search_summaries, which does). On archives where the FTS table is missing or incomplete, sessions where ~timeout can surface a raw SQLite error or produce incorrect false negatives instead of the established sanitized “Search index” degradation with a repair hint.
Useful? React with 👍 / 👎.
Summary
Adds executable lexical predicates to the #2006 Boolean DSL.
~termand~"quoted phrase"now parse into a typedQueryTextPredicateand lower into a correlated FTS5 filter againstmessages_ftsjoined throughblocks.Problem
After #2011, the DSL could execute session fields, structural
exists(...), and actionseq(...), but lexical text inside Boolean predicates was still not representable. That meant users could not write queries such assessions where origin:chatgpt-export AND ~"timeout failure"without dropping back to the older flat ranked FTS path.Solution
Introduced
QueryTextPredicate, extended the Lark Boolean grammar with~text/~"phrase", and wired the archive Boolean lowerer tomessages_fts MATCH ?. Becausemessages_ftsis contentless and its unindexed columns read back as NULL, the lowerer joinsblocksby rowid for session correlation, matching the existing search path's storage reality. This PR gives Boolean FTS filter semantics; the existing flat query-term path remains the ranked lexical search path.Verification
nix develop --command devtools test tests/unit/cli/test_query_expression.py->190 passed in 24.52snix develop --command devtools verify --quick->exit_code: 0devtools verify --quickon pushed branch ->exit_code: 0Ref #2006