Repository navigation
refactor(telegram): consolidate bot handlers into named modules - #122174
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Telegram E2E evidence (exact head 9c8af83ac1c045f0a022f9c63541da38f9c6cc4d)Live default-turn probe via the QA userbot lane (TDLib user, mock provider, ephemeral gateway from this head; DM, ids redacted): sent a real message, received the expected reply — the full inbound path now runs through the consolidated modules end to end (InboundPipeline authorization→buffer→media→text→processing, then dispatch/delivery), on real Telegram transport. This diff is behavior-neutral by construction and by proof: Gate ledger on this head: both cycle checkers, both type lanes, oxlint on all 27 touched files, |
9c8af83 to
35c40ab
Compare
|
Closing the review's two next-steps on exact head 35c40ab: (1) the live default-turn userbot probe was rerun on this head — real Telegram send and expected reply through the consolidated inbound pipeline, exit 0; (2) the +185 classified production LOC tradeoff is maintainer-accepted (Ayaan): the residual is written leaf contracts and named coordinators replacing the derived-type factory graph — better design over line count, same trade as #122091. |
…claw#122174) The bot-handlers family was 22 files behind a 22-line fan-out: six files holding one callback switch, four holding one inbound pipeline, every interface a derived ReturnType, processMessage taking 8 positional args, and its params type declared inside bot-native-commands.ts. Three named coordinators (inbound pipeline, callback router, event bindings) now sit behind the same registerTelegramHandlers entry with hand-written leaf contracts; the factory graph, 16 slice/barrel files, and the type shim are deleted. Behavior-neutral: bot.test.ts and the ingress e2e byte-identical to main (SHA-256-pinned) and green; +185 production LOC accepted as the written-contract tradeoff. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
bot-handlers.*was 22 files behind a 22-line fan-out whose registration order was enforced only by call order: six files holding onecallback_queryswitch, four files holding one inbound pipeline, every interface derived asReturnType<typeof createTelegramXRuntime>, an 8-positional-argumentprocessMessagetype, andRegisterTelegramHandlerParamsdeclared inside the 2,156-linebot-native-commands.ts. Only 7 of 22 files had tests.Why This Change Was Made
The family now has three named coordinators behind the same single entry (
registerTelegramHandlers, which owns registration order directly): the inbound pipeline (authorization → buffer → media → text → processing), the callback router (one internal table; approvals/errors/interactions as its controls), and event bindings (reaction, poll-answer, migration). Contracts live in a leafbot-handlers.types.ts— zero implementation-derived types, named inbound-disposition and callback-outcome unions,processMessageas a named options object.RegisterTelegramHandlerParamsmoved to the leaf with a full cutover (no re-export shim). Per-slice factory graph and its cross-runtime parameter threading deleted; 12*.runtime.tsslice files removed, externally-mocked module paths preserved.User Impact
None: behavior-neutral.
bot.test.ts(6,369 lines, the front-door pin) and the ingress-coalescing e2e are byte-identical to main — verified by SHA-256 in the round report — and green.Evidence
git diff --checkclean.