Skip to content

Features/add graph rule engine#1305

Open
iceljc wants to merge 98 commits intoSciSharp:masterfrom
iceljc:features/add-message-queue-3
Open

Features/add graph rule engine#1305
iceljc wants to merge 98 commits intoSciSharp:masterfrom
iceljc:features/add-message-queue-3

Conversation

@iceljc
Copy link
Collaborator

@iceljc iceljc commented Mar 10, 2026

No description provided.

@qodo-code-review
Copy link
Contributor

Review Summary by Qodo

Add graph-based rule engine with RabbitMQ message queue integration

✨ Enhancement

Grey Divider

Walkthroughs

Description
• **Graph-based rule engine**: Refactored RuleEngine to support graph-based rule execution with
  DFS/BFS traversal algorithms, enabling complex rule flows with multiple branches and synchronization
  points
• **RabbitMQ message queue integration**: Added complete RabbitMQ plugin with connection management,
  channel pooling, message publishing with retry policies, and consumer subscription handling
• **Rule flow topology system**: Implemented IRuleFlow interface for topology providers, allowing
  dynamic rule graph loading from graph databases like Membase
• **Rule actions and conditions**: Added ChatRuleAction, HttpRuleAction,
  FunctionCallRuleAction for rule execution, and LoopingCondition, AllVisitedRuleCondition for
  graph traversal control
• **Membase graph API**: Added REST endpoints for graph node and edge CRUD operations with demo rule
  graph implementation
• **Message queue abstraction**: Created IMQService interface with RabbitMQ implementation,
  supporting consumer subscription, message publishing with delayed delivery, and acknowledgment
  handling
• **Rule execution API**: Added RuleController endpoint for triggering rules with text and state
  parameters
• **Configuration updates**: Added RuleSettings, MessageQueueSettings, RabbitMQSettings for
  centralized configuration management
• **Utility enhancements**: Added dictionary extension methods for type-safe value retrieval with
  JSON deserialization support
• **Code execution context**: Enhanced instruction hooks with CodeExecutionContext parameter to
  track execution origin
• **Bug fixes**: Fixed Membase GraphDb null safety, Graph plugin error logging, and
  MembaseAuthHandler namespace location
Diagram
flowchart LR
  A["Rule Engine"] -->|executes| B["Rule Graph"]
  B -->|contains| C["Rule Nodes"]
  C -->|execute| D["Rule Actions"]
  C -->|evaluate| E["Rule Conditions"]
  D -->|ChatRuleAction| F["Agent Conversation"]
  D -->|HttpRuleAction| G["HTTP Requests"]
  D -->|FunctionCallRuleAction| H["Function Callbacks"]
  B -->|loaded by| I["IRuleFlow Providers"]
  I -->|Membase| J["Graph Database"]
  K["RabbitMQ Plugin"] -->|publishes| L["Message Queue"]
  K -->|consumes| M["Scheduled Messages"]
  L -->|delayed delivery| N["Message Consumers"]
Loading

Grey Divider

File Changes

1. src/Infrastructure/BotSharp.Core.Rules/Engines/RuleEngine.cs ✨ Enhancement +541/-107

Refactor RuleEngine to support graph-based rule execution

• Removed unused CodingSettings dependency and simplified constructor
• Refactored Triggered method to support graph-based rule execution with DFS/BFS traversal
 algorithms
• Added ExecuteGraphNode method with overloads for DFS and BFS graph traversal
• Implemented ExecuteAction and ExecuteCondition methods to execute rule actions and conditions
• Added helper methods GetRuleAction, GetRuleCondition, BuildParameters for rule execution
• Extracted legacy conversation handling into SendMessageToAgent method

src/Infrastructure/BotSharp.Core.Rules/Engines/RuleEngine.cs


2. src/Plugins/BotSharp.Plugin.Membase/Controllers/MembaseController.cs ✨ Enhancement +359/-1

Add graph node and edge management API endpoints

• Added IMembaseApi dependency injection to the controller
• Implemented GetGraphInfo endpoint to retrieve graph information
• Added node CRUD operations: GetNode, CreateNode, MergeNode, DeleteNode
• Added edge CRUD operations: GetEdge, CreateEdge, UpdateEdge, DeleteEdge
• All endpoints include proper error handling and validation

src/Plugins/BotSharp.Plugin.Membase/Controllers/MembaseController.cs


3. src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs ✨ Enhancement +332/-0

Add demo rule graph flow implementation

• New file implementing IRuleFlow<RuleGraph> for demo rule graph provider
• Provides topology configuration and loading from Membase graph database
• Builds RuleGraph from Cypher query results with nodes and edges
• Includes default graph generation for testing purposes

src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs


View more (78)
4. src/Plugins/BotSharp.Plugin.RabbitMQ/Services/RabbitMQService.cs ✨ Enhancement +318/-0

Add RabbitMQ message queue service implementation

• New file implementing IMQService for RabbitMQ message queue operations
• Supports consumer subscription/unsubscription with channel management
• Implements message publishing with retry policy and delayed delivery
• Handles message consumption with acknowledgment/nack logic

src/Plugins/BotSharp.Plugin.RabbitMQ/Services/RabbitMQService.cs


5. src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs ✨ Enhancement +225/-0

Add rule graph data model classes

• New file defining RuleGraph, RuleNode, RuleEdge classes for graph-based rules
• Provides graph operations: add nodes/edges, get root node, traverse parent/children
• Implements graph serialization/deserialization with RuleGraphInfo
• Supports graph clearing and node/edge filtering

src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs


6. src/Infrastructure/BotSharp.Core.Rules/Actions/HttpRuleAction.cs ✨ Enhancement +204/-0

Add HTTP request rule action implementation

