Skip to content

feat(search): search every chat on MAX's server with opcode 68 when no chat is named - #565

Merged
leemour merged 2 commits into
mainfrom
feat/max-global-search
Oct 11, 2026
Merged

leemour merged 2 commits into
mainfrom
feat/max-global-search

Conversation

@leemour

@leemour leemour commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Task

max search messages with no chat should ask MAX's server across every chat, with the opcode web.max.ru's search box uses (68), once. A named chat keeps opcode 73. No automatic follow-up into the top chats (this replaces the "then 73 per top chat" idea in #562).

Why

The server search was refused without a chat, so an unscoped search only saw the local archive. #562 measured that opcode 68 searches message text in all chats (owner's account, read-only, 2026-10-11).

What

  • Spec: messages.searchGlobal, opcode 68, confidence measured; request {query, count, marker?}; evidence and the answer shape in the operation's notes (src/spec/operations/messages.ts). docs/dev/protocol.md and src/generated/* regenerated with pnpm generate. The constant MSG_SEARCH_GLOBAL is ours: no source we hold names 68.
  • Client: messages.searchGlobal(query, count) keeps only section: "MESSAGES" results with a message, chat id from result.chatId. hasMore is marker !== undefined.
  • Adapter: no chat → one 68 call per server query (a Lucene a OR b splits into up to 3 queries, as before) with count: 30 (web client's value), cut to the caller's limit; the marker is never followed, so cli-messaging's 3-call / 5 s bounds see exactly one call per query. Chat given → 73 as before.
  • Dropped: the per-chat count — MessageHit has no field for it, and putting it in providerMetadata would persist a query-specific number into the store.
  • Messenger: serverSearch: true. cli-messaging 0.231.0 (the current pin) only skips on "chat" (server-search.ts), so no cli-messaging change or pin bump is needed.
  • max serve forwards 68 with no change: it forwards what the spec lists.
  • Behaviour change: an unscoped search messages with words now connects to MAX by default (--backend both); --backend archive keeps it local. Four MCP tests and one CLI test meant archive-only and now say so.
  • Docs: docs/search.md server-search section rewritten; changelog under «Не выпущено»: «Что нового» and «Изменено — может сломать скрипты».

Testing

  • Adapter (src/adapter/max-adapter.test.ts): 73 with a chat; 68 without — one call {query, count: 30}, CHATS / PUBLIC_CHATS / sectionless dropped, marker → hasMore, limit cut.
  • End to end (src/program.test.ts): max search messages invoice --json sends exactly one 68, no 73, hit returned with source: "server", server.calls: 1.
  • pnpm lint, pnpm typecheck, pnpm test (1568 passed), pnpm test:matrix (0 missing), pnpm parity:check — all pass. pnpm release:check fails only on the release-time steps (version not raised, «Не выпущено» not dated).
  • Synthetic data only; no live MAX calls.

🤖 Generated with Claude Code

leemour and others added 2 commits October 11, 2026 04:33
…o chat is named

A server search with no chat now sends one opcode 68 request, as web.max.ru's search box does
(count 30, no marker on the first page). MAX answers one result per chat: its best message plus a
per-chat match count. Only MESSAGES-section results become hits; CHATS (title hits), PUBLIC_CHATS
and sectionless results are dropped, and the per-chat count is dropped because a message has no
field for it. The marker is never followed, so a query costs one call; its presence sets hasMore.
A named chat keeps using opcode 73.

- spec: messages.searchGlobal (68, measured 2026-10-11, PR #562); protocol docs regenerated
- client.messages.searchGlobal; adapter routes a chatless searchMessages to it
- messenger declares serverSearch: true (cli-messaging only skips on "chat")
- archive-only MCP/CLI tests now say --backend archive; new end-to-end test proves one 68 call

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@leemour
leemour merged commit 0341c26 into main Oct 11, 2026
1 check passed
@leemour
leemour deleted the feat/max-global-search branch October 11, 2026 02:57
@leemour leemour mentioned this pull request Oct 11, 2026
leemour added a commit that referenced this pull request Oct 11, 2026
MAX global search (#565): a search with no chat named asks the server once with opcode 68.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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