feat(all-mcp): bound get_contacts fan-out with optional limit (#34)#36
Open
kiki830621 wants to merge 1 commit into
Open
feat(all-mcp): bound get_contacts fan-out with optional limit (#34)#36kiki830621 wants to merge 1 commit into
kiki830621 wants to merge 1 commit into
Conversation
getContacts looped one getUser per contact id over the full contact list with no cap (sister to #25). TDLib's getContacts has no server-side limit (unlike getChats / searchChats), so the fix truncates the id list client-side. - get_contacts gains an optional limit (default 200, 10_000 cap via the existing parseLimit). - boundedContactIds(ids:limit:) in TelegramAllLib caps the getUser-per-id loop; getContacts(limit: Int = 200) keeps the bare-array output so the CLI / E2E / MCP handler callers all compile and consume an array unchanged. - 5 hermetic TDLibClientContactsTests; mutation-verified (reverting the prefix to the unbounded list turns the 2 truncation tests RED). 246 unit tests pass. Behavior change (CHANGELOG): no-arg callers with more than 200 contacts now get the first 200, silently truncated (the bare array is kept for backward-compat — a truncation signal would break the 3 callers). Refs #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Bound
get_contacts' unboundedgetUser-per-id fan-out (sister to #25).getContactslooped onegetUserround-trip per contact over the entire contact list with no cap.Refs #34.
Root cause (the load-bearing difference vs #25)
TDLib's
getContactstakes no args — no server-side limit, unlikegetChats(limit:)/searchChats(limit:). SoparseLimiton the arg would only bound the arg, not the loop. The fix truncatesresult.userIdsclient-side before the loop.Approach (a): client-side truncation
get_contactsgains an optionallimit(default 200, 10_000 cap via the existing testedparseLimit).boundedContactIds(_ ids:limit:)inTelegramAllLibcaps the fan-out;getContacts(limit: Int = 200).boundedContactIdshelper.Tests
5 hermetic
TDLibClientContactsTests(truncate / under-limit / at-limit / empty / default-200). Mutation-verified: revertingArray(ids.prefix(limit))to the unboundedidsturns the 2 truncation tests RED. 246 unit tests pass. CLI + E2E targets build clean with the defaulted signature.No-arg
get_contactscallers with more than 200 contacts now get the first 200 — silently truncated. The bare-array output is kept for backward-compat (handler/CLI/E2E all consume an array), so a truncation signal would break them. Pass a higherlimit(up to 10_000) for more.Test plan
swift build(all products incl. telegram-all CLI) — cleanswift test --skip E2ETests→ 246 pass/idd-verify #34 --pr <N>)🤖 Generated with Claude Code