Skip to content

[codex] Add tokenized FTS5 query helper#35

Merged
steipete merged 1 commit into
mainfrom
codex/fts-token-query
Jun 19, 2026
Merged

[codex] Add tokenized FTS5 query helper#35
steipete merged 1 commit into
mainfrom
codex/fts-token-query

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • add a shared tokenized FTS5 query builder for arbitrary user search input
  • quote every generated token and discard punctuation that could be parsed as FTS operators
  • cover Unicode, operator-like input, and punctuation-only queries

Validation

  • go test ./...
  • go test -race ./store/...
  • go vet ./...
  • autoreview: clean

@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: [codex] Add tokenized FTS5 query helper This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit 9a63644 into main Jun 19, 2026
6 checks passed
@steipete
steipete deleted the codex/fts-token-query branch June 19, 2026 12:12

@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: 8f5342a7e6

ℹ️ 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 store/fts.go
flush()
}
flush()
return strings.Join(terms, " ")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return a valid no-match query for punctuation-only input

When the input contains no token characters, such as -- "", terms stays empty and this returns ""; passing that directly to an FTS5 MATCH ? predicate (the query shape documented in docs/cloudflare-remote-archives.md) makes SQLite raise fts5: syntax error near "" instead of returning no rows. The existing FTS5Terms helper avoids this by returning FTS5Phrase(""), so this helper should also produce a valid no-match expression or otherwise surface an error rather than handing callers an invalid FTS query for arbitrary user punctuation.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

Post-merge audit found one real edge case and it is now fixed.

Decomposed Unicode graphemes were split at combining marks, so the generated query did not match SQLite FTS5's token for the original text. PR #37 preserves Unicode marks, documents the empty-input sentinel, and landed as 797628aa9708f8244352e0505d8afc6ec13f7050.

Proof used a real temporary SQLite FTS5 store and covered punctuation, quote/operator-shaped input, multiple scripts, precomposed/decomposed Unicode, empty/all-punctuation input, and unchanged legacy helper behavior. Full tests, race tests, vet, deadcode, vulnerability checks, changed-package static/security analysis, secret scans, autoreview, and the public model-identifier gate passed.

Exact merged-head checks are green: CI, CodeQL, and secret scanning.

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