Summary
_connect_sources_to_output in src/pflow/core/workflow/mermaid/_io.py only recognizes node IDs as output source roots. When an output source references a workflow input (e.g., source: ${data.field} where data is a declared input), the output node renders with no incoming edge — disconnected in the diagram.
Root cause
_io.py:195-197:
for src_node, field in _SOURCE_NODE_FIELD_RE.findall(source):
if src_node not in node_ids:
continue # Input names are silently dropped
_SOURCE_NODE_FIELD_RE captures name.field patterns. When src_node is a workflow input name (not a node ID), it's filtered out. The output node has no edge connecting it to the input.
Additionally, bare input references (source: ${data} without a dot) don't even match the regex (requires name.field format), so they're also disconnected.
Reproducer
from pflow.core.workflow.mermaid import generate_mermaid
ir = {
"ir_version": "0.1.0",
"nodes": [{"id": "process", "type": "shell", "params": {"command": "echo ${data.field}"}}],
"inputs": {"data": {"type": "dict", "description": "Input data"}},
"outputs": {"result": {"source": "${data.field}"}},
}
print(generate_mermaid(ir))
# Output node "result" has no incoming edge — should connect from input "data"
Fix direction
In _connect_sources_to_output, when src_node not in node_ids, check if it's in the workflow inputs. If so, connect the output to the corresponding input parallelogram node instead of skipping.
Discovered during
Code review of GH #247 fix (validator now allows input-root output sources). The validator and runtime handle these correctly, but Mermaid rendering was never updated to match.
Summary
_connect_sources_to_outputinsrc/pflow/core/workflow/mermaid/_io.pyonly recognizes node IDs as output source roots. When an output source references a workflow input (e.g.,source: ${data.field}wheredatais a declared input), the output node renders with no incoming edge — disconnected in the diagram.Root cause
_io.py:195-197:_SOURCE_NODE_FIELD_REcapturesname.fieldpatterns. Whensrc_nodeis a workflow input name (not a node ID), it's filtered out. The output node has no edge connecting it to the input.Additionally, bare input references (
source: ${data}without a dot) don't even match the regex (requiresname.fieldformat), so they're also disconnected.Reproducer
Fix direction
In
_connect_sources_to_output, whensrc_node not in node_ids, check if it's in the workflow inputs. If so, connect the output to the corresponding input parallelogram node instead of skipping.Discovered during
Code review of GH #247 fix (validator now allows input-root output sources). The validator and runtime handle these correctly, but Mermaid rendering was never updated to match.