LemonCore. BindingResolver
(lemon_core v0.1.0)
View Source
Canonical binding resolver shared by gateway and channels.
Resolves bindings and settings for a given chat scope. Bindings map transport/chat/topic combinations to projects, engines, and queue modes.
Both LemonGateway.BindingResolver and LemonChannels.BindingResolver
delegate here after converting their local structs to LemonCore types.
Summary
Functions
Returns the project override for a given scope from the unified store table.
Looks up a project by id from dynamic store, then static config.
Resolve the agent_id for a given scope.
Resolves a binding for the given scope.
Resolves the working directory for a given scope based on project binding.
Resolves the engine to use for a given scope, hint, and resume token.
Resolves the queue mode for a given scope.
Functions
@spec get_project_override(LemonCore.ChatScope.t()) :: String.t() | nil
Returns the project override for a given scope from the unified store table.
Looks up a project by id from dynamic store, then static config.
The optional config_provider is a 0-arity function that returns
a %{projects: %{...}} map (used by gateway/channels to inject
their own config source).
@spec resolve_agent_id( LemonCore.ChatScope.t(), keyword() ) :: String.t()
Resolve the agent_id for a given scope.
If no binding exists or no agent_id is set, returns "default".
@spec resolve_binding( LemonCore.ChatScope.t(), keyword() ) :: LemonCore.Binding.t() | nil
Resolves a binding for the given scope.
Returns the most specific binding that matches:
- Topic-level binding (transport + chat_id + topic_id) takes precedence
- Falls back to chat-level binding (transport + chat_id)
- Returns nil if no binding matches
@spec resolve_cwd( LemonCore.ChatScope.t(), keyword() ) :: String.t() | nil
Resolves the working directory for a given scope based on project binding.
Returns the project root path if a binding with a project exists, nil otherwise.
@spec resolve_engine( LemonCore.ChatScope.t(), String.t() | nil, map() | nil, keyword() ) :: String.t() | nil
Resolves the engine to use for a given scope, hint, and resume token.
Priority order (highest to lowest):
- Resume token engine (from conversation continuation)
- Engine hint (from /engine command)
- Topic binding default_engine
- Chat binding default_engine
- Project default_engine
- Agent profile default_engine
- Global default_engine from config
@spec resolve_queue_mode( LemonCore.ChatScope.t(), keyword() ) :: atom() | nil
Resolves the queue mode for a given scope.
Returns the queue_mode from the binding, or nil if no binding or queue_mode is set.