• New file implementing IRuleAction for HTTP request execution
• Supports GET, POST, PUT, PATCH, DELETE HTTP methods
• Handles URL building with parameter substitution and query parameters
• Includes request headers and body support with response handling

src/Infrastructure/BotSharp.Core.Rules/Actions/HttpRuleAction.cs


7. src/Infrastructure/BotSharp.Core.Rules/Conditions/LoopingCondition.cs ✨ Enhancement +167/-0

Add looping condition for rule graph iteration

• New file implementing IRuleCondition for loop iteration logic
• Manages loop state with list items, current index, and current item
• Returns success when more items to iterate, false when loop completes
• Cleans up loop state parameters after completion

src/Infrastructure/BotSharp.Core.Rules/Conditions/LoopingCondition.cs


8. src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQConnection.cs ✨ Enhancement +154/-0

Add RabbitMQ connection management

• New file implementing IRabbitMQConnection for RabbitMQ connection management
• Handles connection creation with retry policy and automatic recovery
• Manages connection lifecycle events (shutdown, callback exceptions, blocked)
• Provides channel creation and connection state tracking

src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQConnection.cs


9. src/Plugins/BotSharp.Plugin.RabbitMQ/Controllers/RabbitMQController.cs ✨ Enhancement +89/-0

Add RabbitMQ message queue API controller

• New file providing REST API endpoints for message queue operations
• Implements PublishScheduledMessage endpoint for delayed message publishing
• Implements UnSubscribeConsumer endpoint for consumer unsubscription
• Includes error handling and request validation

src/Plugins/BotSharp.Plugin.RabbitMQ/Controllers/RabbitMQController.cs


10. src/Infrastructure/BotSharp.Core.Rules/Actions/ChatRuleAction.cs ✨ Enhancement +82/-0

Add chat message rule action implementation

• New file implementing IRuleAction for sending messages to agents
• Creates new conversation and sends user message to agent
• Manages conversation states and returns conversation ID
• Includes error handling and logging

src/Infrastructure/BotSharp.Core.Rules/Actions/ChatRuleAction.cs


11. src/Infrastructure/BotSharp.Abstraction/Utilities/ObjectExtensions.cs ✨ Enhancement +66/-0

Add dictionary extension methods for type-safe value retrieval

• Added TryGetValueOrDefault<T> extension for IDictionary<string, object?>
• Added TryGetValue<T> extension with support for JsonElement deserialization
• Added TryGetObjectValueOrDefault<T> extension for IDictionary<string, string?>
• Added TryGetObjectValue<T> extension for safe JSON deserialization from string dictionaries

src/Infrastructure/BotSharp.Abstraction/Utilities/ObjectExtensions.cs


12. src/Plugins/BotSharp.Plugin.RabbitMQ/RabbitMQPlugin.cs ✨ Enhancement +56/-0

Add RabbitMQ plugin initialization and configuration

• New file implementing IBotSharpAppPlugin for RabbitMQ plugin registration
• Registers RabbitMQSettings and MessageQueueSettings from configuration
• Conditionally registers IRabbitMQConnection and IMQService implementations
• Subscribes demo consumers in DEBUG mode

src/Plugins/BotSharp.Plugin.RabbitMQ/RabbitMQPlugin.cs


13. src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQChannelPool.cs ✨ Enhancement +73/-0

Add RabbitMQ channel pooling implementation

• New file implementing object pool for RabbitMQ channels
• Provides Get and Return methods for channel lifecycle management
• Implements IPooledObjectPolicy<IChannel> for pool configuration
• Handles closed channel detection and retry logic

src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQChannelPool.cs


14. src/Infrastructure/BotSharp.Core.Rules/Actions/FunctionCallRuleAction.cs ✨ Enhancement +54/-0

Add function call rule action implementation

• New file implementing IRuleAction for function callback execution
• Retrieves function by name from registered IFunctionCallback services
• Executes function with arguments from context parameters
• Returns function execution result and metadata

src/Infrastructure/BotSharp.Core.Rules/Actions/FunctionCallRuleAction.cs


15. src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs ⚙️ Configuration changes +23/-0

Register rule actions, conditions, and settings

• Added RuleSettings registration from configuration
• Registered IRuleAction implementations: ChatRuleAction, HttpRuleAction,
 FunctionCallRuleAction
• Registered IRuleCondition implementations in DEBUG mode: LoopingCondition,
 AllVisitedRuleCondition
• Registered IRuleTrigger demo implementation in DEBUG mode

src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs


16. src/Plugins/BotSharp.Plugin.RabbitMQ/Using.cs ⚙️ Configuration changes +38/-0

Add RabbitMQ plugin global using statements

• New file with global using statements for RabbitMQ plugin
• Includes namespaces for RabbitMQ infrastructure, messaging, and utilities
• Imports RabbitMQ-specific settings, models, interfaces, and consumers

src/Plugins/BotSharp.Plugin.RabbitMQ/Using.cs


17. src/Infrastructure/BotSharp.Core.Rules/Using.cs ⚙️ Configuration changes +23/-1

Expand global using statements for rules infrastructure

• Added Microsoft.Extensions.Logging and System.Text namespaces
• Added global usings for agents, conversations, and message queue abstractions
• Added global usings for rules, hooks, and coding abstractions
• Added global using for RuleConstant from Core.Rules

src/Infrastructure/BotSharp.Core.Rules/Using.cs


18. src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentRuleMongoElement.cs ✨ Enhancement +35/-3

Update agent rule MongoDB model to use config

• Replaced Criteria property with Config property of type RuleConfigMongoModel?
• Added RuleConfigMongoModel class with TopologyProvider property
• Updated mapping methods to convert between RuleConfig and RuleConfigMongoModel

