Skip to content

fix(core): support CJK terms in relaxed FTS fallback#1022

Merged
phernandez merged 7 commits into
basicmachines-co:mainfrom
liusiyuxyfx:codex/cjk-fts-query-relaxation
Jul 15, 2026
Merged

fix(core): support CJK terms in relaxed FTS fallback#1022
phernandez merged 7 commits into
basicmachines-co:mainfrom
liusiyuxyfx:codex/cjk-fts-query-relaxation

Conversation

@liusiyuxyfx

@liusiyuxyfx liusiyuxyfx commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix relaxed full-text search fallback for whitespace-separated CJK queries such as 季度 报告 while preserving existing ASCII token relaxation behavior.

The old eligibility path only extracted ASCII alphanumeric tokens. Short CJK queries split by spaces therefore produced zero tokens, so strict FTS misses never reached the relaxed retry.

What Changed

  • Add CJK-aware relaxed-term splitting in the shared search repository helper.
  • Preserve regex-token relaxation for punctuated ASCII terms such as client-side state management and foo/bar baz qux.
  • Keep the existing guardrails for quoted queries, explicit boolean queries, numeric identifier-like queries, and short English queries.
  • Let SQLite and Postgres render their own relaxed prefix syntax (* versus :*).
  • Apply the same fallback to exact FTS counts.
  • Preserve caller-owned search sessions from current main, including Postgres savepoint protection.
  • Preserve exact relaxed-retry Logfire spans and debug logging in both backends.

Testing

  • uv run pytest --no-cov -q tests/services/test_search_service.py tests/repository/test_search_repository.py tests/repository/test_postgres_search_repository.py — 107 passed, 22 skipped.
  • BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest --no-cov -q tests/repository/test_search_repository.py tests/repository/test_postgres_search_repository.py — 57 passed, 12 skipped.
  • just fast-check — passed with the repository's existing Python 3.14 asyncio deprecation diagnostics.
  • git diff --check — passed.

@CLAassistant

CLAassistant commented Jun 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@liusiyuxyfx liusiyuxyfx changed the title [codex] fix CJK FTS fallback for whitespace-separated queries fix(FTS) fix CJK FTS fallback for whitespace-separated queries Jun 26, 2026
@liusiyuxyfx liusiyuxyfx force-pushed the codex/cjk-fts-query-relaxation branch from 5ecafe5 to 75da579 Compare June 26, 2026 06:31
@liusiyuxyfx liusiyuxyfx changed the title fix(FTS) fix CJK FTS fallback for whitespace-separated queries fix: support CJK terms in relaxed FTS fallback Jun 26, 2026
@liusiyuxyfx liusiyuxyfx marked this pull request as ready for review June 26, 2026 06:34
@liusiyuxyfx liusiyuxyfx force-pushed the codex/cjk-fts-query-relaxation branch from 75da579 to 84ddf63 Compare June 26, 2026 06:36
@liusiyuxyfx liusiyuxyfx marked this pull request as draft June 26, 2026 06:36
@liusiyuxyfx liusiyuxyfx marked this pull request as ready for review June 26, 2026 06:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84ddf6355a

ℹ️ 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".

Comment thread src/basic_memory/services/search_service.py Outdated
@liusiyuxyfx liusiyuxyfx force-pushed the codex/cjk-fts-query-relaxation branch from 84ddf63 to 529c5e8 Compare June 26, 2026 07:07
@liusiyuxyfx liusiyuxyfx marked this pull request as draft June 26, 2026 07:08
@liusiyuxyfx liusiyuxyfx marked this pull request as ready for review June 26, 2026 07:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 529c5e8f1d

ℹ️ 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".

Comment thread src/basic_memory/repository/search_repository_base.py Outdated
@liusiyuxyfx liusiyuxyfx force-pushed the codex/cjk-fts-query-relaxation branch from 529c5e8 to ca153d3 Compare June 26, 2026 08:43
@liusiyuxyfx liusiyuxyfx marked this pull request as draft June 26, 2026 08:43
@phernandez

Copy link
Copy Markdown
Member

@liusiyuxyfx thanks for this PR. Really appreciate the help testing non ascii characters. If it is ready, can you mark it non-draft?

@liusiyuxyfx liusiyuxyfx marked this pull request as ready for review June 26, 2026 15:58
@liusiyuxyfx

Copy link
Copy Markdown
Contributor Author

@liusiyuxyfx thanks for this PR. Really appreciate the help testing non ascii characters. If it is ready, can you mark it non-draft?

ready

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca153d3833

ℹ️ 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".

Comment thread tests/repository/test_search_repository.py
@liusiyuxyfx liusiyuxyfx force-pushed the codex/cjk-fts-query-relaxation branch from 36edcdf to cbfc2e5 Compare June 27, 2026 01:37
@phernandez

Copy link
Copy Markdown
Member

@codex review this pr please

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: cbfc2e5a18

ℹ️ 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".

liusiyuxyfx and others added 3 commits July 14, 2026 22:51
Signed-off-by: liusiyuxyfx <779532360@qq.com>
Signed-off-by: liusiyuxyfx <779532360@qq.com>
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez phernandez force-pushed the codex/cjk-fts-query-relaxation branch from cbfc2e5 to 27e8012 Compare July 15, 2026 03:55
@phernandez

Copy link
Copy Markdown
Member

recheck

@phernandez

Copy link
Copy Markdown
Member

@codex review

@phernandez phernandez changed the title fix: support CJK terms in relaxed FTS fallback fix(core): support CJK terms in relaxed FTS fallback Jul 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27e80123c7

ℹ️ 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".

Comment thread src/basic_memory/repository/postgres_search_repository.py Outdated
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member

@codex review

@phernandez

Copy link
Copy Markdown
Member

recheck

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c80bfbf5e4

ℹ️ 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".

Comment thread src/basic_memory/services/search_service.py
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member

@codex review

recheck

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75432ed4db

ℹ️ 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".

Comment thread src/basic_memory/repository/search_repository_base.py Outdated
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member

@codex review

recheck

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51bb7d7469

ℹ️ 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".

Comment thread src/basic_memory/repository/search_repository_base.py Outdated
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member

@codex review

/recheck

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 27d70fdea9

ℹ️ 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".

@phernandez phernandez merged commit a2f5edf into basicmachines-co:main Jul 15, 2026
3 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.

3 participants