-
Notifications
You must be signed in to change notification settings - Fork 155
resolves #1907 bot_engine: implement coroutine-based stories #1908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vsct-jburet
merged 24 commits into
theopenconversationkit:master
from
Fabilin:1907-story-coroutines
Sep 24, 2025
Merged
resolves #1907 bot_engine: implement coroutine-based stories #1908
vsct-jburet
merged 24 commits into
theopenconversationkit:master
from
Fabilin:1907-story-coroutines
Sep 24, 2025
Conversation
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
1d75dbc to
dd180b6
Compare
Fabilin
commented
Sep 12, 2025
Member
Author
Fabilin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments after review by @vsct-jburet
vsct-jburet
reviewed
Sep 19, 2025
vsct-jburet
reviewed
Sep 19, 2025
vsct-jburet
reviewed
Sep 19, 2025
vsct-jburet
reviewed
Sep 19, 2025
vsct-jburet
reviewed
Sep 19, 2025
vsct-jburet
reviewed
Sep 19, 2025
vsct-jburet
approved these changes
Sep 22, 2025
9e7c6c9
into
theopenconversationkit:master
2 of 3 checks passed
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.
resolves #1907 by adding classes and utilities for executing stories on coroutines.
Note
All new elements are annotated with a new
@ExperimentalTockCoroutinesopt-in annotation, to avoid reliance while the API is still unstable.New
StoryDefinitionhierarchyclassDiagram class StoryDefinition { <<interface>> +StoryHandler storyHandler +Set[StoryStep] steps } class AsyncStoryDefinition { <<interface>> +AsyncStoryHandler storyHandler +Set[AsyncStoryStep] steps } class StoryHandler { <<interface>> } class AsyncStoryHandler { <<interface>> } class AsyncStoryHandlerBase { <<abstract>> } class AsyncDelegatingStoryHandlerBase { <<abstract>> } class AsyncConfigurableStoryHandler class StoryStepDef { <<interface>> } class StoryStep { <<interface>> } class AsyncStoryStep { <<interface>> } class AsyncStoryHandling { <<interface>> } class AsyncStoryHandlingBase { +AsyncConnectorHandling connector } class AsyncConnectorHandling { <<interface>> } class AsyncConnectorHandlingBase StoryDefinition <|.. AsyncStoryDefinition StoryDefinition o-- StoryHandler StoryDefinition o-- StoryStepDef AsyncStoryDefinition o-- AsyncStoryHandler AsyncStoryDefinition o-- AsyncStoryStep AsyncStoryHandler <|.. StoryHandler AsyncStoryHandlerBase ..|> AsyncStoryHandler AsyncDelegatingStoryHandlerBase ..|> AsyncStoryHandlerBase AsyncConfigurableStoryHandler --|> AsyncDelegatingStoryHandlerBase StoryStep <|.. StoryStepDef AsyncStoryStep <|.. StoryStepDef AsyncStoryHandlingBase ..|> AsyncStoryHandling AsyncStoryHandlingBase o-- AsyncConnectorHandling AsyncConnectorHandlingBase ..|> AsyncConnectorHandlingNew classes:
AsyncStoryDefinition:StoryDefinitionspecialized forAsyncStoryHandlerandAsyncStoryStepAsyncStoryHandler: subtype ofStoryHandlerwith a suspendinghandlemethod. It has special casing inStory.handle.AsyncStoryHandlerBase: the most basic implementation ofAsyncStoryHandler. The functionality present inStoryHandlerBaseis split between this class andAsyncDelegatingStoryHandlerBase.AsyncDelegatingStoryHandlerBase: a specialization ofAsyncStoryHandlerBasewhich handles preconditions, steps, and customAsyncStoryHandlingAsyncStoryHandling: equivalent toStoryHandlerDefinition. The naming scheme is changed to be shorter and somewhat more meaningful. Unlike the former, this interface does not directly extendAsyncBusnor require a connector instance, letting implementations decide if they want the utilities.AsyncStoryHandlingBase: equivalent toStoryHandlerDefinitionBase. Also implementsAsyncBusfor convenient access to its methods.AsyncConnectorHandling: equivalent toConnectorStoryHandler. The naming scheme is changed to be shorter and somewhat more meaningful. Unlike the former, this interface does not directly extendAsyncBus, letting implementations decide if they want the utilities.AsyncConnectorHandlingBase: equivalent toConnectorStoryHandlerBase. Tightly coupled toAsyncStoryHandlingBase, for type safety.Utilities
Executor.launchCoroutine: a new method to launch a coroutine from a TOCKExecutorDesign Decisions
AsyncBuslimits access toBotBus-specific data likeUserTimeline. The goal is to eventually have anAsyncClientBusimplementation for TOCK Bot API mode. Ideally,AsyncStoryStepandAsyncStoryHandlingcould also be used in a Bot API client.Backward Compatibility
Source incompatibilities
StoryStephas a new supertype, which is notably used byStoryDefinition. Some advanced code may need to update their typing when iterating through a story's steps.Binary incompatibilities
StoryStepDefinstead of aStoryStep<out StoryHandlerDefinition.This should not cause any source incompatibility.
Other
ConnectorHandlerannotation now allows anyConnectorSpecificHandling, not justConnectorStoryHandler. Third-party connector implementations should update their typing to allow use with async story handlers.TockConnectorController#handleActionalways run asynchronously in a Vert.x worker thread, whereas it previously ran on the calling thread unless the usertimeline was locked. This change is likely to reduce contention on event loop threads, which would be an improvement, but it may have other unintended effects.TockBotBusattempts to preserve coroutine scopes when switching between regular and async stories. This may cause thread starvations if too many story switches happen at once.