src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentRuleMongoElement.cs


19. src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/MQConsumerBase.cs ✨ Enhancement +51/-0

Add abstract base class for message queue consumers

• New file providing abstract base class for message queue consumers
• Implements IMQConsumer interface with service provider and logger
• Defines abstract Config property and HandleMessageAsync method
• Includes disposal pattern implementation

src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/MQConsumerBase.cs


20. src/Infrastructure/BotSharp.Logger/Hooks/InstructionLogHook.cs ✨ Enhancement +4/-2

Update code execution hook signature with context

• Updated AfterCodeExecution method signature to include CodeExecutionContext parameter
• Added import for BotSharp.Abstraction.Coding.Contexts
• Updated method call to pass context along with response

src/Infrastructure/BotSharp.Logger/Hooks/InstructionLogHook.cs


21. src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/Models/MQPublishOptions.cs ✨ Enhancement +40/-0

Add message queue publish options model

• New file defining configuration options for message queue publishing
• Includes properties for topic name, routing key, delay, message ID, and arguments
• Provides JsonSerializerOptions for serialization control

src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/Models/MQPublishOptions.cs


22. src/Infrastructure/BotSharp.Core.Rules/Controllers/RuleController.cs ✨ Enhancement +42/-0

Add rule trigger execution API controller

• New file providing REST API endpoint for rule trigger execution
• Implements RunAction endpoint to trigger rules with text and states
• Includes request validation and trigger lookup

src/Infrastructure/BotSharp.Core.Rules/Controllers/RuleController.cs


23. src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/IMQService.cs ✨ Enhancement +31/-0

Add message queue service interface

• New file defining interface for message queue service operations
• Declares SubscribeAsync method for consumer subscription
• Declares UnsubscribeAsync method for consumer unsubscription
• Declares PublishAsync<T> method for message publishing

src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/IMQService.cs


24. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleEngine.cs ✨ Enhancement +13/-0

Add graph node execution method to rule engine

• Added ExecuteGraphNode method to interface for graph node execution
• Method accepts node, graph, agent ID, trigger, and execution options

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleEngine.cs


25. src/Infrastructure/BotSharp.Core.Rules/Conditions/AllVisitedRuleCondition.cs ✨ Enhancement +32/-0

Add all-visited condition for rule graph synchronization

• New file implementing IRuleCondition for checking if all parent nodes visited
• Evaluates to true when all parent nodes have been processed
• Used in graph traversal to synchronize multiple branches

src/Infrastructure/BotSharp.Core.Rules/Conditions/AllVisitedRuleCondition.cs


26. src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleTriggerOptions.cs ✨ Enhancement +7/-11

Refactor rule trigger options for graph execution

• Replaced code-related properties with rule flow properties
• Changed CodeProcessor, CodeScriptName, ArgumentName, ArgumentContent to AgentFilter,
 JsonOptions, Flow
• Added RuleFlowOptions property for graph-based rule execution

src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleTriggerOptions.cs


27. src/Plugins/BotSharp.Plugin.Membase/Interfaces/IMembaseApi.cs ✨ Enhancement +3/-3

Update Membase API interface and namespace

• Moved interface from Services namespace to Interfaces namespace
• Changed DeleteNodeAsync return type from Task<NodeDeleteResponse?> to Task
• Changed DeleteEdgeAsync return type from Task<EdgeDeleteResponse> to Task

src/Plugins/BotSharp.Plugin.Membase/Interfaces/IMembaseApi.cs


28. src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs ✨ Enhancement +13/-3

Update rule configuration API endpoint

• Replaced GetFormalizedRuleDefinition endpoint with GetRuleConfigOptions endpoint
• New endpoint returns dictionary of available rule flow topology configurations
• Retrieves configurations from all registered IRuleFlow<RuleGraph> implementations

src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs


29. src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleFlowOptions.cs ✨ Enhancement +29/-0

Add rule flow execution options model

• New file defining options for rule flow topology execution
• Includes topology provider, ID, and query properties
• Supports traversal algorithm selection (DFS/BFS)
• Provides custom parameters dictionary for flow configuration

src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleFlowOptions.cs


30. src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleNodeResult.cs ✨ Enhancement +29/-0

Add rule node execution result model

• New file defining result model for rule node execution
• Includes success flag, response content, and error message
• Provides data dictionary for action results and delayed execution flag

src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleNodeResult.cs


31. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleFlow.cs ✨ Enhancement +26/-0

Add rule flow topology provider interface

• New file defining interface for rule flow topology providers
• Declares Provider property for flow identification
• Declares GetTopologyConfigAsync method for configuration retrieval
• Declares GetTopologyAsync method for topology loading

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleFlow.cs


32. src/Plugins/BotSharp.Plugin.RabbitMQ/Models/RabbitMQConsumerConfig.cs ✨ Enhancement +24/-0

Add RabbitMQ consumer configuration model

• New file defining configuration model for RabbitMQ consumers
• Includes exchange name, queue name, routing key, and arguments
• Provides default values for RabbitMQ-specific settings

src/Plugins/BotSharp.Plugin.RabbitMQ/Models/RabbitMQConsumerConfig.cs


33. src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues 📦 Other +0/-0

src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues


34. src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleFlowStepResult.cs ✨ Enhancement +22/-0

Add RuleFlowStepResult model for rule flow execution

• New model class that extends RuleNodeResult with a Node property
• Includes factory method FromResult() to create instances from RuleNodeResult and RuleNode
• Copies result properties (Success, Response, ErrorMessage, Data, IsDelayed) to new instance

src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleFlowStepResult.cs


35. src/Plugins/BotSharp.Plugin.RabbitMQ/Consumers/ScheduledMessageConsumer.cs ✨ Enhancement +25/-0

