Skip to content

feat(workflow): add MDL syntax for outcome parameter mappings in CALL MICROFLOW / CALL WORKFLOW #10

@engalar

Description

@engalar

Summary

CALL MICROFLOW and CALL WORKFLOW activities support parameter mappings in BSON (the executor auto-binds $WorkflowContext for call-workflow), but MDL has no syntax for users to specify explicit parameter values. This limits the expressiveness of workflow scripts.

Gap

Layer Status
BSON Parser ✅ Fully implemented
BSON Writer ✅ Implemented (auto-bind only)
MDL Grammar ❌ No WITH / PARAMETERS clause
MDL Executor ❌ No explicit parameter handler

Key Files & Lines

BSON Writer — where auto-binding happens (extend to accept explicit mappings)

  • sdk/mpr/writer_workflow.go:412-426ParameterMappings for CallMicroflowTask; array marker int32(2)
  • sdk/mpr/writer_workflow.go:464-478ParameterMappings for CallWorkflowActivity; array marker int32(2)

BSON Parser — already implemented, reference only

  • sdk/mpr/parser_workflow.go:354-355parseBoundaryEvents call site (adjacent to where parameter mappings are parsed)

Grammar — where to add syntax

  • mdl/grammar/MDLParser.g4:2247-2254workflowCallMicroflowStmt and workflowCallWorkflowStmt; add optional WITH (param = expr, ...) clause

Executor — where to wire up

  • mdl/executor/cmd_workflows_write.go:159-194buildWorkflowActivities()

AST — where to add fields

  • mdl/ast/ — extend WorkflowCallMicroflowNode and WorkflowCallWorkflowNode with Parameters []WorkflowParamMapping

Proposed MDL Syntax

CALL MICROFLOW MyModule.CalculateDiscount
  WITH (OrderAmount = '$WorkflowContext/TotalAmount', CustomerId = '$WorkflowContext/CustomerId')
  OUTCOMES 'Approved' -> { } 'Rejected' -> { };

CALL WORKFLOW MyModule.SubApprovalWorkflow
  WITH (Context = '$WorkflowContext');

Notes

  • $WorkflowContext auto-binding for CALL WORKFLOW can remain the default when no WITH clause is given
  • Parameter types must match the microflow/workflow parameter types (expression vs object reference)
  • Array marker for ParameterMappings is always int32(2) — see writer_workflow.go:413

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions