Summary
Currently ChatSessionRepositoryImpl is not created by auto-configuration — consuming apps (e.g., guide) must construct it manually in their @Configuration classes. This means they need to explicitly pass ApplicationEventPublisher (and any future dependencies) to the constructor, which is easy to miss.
Current Behavior
The autoconfigure provides:
StoredConversationFactory
SessionEventAwaiter
InMemoryConversationFactory
ConversationFactoryProvider
But not ChatSessionRepository. Apps must create it themselves:
@Bean
fun chatSessionRepository(
@Qualifier("neoGraphObjectManager") graphObjectManager: GraphObjectManager,
eventPublisher: ApplicationEventPublisher
): ChatSessionRepository {
return ChatSessionRepositoryImpl(graphObjectManager, eventPublisher)
}
Proposed Behavior
The autoconfigure should provide a default ChatSessionRepository bean (@ConditionalOnMissingBean) that:
- Accepts a
GraphObjectManager (or connection properties like spring.neo4j.uri, spring.neo4j.authentication.*)
- Auto-injects
ApplicationEventPublisher for SessionCreatedEvent publishing
- Can be overridden by apps that need custom setup
Apps would only need to provide:
- Connection properties or a compatible
GraphObjectManager bean
- Subtype registrations (e.g.,
PersistenceManager.registerSubtype) for their user types
Context
This came up while fixing a race condition where StoredConversation.addMessageInternal tried to persist a message before the session existed. The fix (SessionEventAwaiter + SessionCreatedEvent) requires ChatSessionRepositoryImpl to have the eventPublisher — which was missed in the guide's manual construction until caught during review.
Summary
Currently
ChatSessionRepositoryImplis not created by auto-configuration — consuming apps (e.g., guide) must construct it manually in their@Configurationclasses. This means they need to explicitly passApplicationEventPublisher(and any future dependencies) to the constructor, which is easy to miss.Current Behavior
The autoconfigure provides:
StoredConversationFactorySessionEventAwaiterInMemoryConversationFactoryConversationFactoryProviderBut not
ChatSessionRepository. Apps must create it themselves:Proposed Behavior
The autoconfigure should provide a default
ChatSessionRepositorybean (@ConditionalOnMissingBean) that:GraphObjectManager(or connection properties likespring.neo4j.uri,spring.neo4j.authentication.*)ApplicationEventPublisherforSessionCreatedEventpublishingApps would only need to provide:
GraphObjectManagerbeanPersistenceManager.registerSubtype) for their user typesContext
This came up while fixing a race condition where
StoredConversation.addMessageInternaltried to persist a message before the session existed. The fix (SessionEventAwaiter + SessionCreatedEvent) requiresChatSessionRepositoryImplto have theeventPublisher— which was missed in the guide's manual construction until caught during review.