support sub flows#980
Conversation
GitLab Pipeline ActionGeneral informationLink to pipeline: https://gitlab.com/code0-tech/development/sagittarius/-/pipelines/2549035058 Status: Passed Job summariesrspec: [cloud]Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/14519395676/artifacts/tmp/coverage/index.html rspec: [ee]Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/14519395675/artifacts/tmp/coverage/index.html rspec: [ce]Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/14519395674/artifacts/tmp/coverage/index.html docs:previewDocumentation preview available at https://code0-tech.gitlab.io/-/development/telescopium/-/jobs/14519403951/artifacts/out/index.html rubocop841 files inspected, no offenses detected |
There was a problem hiding this comment.
Pull request overview
This PR replaces the old “function value” (NodeFunctionIdWrapper / node_functions.value_of_node_parameter) mechanism with a first-class SubFlow model that can be used as a node-parameter value, and wires it through GraphQL, persistence, and gRPC serialization. It also adds an optional cast field to flow settings and node parameters.
Changes:
- Introduces
SubFlow+SubFlowSettingmodels, tables, factories, and specs; updatesNodeParameterto usesub_flowinstead offunction_value. - Updates Flow create/update GraphQL inputs and response unions to accept/return
subFlowvalues (and removesNodeFunctionIdWrapper). - Adds
casttoflow_settingsandnode_parameters(GraphQL + persistence + gRPC), plus docs updates.
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/requests/graphql/mutation/namespace/projects/flows/update_mutation_spec.rb | Updates mutation spec to send/expect subFlow parameter values |
| spec/requests/graphql/mutation/namespace/projects/flows/create_mutation_spec.rb | Updates mutation spec to send/expect subFlow parameter values |
| spec/models/sub_flow_spec.rb | New model spec for SubFlow associations/validation |
| spec/models/sub_flow_setting_spec.rb | New model spec for SubFlowSetting associations/validation |
| spec/models/node_parameter_spec.rb | Replaces function_value expectations with sub_flow |
| spec/models/node_function_spec.rb | Removes value_of_node_parameter association expectations |
| spec/factories/sub_flows.rb | Adds factory for SubFlow |
| spec/factories/sub_flow_settings.rb | Adds factory for SubFlowSetting |
| spec/factories/node_parameters.rb | Removes function_value factory attribute |
| spec/factories/node_functions.rb | Removes value_of_node_parameter factory attribute |
| docs/graphql/union/nodeparametervalue.md | Documents FlowSubFlow as a possible union type |
| docs/graphql/object/nodeparameter.md | Documents new cast field on NodeParameter |
| docs/graphql/object/nodefunctionidwrapper.md | Removes docs for deprecated NodeFunctionIdWrapper |
| docs/graphql/object/flowsubflowsetting.md | Adds docs for FlowSubFlowSetting |
| docs/graphql/object/flowsubflow.md | Adds docs for FlowSubFlow |
| docs/graphql/object/flowsetting.md | Documents new cast field on FlowSetting |
| docs/graphql/input_object/nodeparametervalueinput.md | Replaces nodeFunctionId with subFlow input |
| docs/graphql/input_object/nodeparameterinput.md | Documents new cast input |
| docs/graphql/input_object/flowsubflowsettinginput.md | Adds docs for FlowSubFlowSettingInput |
| docs/graphql/input_object/flowsubflowinput.md | Adds docs for FlowSubFlowInput |
| docs/graphql/input_object/flowsettinginput.md | Documents new cast input on FlowSettingInput |
| docs/graphql/enum/errorcodeenum.md | Removes FUNCTION_VALUE_NOT_FOUND from documented error codes |
| db/structure.sql | Reflects schema changes: new tables + cast columns + removed FK/index |
| db/schema_migrations/20260520120000 | Adds checksum entry for the new migration |
| db/migrate/20260520120000_add_tucana_shared_flow_sub_flows.rb | Adds cast columns, creates sub_flow tables, removes old reference |
| app/services/namespaces/projects/flows/update_service.rb | Implements cast handling and subFlow update/clear logic |
| app/services/error_code.rb | Removes obsolete function_value_not_found error code |
| app/models/sub_flow.rb | New SubFlow model with gRPC conversion + validation |
| app/models/sub_flow_setting.rb | New SubFlowSetting model with gRPC conversion |
| app/models/node_parameter.rb | Switches from function_value to sub_flow; adds cast to gRPC |
| app/models/node_function.rb | Removes value_of_node_parameter association |
| app/models/flow_setting.rb | Adds cast to gRPC serialization |
| app/graphql/types/node_parameter_value_type.rb | Updates union to include FlowSubFlow and resolve SubFlow |
| app/graphql/types/node_parameter_type.rb | Adds cast field; returns sub_flow as the parameter value |
| app/graphql/types/node_function_id_wrapper_type.rb | Removes deprecated GraphQL type |
| app/graphql/types/input/node_parameter_value_input_type.rb | Replaces nodeFunctionId with subFlow; updates one-of validation |
| app/graphql/types/input/node_parameter_input_type.rb | Adds cast input |
| app/graphql/types/input/flow_sub_flow_setting_input_type.rb | Adds input type for sub-flow settings |
| app/graphql/types/input/flow_sub_flow_input_type.rb | Adds input type for sub-flow values |
| app/graphql/types/input/flow_setting_input_type.rb | Adds cast input for flow settings |
| app/graphql/types/flow_sub_flow_type.rb | Adds GraphQL object type for FlowSubFlow |
| app/graphql/types/flow_sub_flow_setting_type.rb | Adds GraphQL object type for FlowSubFlowSetting |
| app/graphql/types/flow_setting_type.rb | Adds cast field to FlowSetting GraphQL type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Niklas van Schrick <mc.taucher2003@gmail.com> Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
Co-authored-by: Niklas van Schrick <mc.taucher2003@gmail.com> Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
Co-authored-by: Niklas van Schrick <mc.taucher2003@gmail.com> Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
| factory :sub_flow do | ||
| node_parameter | ||
| starting_node factory: :node_function | ||
| function_definition { nil } | ||
| signature { '(): VOID' } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
| class FlowSubFlowType < Types::BaseObject | ||
| description 'Represents a sub-flow parameter value.' | ||
|
|
||
| field :function_identifier, String, |
There was a problem hiding this comment.
While the input type should take the function_identifier, this should provide the resolved FunctionDefinition.
| def to_grpc | ||
| Tucana::Shared::SubFlowSetting.new( | ||
| identifier: identifier, | ||
| default_value: default_value.nil? ? nil : Tucana::Shared::Value.from_ruby(default_value), |
There was a problem hiding this comment.
Not sure if that is important for you on the runtime side, but Tucana::Shared::Value.from_ruby(nil) creates a proper NULL_VALUE while using nil is basically that the field is not set.
|
|
||
| sub_flow = node_parameter.sub_flow || node_parameter.build_sub_flow | ||
| sub_flow.assign_attributes( | ||
| starting_node_id: starting_node_id, |
There was a problem hiding this comment.
I would expect that you don't need the persistence of new nodes if you assign the starting_node instead of the starting_node_id
| foreign_key: { to_table: :node_parameters, on_delete: :cascade } | ||
| t.references :starting_node, null: true, foreign_key: { to_table: :node_functions, on_delete: :restrict } | ||
| t.references :function_definition, null: true, foreign_key: { on_delete: :restrict } | ||
| t.text :signature, null: false |
There was a problem hiding this comment.
Forgot this one, it should also have a limit
| t.text :signature, null: false | |
| t.text :signature, null: false, limit: 500 |
Resolves: #931