Add ScheduledMessageConsumer for RabbitMQ delayed messages

• New consumer class extending MQConsumerBase for handling scheduled/delayed messages
• Configures RabbitMQ exchange, queue, and routing key
• Implements HandleMessageAsync() to log and process delayed messages

src/Plugins/BotSharp.Plugin.RabbitMQ/Consumers/ScheduledMessageConsumer.cs


36. src/Plugins/BotSharp.Plugin.RabbitMQ/Consumers/DummyMessageConsumer.cs ✨ Enhancement +24/-0

Add DummyMessageConsumer for RabbitMQ test messages

• New consumer class extending MQConsumerBase for dummy message handling
• Configures RabbitMQ exchange, queue, and routing key
• Implements HandleMessageAsync() to log and process dummy messages

src/Plugins/BotSharp.Plugin.RabbitMQ/Consumers/DummyMessageConsumer.cs


37. src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleFlowContext.cs ✨ Enhancement +18/-0

Add RuleFlowContext model for rule execution context

• New context model for rule flow execution containing text, parameters, and previous step results
• Includes JSON serialization options and references to rule graph components
• Provides context for both actions and conditions in rule flows

src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleFlowContext.cs


38. src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentRule.cs ✨ Enhancement +9/-2

Replace AgentRule criteria with config topology provider

• Replaced Criteria property with Config property of type RuleConfig?
• Added new RuleConfig class with TopologyProvider property
• Updated JSON property names and added conditional serialization

src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentRule.cs


39. src/Infrastructure/BotSharp.Core/Messaging/MessagingPlugin.cs ✨ Enhancement +18/-0

Add MessagingPlugin for message queue services

• New plugin class implementing IBotSharpPlugin for message queue services
• Registers MessageQueueSettings from configuration
• Provides dependency injection setup for messaging infrastructure

src/Infrastructure/BotSharp.Core/Messaging/MessagingPlugin.cs


40. src/Plugins/BotSharp.Plugin.Membase/GraphDb/MembaseGraphDb.cs 🐞 Bug fix +2/-1

Fix Membase GraphDb null safety and imports

• Added missing using statement for BotSharp.Plugin.Membase.Interfaces
• Added null-coalescing operator to options parameter in CypherQueryAsync() call

src/Plugins/BotSharp.Plugin.Membase/GraphDb/MembaseGraphDb.cs


41. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleFlowUnit.cs ✨ Enhancement +21/-0

Add IRuleFlowUnit interface for rule components

• New interface defining contract for rule flow units (actions, conditions)
• Includes properties for Name, AgentId, and Triggers with default implementations

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleFlowUnit.cs


42. src/Infrastructure/BotSharp.Abstraction/Instructs/IInstructHook.cs ✨ Enhancement +1/-1

Add CodeExecutionContext parameter to AfterCodeExecution hook

• Updated AfterCodeExecution() method signature to include CodeExecutionContext parameter
• Allows hooks to access execution context in addition to response

src/Infrastructure/BotSharp.Abstraction/Instructs/IInstructHook.cs


43. src/Infrastructure/BotSharp.Core.Rules/Models/RuleTriggerActionRequest.cs ✨ Enhancement +18/-0

Add RuleTriggerActionRequest model for rule triggers

• New request model for rule trigger actions with trigger name and text
• Includes optional states and options for rule execution
• Uses JSON property name attributes for serialization

src/Infrastructure/BotSharp.Core.Rules/Models/RuleTriggerActionRequest.cs


44. src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQChannelPoolFactory.cs ✨ Enhancement +13/-0

Add RabbitMQChannelPoolFactory for connection pooling

• New factory class for managing RabbitMQ channel pools
• Uses ConcurrentDictionary to cache pools by connection string
• Provides thread-safe pool retrieval and creation

src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQChannelPoolFactory.cs


45. src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/Models/MQMessage.cs ✨ Enhancement +14/-0

Add MQMessage generic model for queue messages

• New generic message model for message queue operations
• Includes payload, message ID, and creation timestamp
• Constructor initializes payload and message ID

src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/Models/MQMessage.cs


46. src/Plugins/BotSharp.Plugin.RabbitMQ/Settings/RabbitMQSettings.cs ⚙️ Configuration changes +10/-0

Add RabbitMQSettings for connection configuration

• New settings class for RabbitMQ connection configuration
• Includes hostname, port, credentials, and virtual host with defaults

src/Plugins/BotSharp.Plugin.RabbitMQ/Settings/RabbitMQSettings.cs


47. src/Infrastructure/BotSharp.Core.Rules/Constants/RuleConstant.cs ✨ Enhancement +17/-0

Add RuleConstant for rule flow configuration

• New constants class defining rule flow behavior limits and node types
• Defines max recursion depth and lists condition/action node types

src/Infrastructure/BotSharp.Core.Rules/Constants/RuleConstant.cs


48. src/Infrastructure/BotSharp.Core.Rules/Models/RuleMessagePayload.cs ✨ Enhancement +11/-0

Add RuleMessagePayload for rule message data

• New payload model for rule-triggered messages
• Contains agent ID, trigger name, channel, text, states, and timestamp

src/Infrastructure/BotSharp.Core.Rules/Models/RuleMessagePayload.cs


49. src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Conversation.cs Formatting +1/-2

Simplify conversation truncation query logic

• Simplified LINQ query by combining two Where() clauses into single condition
• Improved code readability without changing functionality

src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Conversation.cs


50. src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleNodeExecutionOptions.cs ✨ Enhancement +11/-0

Add RuleNodeExecutionOptions for node execution config

• New options class for rule node execution configuration
• Includes text, message states, JSON options, and flow options

src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleNodeExecutionOptions.cs


