Refactor EndNodeTemplate configuration to deployment specific#183
Refactor EndNodeTemplate configuration to deployment specific#183sthanikan2000 wants to merge 1 commit intoOpenNSW:mainfrom
Conversation
Summary of ChangesHello @sthanikan2000, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request aims to improve the maintainability and flexibility of the workflow engine by decoupling the EndNode configuration from the core logic. By using a template-driven approach, the EndNode behavior can be managed through database entries, aligning it with other workflow templates and reducing the need for code changes when EndNode configurations evolve. Highlights
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the EndNode configuration to be template-driven, which is a great improvement for maintainability by removing the hardcoded UUID. The changes are generally well-structured and align with the goal of making the EndNode a first-class template type. I have identified a few areas for improvement, including a potential unintended API change (with implications for template-to-instance mapping), a typo, and some issues with test coverage and correctness (also related to template-to-instance mapping). Please review the specific comments for details.
I am having trouble creating individual review comments. Click here to see my feedback.
backend/internal/workflow/service/consignment_service.go (582-585)
This change removes the filtering of the EndNode from the ConsignmentDetailDTO. While the PR aims to treat EndNode as a first-class citizen, this alters the API response by exposing a node that was previously considered an internal implementation detail, as indicated by the removed comment. This could be a breaking change for API consumers. As per the rule regarding template ID to node instance ID mapping, changes in how template-driven nodes are exposed should be carefully considered for their impact on external interfaces. Was this change in the API response intentional? If so, it would be beneficial to document it.
References
- When mapping template IDs to node instance IDs, ensure that each template ID corresponds to a single node instance. If duplicate templates are supported, the mapping should handle multiple instances or use a different resolution strategy.
backend/internal/workflow/service/consignment_service_test.go (442)
This test mock appears to be incorrect. After the consignment is marked as FINISHED, this subsequent Save operation (for appending to global context) should not use the state IN_PROGRESS. The state should remain FINISHED. This seems to be a copy-paste error in the test setup that could hide a potential bug where the consignment state is unintentionally reverted.
WithArgs(sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), "FINISHED", sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), consignmentID).
backend/internal/workflow/model/workflow_node.go (14)
There's a typo in the constant name. It should be WorkflowNodeTypeEndNode to be consistent with other WorkflowNode... constants in the codebase.
WorkflowNodeTypeEndNode WorkflowNodeTemplateType = "END_NODE" // Special type for end nodes that don't correspond to a task plugin
backend/internal/workflow/service/state_machine_test.go (168)
The tests for InitializeNodesFromTemplates do not seem to cover the new logic for creating an EndNode. The state machine is initialized with a nil templateProvider, and the existing test cases do not trigger the code path where GetEndNodeTemplate would be called. As per the rule regarding template ID to node instance ID mapping, it is crucial to ensure that the logic for creating and mapping node instances from templates is thoroughly tested. Please consider adding a test case that provides a mock templateProvider to verify the EndNode creation and its dependency mapping logic.
References
- When mapping template IDs to node instance IDs, ensure that each template ID corresponds to a single node instance. If duplicate templates are supported, the mapping should handle multiple instances or use a different resolution strategy.
… services refactor: Add GetEndNodeTemplate method to MockTemplateProvider and update related tests refactor: Remove templateProvider from WorkflowNodeStateMachine and related updates
bb2be17 to
0e9352f
Compare
Summary
This PR removes the hardcoded EndNode configuration from the workflow state machine and makes EndNode resolution template-driven.
The state machine now retrieves the EndNode template via the template provider/service instead of relying on a fixed template UUID in code. This reduces coupling, improves maintainability, and keeps EndNode behavior aligned with DB-managed workflow template data.
Type of Change
Changes Made
state_machine.go.TemplateProviderwithGetEndNodeTemplate(ctx)and implemented it intemplate_service.go.consignment_service.go,pre_consignment_service.go) to construct the state machine with both node repository and template provider.END_NODE(and label as End Node).router_test.go,consignment_service_test.go,workflow_node_service_test.go,state_machine_test.go) for the new provider method and SQL expectation changes.Testing
Targeted test run completed for touched workflow packages: 80 passed, 0 failed.
Checklist
Related Issues
#174
Additional Notes
Deployment Notes
Ensure the DB migration/seed state includes the EndNode workflow template (
END_NODE) in environments where initialization depends on template lookup.