Skip to content

Search overview: a search needs at least three words - #729

Merged
neuromechanist merged 3 commits into
developfrom
feature/issue-728-overview-three-words
Nov 11, 2026
Merged

neuromechanist merged 3 commits into
developfrom
feature/issue-728-overview-three-words

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

The maintainer's rule (2026-11-11): an AI overview needs a search of at least three words.
A one-word search such as "EEG" came back from the dev overview as a 502 every time (#728), and nemar.org's Discover panel showed its error state.

  • src/api/overview.py:
    • MIN_QUERY_WORDS = 3 and query_word_count(query), which counts whitespace-separated tokens that hold at least one letter or digit. It is Unicode-aware, so "P300", "naïve" and "α-band" are words and a lone "-" is not.
    • OverviewRequest's query validator refuses a shorter query, so the route answers 422 with "an overview needs a search of at least 3 words" before any model call or cache lookup.
  • nemar.org's Discover panel counts the same way and shows a note instead of calling. That change is the companion website PR into staging. A 422 from here shows the same note, so the two sides cannot disagree visibly.
  • The existing tests now use three-word queries, with each test's intent unchanged: the cache-key spelling, eviction, concurrency, the 300-character bound now as three words, and so on.
  • docs/search-overview.md gives the rule in the field table and the 422 row. CHANGELOG entry added.

Refs #728. It closes after a check on develop: "EEG" answers 422, and a three-word search answers 200 with a cited overview.

What this does not settle: why a short query produced no citation, and whether the plain-text error code: 502 body came from Cloudflare replacing OSA's JSON 502. Both need the dev server logs. With the three-word rule the case no longer reaches the model, so I am noting them on #728 rather than chasing them here.

Tests

  • tests/test_api/test_overview_unit.py: the word count on seven cases, and the minimum (3 words pass, 2 are refused)
  • tests/test_api/test_search_overview.py: one and two words are 422 with no model call; "EEG" is a 422 whose body says "at least 3 words"
  • pytest tests/test_api tests/test_metrics -m 'not network and not llm' (Python 3.12): 2112 passed
  • ruff check and ruff format: clean

…any model call

query_word_count counts whitespace tokens holding a letter or digit; MIN_QUERY_WORDS = 3.
Tests move to three-word queries and cover the count, the 422 and its reason.

Tested: tests/test_api and tests/test_metrics (2112 passed).
…rule, not a model limit; api-structure.md and the worker routing test follow it

Tested: overview tests (166 passed); bun workers/osa-worker/test-routing.js passes.
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1 (Sonnet code reviewer): outcomes

No critical findings, 2 important, 1 minor; all fixed in the round 1 commit. The reviewer checked the Python word count against the website's TypeScript count with both runtimes. They agree on letters, digits, marks, underscores, symbols, CJK without spaces (one word each) and the common whitespace. They differ only on U+001C to U+001F, U+0085 and U+FEFF, which a real search does not contain. Either way the result is a refusal, not a wrong overview.

# Severity Finding Outcome
1 Important .context/api-structure.md section 5 had a two-word example, the old query bound and a 422 row without the rule Fixed: a three-word example, the rule with MIN_QUERY_WORDS and query_word_count, and "a query under 3 words" in the 422 row
2 Important The docs and the code comment said a short search "gives the model too little to write a cited reading", which #728 does not establish ("P300 speller", two words, returned a cited 200) Fixed: both now state it as the maintainer's rule, refused before any model call, and mention the "EEG" 502 only as what was seen
3 Minor workers/osa-worker/test-routing.js posted the one-word query 'faces' Fixed: 'faces in EEG'; the test passes

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Worker Deployment Required

Worker changes detected. After merging to main or develop, the workflow will automatically deploy the worker.

Manual deployment (if needed):

cd workers/osa-worker
wrangler deploy --env dev  # for develop branch
wrangler deploy            # for main branch

@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2 (Sonnet code reviewer): outcomes

No findings: all 3 round 1 findings are resolved, and the fixes introduced nothing new. This was the last round.

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