51. src/Infrastructure/BotSharp.Abstraction/Instructs/InstructHookBase.cs ✨ Enhancement +1/-1

Update InstructHookBase with CodeExecutionContext parameter

• Updated AfterCodeExecution() method signature to include CodeExecutionContext parameter
• Maintains backward compatibility with async implementation

src/Infrastructure/BotSharp.Abstraction/Instructs/InstructHookBase.cs


52. src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleFlowLoadOptions.cs ✨ Enhancement +9/-0

Add RuleFlowLoadOptions for rule flow loading

• New options class for loading rule flows with agent ID and trigger name
• Includes optional query and parameters for dynamic rule loading

src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleFlowLoadOptions.cs


53. src/Infrastructure/BotSharp.Core.Rules/DemoRuleTrigger.cs ✨ Enhancement +10/-0

Add DemoRuleTrigger for rule trigger demonstration

• New demo trigger implementation of IRuleTrigger interface
• Defines crontab channel with demo entity type and ID

src/Infrastructure/BotSharp.Core.Rules/DemoRuleTrigger.cs


54. src/Plugins/BotSharp.Plugin.Graph/GraphDb.cs 🐞 Bug fix +1/-1

Fix Graph plugin error logging message

• Updated error log message to use generic Provider variable instead of hardcoded "Lessen GLM"
• Improves log message flexibility for different graph database providers

src/Plugins/BotSharp.Plugin.Graph/GraphDb.cs


55. src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleConfigModel.cs ✨ Enhancement +10/-0

Add RuleConfigModel for rule configuration data

• New model for rule configuration with topology ID and provider
• Includes custom parameters as JSON document with empty object default

src/Infrastructure/BotSharp.Abstraction/Rules/Models/RuleConfigModel.cs


56. src/Plugins/BotSharp.Plugin.RabbitMQ/Interfaces/IRabbitMQConnection.cs ✨ Enhancement +11/-0

Add IRabbitMQConnection interface for RabbitMQ connections

• New interface defining RabbitMQ connection contract
• Includes connection status, channel creation, and connection methods

src/Plugins/BotSharp.Plugin.RabbitMQ/Interfaces/IRabbitMQConnection.cs


57. src/Plugins/BotSharp.Plugin.RabbitMQ/Models/ScheduledMessagePayload.cs ✨ Enhancement +9/-0

Add ScheduledMessagePayload for delayed messages

• New payload model for scheduled/delayed messages
• Contains message name property

src/Plugins/BotSharp.Plugin.RabbitMQ/Models/ScheduledMessagePayload.cs


58. src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleFlowConfigOptions.cs ✨ Enhancement +7/-0

Add RuleFlowConfigOptions for flow configuration

• New options class for rule flow configuration
• Includes topology ID and purpose properties

src/Infrastructure/BotSharp.Abstraction/Rules/Options/RuleFlowConfigOptions.cs


59. src/Infrastructure/BotSharp.Abstraction/Coding/Contexts/CodeExecutionContext.cs ✨ Enhancement +1/-0

Add InvokeFrom property to CodeExecutionContext

• Added InvokeFrom property to track execution origin
• Allows context to identify where code execution was triggered from

src/Infrastructure/BotSharp.Abstraction/Coding/Contexts/CodeExecutionContext.cs


60. src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/MessageQueueSettings.cs ⚙️ Configuration changes +7/-0

Add MessageQueueSettings for queue configuration

• New settings class for message queue configuration
• Includes enabled flag and provider selection

src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/MessageQueueSettings.cs


61. src/Plugins/BotSharp.Plugin.Membase/Handlers/MembaseAuthHandler.cs 🐞 Bug fix +1/-1

Fix MembaseAuthHandler namespace location

• Changed namespace from BotSharp.Plugin.Membase.Services to BotSharp.Plugin.Membase.Handlers
• Corrects handler class location in namespace hierarchy

src/Plugins/BotSharp.Plugin.Membase/Handlers/MembaseAuthHandler.cs


62. src/Plugins/BotSharp.Plugin.Membase/Models/Requests/EdgeUpdateModel.cs ✨ Enhancement +1/-0

Add Id property to EdgeUpdateModel

• Added optional Id property to edge update model
• Allows specifying edge ID during updates

src/Plugins/BotSharp.Plugin.Membase/Models/Requests/EdgeUpdateModel.cs


63. src/Plugins/BotSharp.Plugin.Membase/Services/MembaseService.cs ✨ Enhancement +1/-0

Add Membase Interfaces using statement

• Added using statement for BotSharp.Plugin.Membase.Interfaces
• Prepares for interface usage in service implementation

src/Plugins/BotSharp.Plugin.Membase/Services/MembaseService.cs


64. src/Plugins/BotSharp.Plugin.RabbitMQ/Models/UnsubscribeConsumerRequest.cs ✨ Enhancement +6/-0

Add UnsubscribeConsumerRequest for consumer management

• New request model for unsubscribing consumers
• Contains consumer name property

src/Plugins/BotSharp.Plugin.RabbitMQ/Models/UnsubscribeConsumerRequest.cs


65. src/Infrastructure/BotSharp.Abstraction/Rules/Settings/RuleSettings.cs ✨ Enhancement +5/-0

Add RuleSettings for rule configuration

• New empty settings class for rule configuration
• Placeholder for future rule-related settings

src/Infrastructure/BotSharp.Abstraction/Rules/Settings/RuleSettings.cs


66. BotSharp.sln ⚙️ Configuration changes +11/-0

Add RabbitMQ plugin project to solution

• Added new BotSharp.Plugin.RabbitMQ project to solution
• Configured project build configurations for Debug and Release
• Added project dependency mapping

BotSharp.sln


