refactor(telegram): shard adapter.py wave 1 — polling, inbound, delivery, rich mixins (−6,014 lines) - #78866
Closed
andrexibiza wants to merge 6 commits into
Closed
refactor(telegram): shard adapter.py wave 1 — polling, inbound, delivery, rich mixins (−6,014 lines)#78866andrexibiza wants to merge 6 commits into
andrexibiza wants to merge 6 commits into
Conversation
…amIngestMixin (adapter god-file slice) Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
…eliveryMixin (adapter god-file slice) Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com> # Conflicts: # plugins/platforms/telegram/adapter.py
…xin (adapter god-file slice) Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com> # Conflicts: # plugins/platforms/telegram/adapter.py
…llingMixin (adapter god-file slice) Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com> # Conflicts: # plugins/platforms/telegram/adapter.py
… mixin The webhook-start block (and its GHSA-3vpc-7q5r-276h secret guard) moved from TelegramAdapter.connect() into TelegramPollingMixin._start_webhook during the adapter god-file slice. The source-level pin now scans both adapter.py and telegram_polling.py so the invariant survives either layout, and the polling-branch check anchors on the new ``if not webhook_started:`` dispatch instead of the old else-branch. Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
The inbound mixin called the media cache via its own module global; the gateway test suite monkeypatches plugins.platforms.telegram.adapter. cache_image_from_bytes (media-group batching), so the patch missed and the real guard rejected the fake payloads, breaking photo-burst buffering. Function-local lazy imports route resolution through the adapter module, matching the landed slices' shim pattern. Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
This was referenced Aug 4, 2026
Contributor
Author
|
Superseded by #79010 (adapter god-file decomposition, wave 2 consolidation). #79010's diff against main includes BOTH wave-1 (polling/inbound/delivery/rich) and wave-2 (dm-topics/lifecycle/interactive/media/config-mention/reactions) mixins — the complete 10,147 → 1,390 line decomposition in one PR. Closing this standalone to keep ONE PR per class (CCC doctrine). No work lost: every wave-1 commit is in #79010's history. |
Contributor
Author
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.
Summary
First slice wave of the Telegram adapter god-file decomposition
(
plugins/platforms/telegram/adapter.py, 10,147 lines at basebe55e99cbc).Pure extraction — zero behavior change — of the four most entangled clusters
into focused mixin modules, following the landed TelegramAuthorizationMixin
(#75742) / SessionTelegramTopicsMixin (#75747) pattern:
telegram_polling.py(1,311 ln)telegram_inbound.py(1,352 ln)telegram_messaging.py(1,043 ln)telegram_rich.py(635 ln)adapter.py 10,147 → ~4,133 lines (−6,014). Each module is imported back
into adapter.py as a module attribute (existing callers/tests stay green) and
the adapter class inherits all four mixins.
Why this wave
Operator policy: all god-files are to be sharded — model first, agree on
the graph, then slice; one PR per cluster, suite green. The decomposition plan
(three-wave blind analysis, 5 domains × 2 witnesses + validation) is the agreed
graph. This wave targeted the gnarliest clusters first (largest, most
entangled, highest regression risk) so the pattern is proven where it is
hardest. Subsequent waves take the remaining clusters (formatting, reactions,
media send/ingest, drafts, controls, notifications) with the same gates.
Verification
C:/tmp/wt-tg-verify/fidelity-report.md):inbound 26/26, delivery 12/12 (shim-adjusted), rich 19/19, polling verified
in-slice with the same gates — every moved function
ast.dump-identical tothe monolith (modulo the documented function-local lazy-import shims).
6012fd5e5d): the inbound mixincalled
cache_image_from_bytesvia its own module global; the gateway suitemonkeypatches
plugins.platforms.telegram.adapter.cache_image_from_bytes(media-group batching), so the patch missed and photo-burst buffering broke
(
test_non_album_photo_burst_is_buffered_and_combined). Function-local lazyimports route resolution through the adapter namespace — the same shim
pattern the delivery/rich slices use. Caught by the full-suite run, fixed,
and regression-locked by that test.
0 failed (isolated basetemp; Windows host). ruff +
git diff --checkcleanper slice; DCO sign-off on every commit.
git diffnumstat.Scope honesty
Wave 1 of the adapter decomposition — the four hardest clusters. Remaining
adapter.py surface (formatting, reactions, media send/ingest, drafts, controls,
notifications, callback/picker machinery, gateway bindings) ships in follow-up
waves, each its own PR with the same evidence shape.
Links
C:/tmp/tg-campaign/decomp-plan.mdC:/tmp/wt-tg-verify/fidelity-report.md