Native route recovery reads the session's newest native admission with admissions.latest_admission (payload_marker native_text_v1); the plugin-turn wake, the exhausted-turn replay check and /new's paused-follower count read the session's pending admissions with admissions.list; the completion-note close check reads the row with sessions.get and RECOVERABLE_END_REASONS. Each keeps the statuses and fields it counted before.
Telegram dm_threads shared mode reads topic-mode state with routing.is_topic_mode_enabled on the storage interface handle: the runner's own handle, the SessionStore's scoped handle (a pinned store wins), or the routed profile's handle for a multiplexed identity.
Tests: the claim helper claims through admissions.claim; the relay recovery, plugin-turn, completion, resume and dm_threads tests seed and read through the interface, assertions unchanged; new cases cover paused_followers and the fresh-session pending check.
Review follow-ups on dm_threads: shared (Greptile on #155680):
- text batches stay per DM thread (the session key drops the thread, a merged
batch kept only the first event's source, so a second thread got no answer)
- /topic state is read from the source's pinned runtime profile store, not the
active scope (a primary bot routing to another profile keys before scoping)
- a hot reload of dm_topics updates config.extra too, so a topic added while
running stays its own session
- the shared copy uses session_identity.replace_source (keeps provenance)
- a rebuilt source with no live adapter ref (/loop, restored routes) reads the
answering bot's settings through the runner's delivery resolver
With BotFather Threaded Mode on, Telegram stamps a message_thread_id on
ordinary DM messages and build_session_key folds it into the DM key, so
one chat ran several concurrent sessions (one busy guard each): a
re-sent question started N parallel turns and N simultaneous final sends.
platforms.telegram.extra.dm_threads: shared drops the DM thread id from
the session key outside /topic lanes and declared dm_topics threads.
Default per_thread keeps the historical isolation; an unknown value warns
once and keeps per_thread. One helper (gateway/session_dm_threads.py) is
applied by every key builder: SessionStore._generate_session_key (store,
cron seeding, admission envelopes), the adapter batch/busy key, the
runner fallback key and the handoff key.
Fixes#107133