67. src/WebStarter/appsettings.json ⚙️ Configuration changes +26/-1

Add Rules and RabbitMQ configuration to appsettings

• Added Rules configuration section with graph topology providers
• Added MessageQueue settings with enabled flag and RabbitMQ provider
• Added RabbitMQ connection settings (hostname, port, credentials)
• Added BotSharp.Core.Rules and BotSharp.Plugin.RabbitMQ to plugin loader assemblies

src/WebStarter/appsettings.json


68. Directory.Packages.props Dependencies +1/-0

Add RabbitMQ.Client package dependency

• Added RabbitMQ.Client package version 7.2.0 to centralized package management

Directory.Packages.props


69. src/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/agent.json ⚙️ Configuration changes +6/-1

Add rules configuration to demo agent

• Added rules array to agent configuration
• Includes demo rule trigger with DemoRuleTrigger name

src/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/agent.json


70. src/Plugins/BotSharp.Plugin.RabbitMQ/BotSharp.Plugin.RabbitMQ.csproj ⚙️ Configuration changes +22/-0

Add RabbitMQ plugin project file

• New project file for RabbitMQ plugin
• References Polly and RabbitMQ.Client packages
• Depends on BotSharp.Abstraction project

src/Plugins/BotSharp.Plugin.RabbitMQ/BotSharp.Plugin.RabbitMQ.csproj


71. src/WebStarter/WebStarter.csproj ⚙️ Configuration changes +1/-0

Add RabbitMQ plugin reference to WebStarter

• Added project reference to BotSharp.Plugin.RabbitMQ

src/WebStarter/WebStarter.csproj


72. src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/IMQConsumer.cs Additional files +21/-0

...

src/Infrastructure/BotSharp.Abstraction/Infrastructures/MessageQueues/IMQConsumer.cs


73. src/Infrastructure/BotSharp.Abstraction/Rules/Hooks/IRuleTriggerHook.cs Additional files +13/-0

...

src/Infrastructure/BotSharp.Abstraction/Rules/Hooks/IRuleTriggerHook.cs


74. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleAction.cs Additional files +18/-2

...

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleAction.cs


75. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleCondition.cs Additional files +22/-0

...

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleCondition.cs


76. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleConfig.cs Additional files +0/-5

...

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleConfig.cs


77. src/Infrastructure/BotSharp.Abstraction/Rules/IRuleCriteria.cs Additional files +0/-5

...

src/Infrastructure/BotSharp.Abstraction/Rules/IRuleCriteria.cs


78. src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs Additional files +1/-1

...

src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs


79. src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs Additional files +8/-0

...

src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs


80. src/Plugins/BotSharp.Plugin.Membase/Settings/MembaseSettings.cs Additional files +19/-0

...

src/Plugins/BotSharp.Plugin.Membase/Settings/MembaseSettings.cs


81. src/Plugins/BotSharp.Plugin.RabbitMQ/Models/PublishDelayedMessageRequest.cs Additional files +31/-0

...

src/Plugins/BotSharp.Plugin.RabbitMQ/Models/PublishDelayedMessageRequest.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Mar 10, 2026

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (5) 📎 Requirement gaps (0)

Grey Divider


Action required

1. GetGraphInfo() leaks internal lists📘 Rule violation ⛯ Reliability
Description
RuleGraph.GetGraphInfo() returns internal _nodes/_edges list references, allowing external
mutation and cross-call side effects. This violates the defensive-copy requirement for
caller/response collections before exposure or mutation.
Code

src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs[R133-140]

