Repository navigation
feat(telegram): ADR-0020 slice 1a TurnGate + mid-run steer - #170
Merged
Merged
Conversation
Introduce TurnGate (session_key, cap 10, QUEUE_FULL) so Telegram user turns serialize per key: submit → spawn loop → finish → User / StepLimit / Idle|Scheduled. Mid-run messages get 👀 Accepted and steer via drain A/B with a [Steer] prefix; /stop cancels and clears the queue. Wire SteerFn into loop_runner, drop dead apply_steer / pending_injections, and keep cancel_token_registry (gate serializes → one token per key). Update the Telegram Update injector to await gate idle after chat drives.
Owner
Author
TL ACCEPT — ADR-0020 slice 1a @ 301568cReviewed tip Passes
Out of scope (correctly left out)
Non-blocking follow-up (do not block 1a merge)
No merge/tag from TL. Same-account standing → this is the ACCEPT record (issue comment), not the Approve button. |
CodeQL rust/cleartext-logging flagged interpolating session_key into panic! in the Telegram injector harness (alert #26). Message no longer embeds the key.
Owner
Author
TL ACCEPT — tip
|
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
ADR-0020 slice 1a: mid-run message queue for Telegram user turns.
session_key(bot_id, user_id): at most one active turn; FIFO pending cap 10; full →QUEUE_FULLtext (never silent drop).Startspawn a loop that runsrun_telegram_user_turnthen finish →Next::User/StepLimit/Idle|Scheduled; onAcceptedreact 👀; onFullreply with the queue-full sentence.loop_runnerviaSteerFn/with_steer; queued text injected with a[Steer]prefix./stop: cancel processing andturn_gate.clear(report how many queued messages were cleared).ConversationManager::apply_steerandpending_injectionspath;lib.rsexportsturn_gate.Out of scope (later slices)
Note / deviation
cancel_token_registryis kept: the gate serializes turns per key, so there is still one cancel token per key.Refs: ADR-0020
Test plan / QA matrix
turn_gatemodule tests +tests/mid_run_steer.rscargo fmt --checkcargo clippy --locked --all-targets -- -D warningsenv -u RUSTFOX_GOOGLE_OAUTH_CLIENT_ID cargo test --locked(942 passed / 0 failed)/stopcancels and clears the queue