Skip to content

feat(search): auto-detect Cypher queries + pattern/workspace swap hints (closes #239) - #246

Merged
Wolfvin merged 1 commit into
mainfrom
feat/issue-239-search-self-correct
Jul 12, 2026
Merged

feat(search): auto-detect Cypher queries + pattern/workspace swap hints (closes #239)#246
Wolfvin merged 1 commit into
mainfrom
feat/issue-239-search-self-correct

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Closes #239.

Summary

  • search returns a _hints field when pattern is an existing directory (likely argument swap — search is the only umbrella command with pattern-before-workspace).
  • High-confidence Cypher-shaped patterns (MATCH (...) auto-route to --mode graph when a different mode was set, with a hint explaining the auto-route.
  • Both heuristics are narrow by design (verified no false positives against the existing search test suite + a dedicated negative-control test).

Test plan

  • pytest tests/test_search_command.py — 8/8 new tests
  • pytest tests/test_search_command.py tests/test_search_engine.py tests/test_semantic_search_engine.py tests/test_query_graph.py — all pass
  • Manual verification on real workspace: search . "getAccessMode" --mode symbol (swapped args) → _hints correctly flags it; search "MATCH (n) ... RETURN n LIMIT 2" . (no --mode graph) → auto-routed, correct graph results returned

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Wolfvin
Wolfvin merged commit b9dff3f into main Jul 12, 2026
1 of 7 checks passed
@Wolfvin
Wolfvin deleted the feat/issue-239-search-self-correct branch July 12, 2026 12:53
…e swap (closes #239)

Two related runtime UX gaps, both about the tool correcting toward the
right answer instead of silently returning the wrong one:

1. `search` is the only umbrella command with pattern before workspace
   (opposite of every other command). Getting it backwards doesn't
   error — the workspace path silently becomes the search pattern and
   returns an empty "ok" result with zero indication anything went
   wrong (the docstring/--help example order was already fixed in a
   prior PR this session; this fixes the runtime behavior itself).
   Now: if `pattern` is an existing directory, a `_hints` entry flags
   the likely argument swap.

2. A Cypher-shaped pattern (`MATCH (...`) passed without `--mode graph`
   previously got run through whatever mode was set (default:
   semantic), producing a confusing near-empty result instead of the
   graph query the caller almost certainly meant. Now: high-confidence
   matches (pattern starts with `MATCH (`) auto-route to `--mode graph`
   with a `_hints` entry explaining the auto-route (silence it by
   passing `--mode graph` explicitly).

Both heuristics are narrow by design — no false positives on the
existing search test suite, and a negative-control test confirms a
pattern that merely mentions "MATCH" mid-string is not reinterpreted.
@sonarqubecloud

Copy link
Copy Markdown

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.

feat(search): auto-detect Cypher-shaped queries and warn on argument-order mistakes

1 participant