+    public RuleGraphInfo GetGraphInfo()
+    {
+        return new()
+        {
+            GraphId = _id,
+            Nodes = _nodes,
+            Edges = _edges
+        };
Evidence
The compliance rule requires defensive copies to avoid shared mutable state. The code returns
_nodes and _edges directly via RuleGraphInfo, exposing internal mutable collections to
callers.

src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs[133-140]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`RuleGraph.GetGraphInfo()` exposes internal mutable `_nodes` and `_edges` lists via `RuleGraphInfo`, enabling external callers to mutate internal state.
## Issue Context
Compliance requires defensive copies of collections before exposing/assigning them to prevent shared mutable references.
## Fix Focus Areas
- src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs[133-140]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. AddEdge() stores shared collections📘 Rule violation ⛯ Reliability
Description
RuleGraph.AddEdge() assigns payload.Labels and payload.Config directly into the new
RuleEdge, preserving shared mutable references. Mutations to the payload collections after the
call can unintentionally mutate graph edges.
Code

src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs[R106-115]

+            _edges.Add(new RuleEdge(from, to)
+            {
+                Id = payload.Id,
+                Name = payload.Name,
+                Type = payload.Type,
+                Labels = payload.Labels,
+                Weight = payload.Weight,
+                Purpose = payload.Purpose,
+                Config = payload.Config
+            });
Evidence
The rule prohibits reusing caller-provided collection instances without copying. The edge object
directly reuses payload.Labels and payload.Config references.

src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs[106-115]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`RuleGraph.AddEdge()` assigns collection properties from `payload` directly onto the edge, creating shared mutable references.
## Issue Context
Compliance requires defensive copies of caller/response collections before mutation or assignment to prevent cross-request side effects.
## Fix Focus Areas
- src/Infrastructure/BotSharp.Abstraction/Agents/Models/RuleGraph.cs[106-115]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Plugin Configure() blocks async 📘 Rule violation ⛯ Reliability
Description
RabbitMQPlugin.Configure() synchronously blocks on SubscribeAsync using
GetAwaiter().GetResult(), which is deadlock-prone and can delay app startup or hang under certain
synchronization contexts. This violates the async/deadlock avoidance requirement.
Code

src/Plugins/BotSharp.Plugin.RabbitMQ/RabbitMQPlugin.cs[R41-52]

+            // Create and subscribe the consumer using the abstract interface
+            var scheduledConsumer = new ScheduledMessageConsumer(sp, loggerFactory.CreateLogger<ScheduledMessageConsumer>());
+            mqService.SubscribeAsync(nameof(ScheduledMessageConsumer), scheduledConsumer)
+                .ConfigureAwait(false)
+                .GetAwaiter()
+                .GetResult();
+
+            var dummyConsumer = new DummyMessageConsumer(sp, loggerFactory.CreateLogger<DummyMessageConsumer>());
+            mqService.SubscribeAsync(nameof(DummyMessageConsumer), dummyConsumer)
+                .ConfigureAwait(false)
+                .GetAwaiter()
+                .GetResult();
Evidence
The compliance rule prohibits deadlock-prone async blocking. The plugin uses sync waiting
(GetResult()) on async subscription calls during configuration.

src/Plugins/BotSharp.Plugin.RabbitMQ/RabbitMQPlugin.cs[41-52]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`RabbitMQPlugin.Configure()` blocks on async `SubscribeAsync` calls using `GetAwaiter().GetResult()`, which can deadlock and stall startup.
## Issue Context
Compliance requires avoiding deadlock-prone async patterns.
## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.RabbitMQ/RabbitMQPlugin.cs[41-52]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (6)
4. options!.GraphId null-forgiving deref 📘 Rule violation ⛯ Reliability
Description
MembaseGraphDb.ExecuteQueryAsync uses options!.GraphId, which can throw if options is null at
this system boundary. A null/empty guard with a safe fallback/error is required for robustness.
Code

src/Plugins/BotSharp.Plugin.Membase/GraphDb/MembaseGraphDb.cs[42]

+            var response = await _membaseApi.CypherQueryAsync(options!.GraphId, new CypherQueryRequest
Evidence
The compliance rule requires explicit null guards at system boundaries. The code explicitly
suppresses nullability and dereferences options without a guard.

src/Plugins/BotSharp.Plugin.Membase/GraphDb/MembaseGraphDb.cs[42-42]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`ExecuteQueryAsync` uses `options!.GraphId` which can throw if `options` is null (or GraphId is empty), without an explicit guard.
## Issue Context
This is a boundary call to an external API (`_membaseApi`), and compliance requires explicit null/empty guards with safe fallbacks.
## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/GraphDb/MembaseGraphDb.cs[42-42]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Rules config section mismatch📘 Rule violation ✓ Correctness
Description
Configuration adds a Rules section in appsettings.json, but RulesPlugin binds settings from
Rule, creating contract drift and likely leaving settings unbound. This breaks the single source
of truth and consistent configuration matching requirement.
Code

src/WebStarter/appsettings.json[R739-745]

+  "Rules": {
+    "ConfigOptions": {
+      "Graph": [
+        "membase"
+      ]
+    }
+  },
Evidence
The compliance rule requires consistent configuration contracts. The app config section name
(Rules) does not match the plugin binding key (Rule), so configuration will not bind as
intended.

src/WebStarter/appsettings.json[739-745]
src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs[22-25]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The configuration section name in `appsettings.json` (`Rules`) does not match the section name used by DI binding (`Rule`), causing settings to be unbound or inconsistent.
## Issue Context
Compliance requires configuration/contracts to be consistent and robustly matched.
## Fix Focus Areas
- src/WebStarter/appsettings.json[739-745]
- src/Infrastructure/BotSharp.Core.Rules/RulesPlugin.cs[22-25]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Trigger API ignores result 🐞 Bug ✓ Correctness
Description
RuleController.RunAction awaits IRuleEngine.Triggered(...) (which returns conversation IDs) but
always responds with Success=true and discards the result. Clients cannot detect failures or
retrieve created conversation IDs.
Code

src/Infrastructure/BotSharp.Core.Rules/Controllers/RuleController.cs[R39-40]

+        var result = await _ruleEngine.Triggered(trigger, request.Text, request.States, request.Options);
+        return Ok(new { Success = true });
Evidence
The controller computes Triggered(...)'s return value but never returns it; the interface confirms
Triggered returns IEnumerable<string> (conversation IDs).

src/Infrastructure/BotSharp.Core.Rules/Controllers/RuleController.cs[25-41]
src/Infrastructure/BotSharp.Abstraction/Rules/IRuleEngine.cs[5-18]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`RuleController.RunAction` discards the return value from `IRuleEngine.Triggered(...)` and always returns `{ Success = true }`, preventing clients from obtaining conversation IDs and from detecting execution failures.
### Issue Context
`IRuleEngine.Triggered` returns `IEnumerable&amp;amp;amp;amp;amp;lt;string&amp;amp;amp;amp;amp;gt;`.
### Fix Focus Areas
- src/Infrastructure/BotSharp.Core.Rules/Controllers/RuleController.cs[25-41]
- src/Infrastructure/BotSharp.Abstraction/Rules/IRuleEngine.cs[5-18]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Wrong graph property mapping🐞 Bug ✓ Correctness
Description
DemoRuleGraph.BuildGraph assigns target node Purpose from source node properties and assigns edge
Name/Type/Purpose from node properties instead of edge properties. This corrupts the loaded topology
metadata, which can lead to wrong node/edge classification during rule execution.
Code

src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs[R174-194]

+            // Create target node
+            var targetNode = new RuleNode()
+            {
+                Id = targetNodeId ?? Guid.NewGuid().ToString(),
+                Labels = targetNodeLabels,
+                Name = GetGraphItemAttribute(targetNodeProps, key: "name", defaultValue: "node"),
+                Type = GetGraphItemAttribute(targetNodeProps, key: "type", defaultValue: "action"),
+                Purpose = GetGraphItemAttribute(sourceNodeProps, key: "purpose", defaultValue: "empty"),
+                Config = GetConfig(targetNodeProps)
+            };
+
+            // Create edge payload
+            var edgePayload = new GraphItemPayload()
+            {
+                Id = edgeId ?? Guid.NewGuid().ToString(),
+                Name = GetGraphItemAttribute(targetNodeProps, key: "name", defaultValue: "edge"),
+                Type = GetGraphItemAttribute(targetNodeProps, key: "type", defaultValue: "next"),
+                Purpose = GetGraphItemAttribute(sourceNodeProps, key: "purpose", defaultValue: "empty"),
+                Weight = edgeWeight,
+                Config = GetConfig(edgeProps)
+            };
Evidence
The code explicitly reads attributes for the target node and edge payload from the wrong JsonElement
variables (sourceNodeProps/targetNodeProps instead of targetNodeProps/edgeProps).

src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs[174-194]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`DemoRuleGraph.BuildGraph` maps target node and edge metadata from incorrect JSON sources, corrupting the resulting `RuleGraph`.
### Issue Context
The graph query returns `a` (source node), `b` (target node), `r` (edge). Node attributes should come from the node&amp;amp;amp;amp;amp;#x27;s `properties`, and edge attributes should come from the edge&amp;amp;amp;amp;amp;#x27;s `properties`.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs[174-194]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. API key leaked in URL 🐞 Bug ⛨ Security
Description
DemoRuleGraph.GetTopologyConfigAsync embeds MembaseSettings.ApiKey into a URL (token=...) inside
RuleConfigModel.CustomParameters. AgentController.GetRuleConfigOptions returns these configs to API
callers, leaking the API key to clients.
Code

src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs[R30-58]

+        var settings = _services.GetRequiredService<MembaseSettings>();
+        var apiKey = settings.ApiKey;
+        var projectId = settings.ProjectId;
+
+        var foundInstance = settings.GraphInstances?.FirstOrDefault(x => x.Id.IsEqualTo(options?.TopologyId));
+        if (foundInstance == null && !string.IsNullOrEmpty(options?.Purpose))
+        {
+            foundInstance = settings.GraphInstances?.FirstOrDefault(x => x.Purpose.IsEqualTo(options.Purpose));
+        }
+
+        if (foundInstance == null)
+        {
+            // default
+            foundInstance = settings.GraphInstances?.FirstOrDefault(x => x.Purpose.IsEqualTo("rule"));
+        }
+
+        var graphId = foundInstance?.Id ?? string.Empty;
+        var query = Uri.EscapeDataString("MATCH (a)-[r]->(b) WITH a, r, b WHERE a.agent = $agent AND a.trigger = $trigger AND b.agent = $agent AND b.trigger = $trigger RETURN a, r, b LIMIT 100");
+
+        return new RuleConfigModel
+        {
+            TopologyProvider = Provider,
+            TopologyId = graphId,
+            CustomParameters = JsonDocument.Parse(JsonSerializer.Serialize(new
+            {
+                htmlTag = "iframe",
+                appendParameterName = "parameters",
+                url = $"https://console.membase.dev/query-editor/{projectId}?graphId={graphId}&query={query}&token={apiKey}"
+            }))
Evidence
The provider constructs a URL containing the ApiKey and returns it in
RuleConfigModel.CustomParameters; the OpenAPI controller returns RuleConfigModel objects directly
from /rule/config/options.

src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs[30-59]
src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs[22-35]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A long-lived secret (`MembaseSettings.ApiKey`) is embedded into a URL and returned to clients via `/rule/config/options`, leaking credentials.
### Issue Context
`GetRuleConfigOptions` returns `RuleConfigModel.CustomParameters` as-is.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/Services/DemoRuleGraph.cs[30-59]
- src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs[22-35]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Unchecked RabbitMQ connect result 🐞 Bug ⛯ Reliability
Description
RabbitMQService.PublishAsync calls ConnectAsync without checking whether it succeeded, then
unconditionally creates/uses a channel pool keyed by rabbitMQConnection.Connection.ToString(). If
ConnectAsync fails, Connection remains null and this path can throw NullReferenceException and fail
publishing unreliably.
Code

src/Plugins/BotSharp.Plugin.RabbitMQ/Services/RabbitMQService.cs[R189-200]

+            if (!_mqConnection.IsConnected)
+            {
+                await _mqConnection.ConnectAsync();
+            }
+
+            var isPublished = false;
+            var policy = BuildRetryPolicy();
+            await policy.Execute(async () =>
+            {
+                var channelPool = RabbitMQChannelPoolFactory.GetChannelPool(_services, _mqConnection);
+                var channel = channelPool.Get();
+
Evidence
ConnectAsync returns a bool but its result is ignored; the channel pool factory dereferences
rabbitMQConnection.Connection for ToString(), and RabbitMQConnection exposes Connection without null
guard while _connection is uninitialized until a successful connection.

src/Plugins/BotSharp.Plugin.RabbitMQ/Services/RabbitMQService.cs[189-200]
src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQChannelPoolFactory.cs[5-12]
src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQConnection.cs[17-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PublishAsync` proceeds even if `ConnectAsync` fails, and the channel pool factory dereferences `rabbitMQConnection.Connection` to build its key. This can throw and/or cause unreliable publishing when RabbitMQ is unavailable.
### Issue Context
`ConnectAsync()` returns `bool` but callers ignore it.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.RabbitMQ/Services/RabbitMQService.cs[189-200]
- src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQChannelPoolFactory.cs[5-12]
- src/Plugins/BotSharp.Plugin.RabbitMQ/Connections/RabbitMQConnection.cs[17-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant