Package at.aimon.session.web.internal
Class BindingResolver
java.lang.Object
at.aimon.session.web.internal.BindingResolver
Resolves and validates the
agentRef bound to a ConversationId.
Implements design §3.6: the binding is a sole-writer field on the conversation; only the manager writes it. Reads
use a small in-memory cache backed by the ConversationRepository to avoid hitting persistent storage on
every submit. The cache stores positive results only — a missing binding always re-checks the repository.
After successful first-turn binding, callers invoke recordBinding(ConversationId, String) so subsequent
submits hit the cache directly.
-
Constructor Summary
ConstructorsConstructorDescriptionBindingResolver(at.aimon.core.agent.conversation.ConversationRepository repository) -
Method Summary
Modifier and TypeMethodDescriptionvoidinvalidate(at.aimon.core.agent.conversation.ConversationId conversationId) Drop the cached binding forconversationId.voidrecordBinding(at.aimon.core.agent.conversation.ConversationId conversationId, String agentRef) Record the binding forconversationIdafter a successful first-turn lock acquisition.resolveAndValidate(at.aimon.core.agent.conversation.ConversationId conversationId, String requestedAgentRef) Validate thatrequestedAgentRefis compatible with the conversation's current binding.
-
Constructor Details
-
BindingResolver
public BindingResolver(at.aimon.core.agent.conversation.ConversationRepository repository)
-
-
Method Details
-
resolveAndValidate
public Optional<String> resolveAndValidate(at.aimon.core.agent.conversation.ConversationId conversationId, String requestedAgentRef) Validate thatrequestedAgentRefis compatible with the conversation's current binding.Three cases:
- No binding exists yet (first turn) — returns empty
Optional. - Binding exists and matches — returns
Optional.of(existing). - Binding exists and differs — throws
ConflictingAgentException.
- Parameters:
conversationId- target conversation (must not be null)requestedAgentRef- the agent ref carried by the request (must not be null)- Returns:
- the existing binding, or empty when this is the first turn
- No binding exists yet (first turn) — returns empty
-
recordBinding
public void recordBinding(at.aimon.core.agent.conversation.ConversationId conversationId, String agentRef) Record the binding forconversationIdafter a successful first-turn lock acquisition. Updates the persistentagentReffield and refreshes the in-memory cache.- Parameters:
conversationId- the conversation (must not be null)agentRef- the agent ref to bind (must not be null)
-
invalidate
public void invalidate(at.aimon.core.agent.conversation.ConversationId conversationId) Drop the cached binding forconversationId. Called fromWebAgentSessionManager.releaseConversation(ConversationId)and when a stale binding is suspected (e.g. afterConflictingAgentException).- Parameters:
conversationId- the conversation (must not be null)
-