Skip to content

fix(backend): add LIKE fallback to item search for compound-token substrings - #235

Merged
getappz merged 2 commits into
masterfrom
fix/item-search-like-fallback
Jul 18, 2026
Merged

fix(backend): add LIKE fallback to item search for compound-token substrings#235
getappz merged 2 commits into
masterfrom
fix/item-search-like-fallback

Conversation

@getappz

@getappz getappz commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • items_fts (porter unicode61) splits agentflare-store into agentflare/store tokens, so a query for flare-store or bare flare can't match since flare is a suffix, not a prefix, of agentflare
  • Falls back to a LIKE scan on zero FTS hits, mirroring the existing pattern in src/memory/search.rs

Test plan

  • cargo test -p agentflare-backend item:: (25 passed, including search_falls_back_to_like_for_suffix_of_compound_token)

Summary by CodeRabbit

  • Bug Fixes
    • Improved search results when FTS tokenization misses terms in compound names and descriptions (e.g., hyphenated identifiers).
    • Added a secondary fallback search that performs substring matching when the primary search returns no results.
    • Enhanced query escaping so special characters like backslashes are matched correctly, while still respecting limits and returning the most recently updated items first.

…strings

items_fts (porter unicode61) splits agentflare-store into agentflare/store
tokens; a query for flare-store or bare flare can't match since flare is a
suffix, not a prefix, of agentflare. Fall back to a LIKE scan on zero FTS
hits, mirroring the existing pattern in src/memory/search.rs.
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0afae075-02fc-4058-b3f4-aee0611ae05d

📥 Commits

Reviewing files that changed from the base of the PR and between 99314eb and e7adf80.

📒 Files selected for processing (1)
  • crates/agentflare-backend/src/item.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/agentflare-backend/src/item.rs

📝 Walkthrough

Walkthrough

search() now falls back to an escaped LIKE query when FTS5 returns no results. The fallback searches item names and descriptions, preserves ordering and limits, and is tested for compound-identifier suffixes and literal backslashes.

Changes

Search fallback

Layer / File(s) Summary
Escaped LIKE fallback and validation
crates/agentflare-backend/src/item.rs
Documents FTS5 tokenization edge cases, adds an escaped LIKE fallback ordered by update time with the existing limit, and tests compound-identifier suffix matching plus literal backslash escaping.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • getappz/agentflare#193: Extends the same item search behavior with an FTS5 no-results fallback using an escaped LIKE query and corresponding tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main backend search change and its purpose.
Description check ✅ Passed The description covers the summary and test plan and is mostly aligned with the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/item-search-like-fallback

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/agentflare-backend/src/item.rs`:
- Line 554: Update the LIKE pattern construction in the `like_pat` expression to
escape backslashes before escaping `%` and `_`, preserving literal backslashes
in queries such as `a\b` and `\%` under the existing `ESCAPE '\\'` behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4ae90ba-321e-410f-9ae5-defdc0e7bb6b

📥 Commits

Reviewing files that changed from the base of the PR and between ba258fa and 99314eb.

📒 Files selected for processing (1)
  • crates/agentflare-backend/src/item.rs

Comment thread crates/agentflare-backend/src/item.rs Outdated
CodeRabbit finding on PR #235: format! left a literal backslash in the
query un-doubled before it reached SQLite's ESCAPE '\' clause, so it
was silently swallowed as an (undefined) escape prefix for the next
character instead of matching literally.
@getappz
getappz merged commit aa4ae5d into master Jul 18, 2026
16 checks passed
@getappz
getappz deleted the fix/item-search-like-fallback branch July 18, 2026 03:50
getappz added a commit that referenced this pull request Jul 22, 2026
#305)

* feat: flare doctor — claim-worktree health sweep + safe reclaim

Agentflare-Agent: 1
Agentflare-Branch: item-235-flare-doctor

* fix(git): correct flare doctor's dirty/stale detection, wire up orphaned

- is_dirty checked run_in_ok's exit status, but `git status --porcelain`
  always exits 0 -- it was always false, so --reclaim's dirty guard never
  actually fired. Now checks for non-empty output instead.
- Stale was unconditionally pushed for every lane regardless of actual
  age, making every worktree "stale" and, combined with the dirty bug,
  making --reclaim eligible to delete every lane in the repo. Now derived
  from days since the worktree's last commit, compared against the
  threshold.
- Orphaned (item completed/cancelled but worktree remains) was declared
  in the enum/summary/formatters but never computed. Wired scan() to
  accept a sequence_id -> state group_name map (built by the CLI layer
  from the items/states tables, mirroring claimed_sequence_ids) and flag
  lanes whose item is completed or cancelled.
- Zombie (dead claiming-session pid) stays unimplemented -- no existing
  pid-liveness primitive in this codebase to build on; documented on the
  enum variant and left for a follow-up rather than rushed in.
- Fixed clippy (useless format!, collapsible if) and fmt findings from
  CI; added coverage for the two correctness fixes.

Agentflare-Agent: claude-code_2-1-217_agent
Agentflare-Branch: item-235-flare-doctor

* fix(git): address CodeRabbit findings on flare doctor

- Detached-HEAD worktrees were encoded as a fake branch name ("detached
  at <rev>"), which then flowed into has_upstream and duplicate-branch
  checks meant for real branches. Split into a separate detached_at
  field so detached lanes are excluded from branch-only checks, same as
  they should be.
- reclaim() silently dropped a lane when remove_dir_all failed (e.g. a
  Windows file lock) with no diagnostic at all -- now logs which lane
  and why.
- --format accepted any string and silently fell back to text output on
  a typo; now a clap ValueEnum so an invalid value is a parse error.
- reclaim's status lines were printed to stdout, corrupting
  `--reclaim --format json` output for a script piping it to `jq`. Moved
  to stderr, alongside the JSON/markdown/text report on stdout.

Agentflare-Agent: claude-code_2-1-217_agent
Agentflare-Branch: item-235-flare-doctor
getappz added a commit that referenced this pull request Aug 14, 2026
…ctor)

Adds a doctor action to the item MCP tool wrapping flare_git_core::doctor::scan/reclaim
(item #235's CLI-only worktree hygiene scan/reclaim) so an MCP-only agent that hits the
git worktree remove/prune shim denial has a discoverable path to worktree cleanup instead
of a dead end. Also cross-references the new action from the shim's teardown-deny message
and the item tool's own description.

Agentflare-Agent: claude-code
Agentflare-Branch: task/465-surface-flare-doctor-reclaim-via-mcp-wor
Agentflare-Item: 465
getappz added a commit that referenced this pull request Aug 14, 2026
…ctor) (#487)

Adds a doctor action to the item MCP tool wrapping flare_git_core::doctor::scan/reclaim
(item #235's CLI-only worktree hygiene scan/reclaim) so an MCP-only agent that hits the
git worktree remove/prune shim denial has a discoverable path to worktree cleanup instead
of a dead end. Also cross-references the new action from the shim's teardown-deny message
and the item tool's own description.

Agentflare-Agent: claude-code
Agentflare-Branch: task/465-surface-flare-doctor-reclaim-via-mcp-wor
Agentflare-Item: 465
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