{
  "artifactVersion": "loop.plan.artifact/v1",
  "compilerVersion": "loop.plan.compiler/v1",
  "apiVersion": "loop.plan/v1",
  "digest": "sha256:4e75cace14851404e719f2b702faff24a3116dec4a642276f0647f818bf08573",
  "contracts": {
    "input": [
      {
        "name": "value",
        "schema": {
          "type": "string",
          "required": true,
          "default": null,
          "values": [],
          "items": null
        }
      }
    ],
    "output": [
      {
        "name": "value",
        "schema": {
          "type": "string",
          "required": true,
          "default": null,
          "values": [],
          "items": null
        }
      }
    ],
    "state": []
  },
  "entry": {
    "nodeId": "repeat",
    "port": "enter",
    "bindings": [
      {
        "target": "value",
        "value": {
          "op": "load",
          "resultType": "string",
          "load": {
            "space": "plan_input",
            "path": [
              "value"
            ]
          }
        }
      }
    ]
  },
  "nodes": [
    {
      "id": "failure",
      "opcode": "end.failed",
      "inputPorts": [
        {
          "name": "in",
          "contract": []
        }
      ],
      "outputPorts": [],
      "stateEffects": {
        "reads": [],
        "writes": []
      },
      "scopePath": [],
      "config": {
        "end": {
          "code": "loop_failed"
        }
      }
    },
    {
      "id": "fanout",
      "opcode": "fork",
      "inputPorts": [
        {
          "name": "in",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      ],
      "outputPorts": [
        {
          "name": "left",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "right",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      ],
      "stateEffects": {
        "reads": [],
        "writes": []
      },
      "scopePath": [
        {
          "kind": "loop",
          "ownerId": "repeat"
        }
      ],
      "config": {
        "fork": {
          "branches": [
            "left",
            "right"
          ]
        }
      }
    },
    {
      "id": "gather",
      "opcode": "join.all",
      "inputPorts": [
        {
          "name": "left",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "right",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      ],
      "outputPorts": [
        {
          "name": "completed",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "failed",
          "contract": []
        }
      ],
      "stateEffects": {
        "reads": [],
        "writes": []
      },
      "scopePath": [
        {
          "kind": "loop",
          "ownerId": "repeat"
        }
      ],
      "config": {
        "join": {
          "ownerId": "fanout",
          "result": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ],
          "merge": [
            {
              "target": "value",
              "value": {
                "op": "load",
                "resultType": "string",
                "load": {
                  "space": "join_branch",
                  "scopeOwnerId": "fanout",
                  "branch": "left",
                  "path": [
                    "value"
                  ]
                }
              }
            }
          ]
        }
      }
    },
    {
      "id": "repeat",
      "opcode": "loop",
      "inputPorts": [
        {
          "name": "break",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "continue",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "enter",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      ],
      "outputPorts": [
        {
          "name": "body",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "done",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "failed",
          "contract": []
        }
      ],
      "stateEffects": {
        "reads": [],
        "writes": []
      },
      "scopePath": [],
      "config": {
        "loop": {
          "mode": "counted",
          "iterations": 3,
          "state": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      }
    },
    {
      "id": "route",
      "opcode": "switch.first_match",
      "inputPorts": [
        {
          "name": "in",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      ],
      "outputPorts": [
        {
          "name": "again",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        },
        {
          "name": "stop",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      ],
      "stateEffects": {
        "reads": [],
        "writes": []
      },
      "scopePath": [
        {
          "kind": "loop",
          "ownerId": "repeat"
        }
      ],
      "config": {
        "switch": {
          "cases": [
            {
              "port": "again",
              "default": false,
              "condition": {
                "op": "eq",
                "resultType": "boolean",
                "args": [
                  {
                    "op": "load",
                    "resultType": "string",
                    "load": {
                      "space": "activation_input",
                      "path": [
                        "value"
                      ]
                    }
                  },
                  {
                    "op": "const",
                    "resultType": "string",
                    "value": "again"
                  }
                ]
              }
            },
            {
              "port": "stop",
              "default": true,
              "condition": null
            }
          ]
        }
      }
    },
    {
      "id": "success",
      "opcode": "end.succeeded",
      "inputPorts": [
        {
          "name": "in",
          "contract": [
            {
              "name": "value",
              "schema": {
                "type": "string",
                "required": true,
                "default": null,
                "values": [],
                "items": null
              }
            }
          ]
        }
      ],
      "outputPorts": [],
      "stateEffects": {
        "reads": [],
        "writes": []
      },
      "scopePath": [],
      "config": {
        "end": {
          "code": ""
        }
      }
    }
  ],
  "edges": [
    {
      "id": "again",
      "source": {
        "nodeId": "route",
        "port": "again"
      },
      "target": {
        "nodeId": "repeat",
        "port": "continue"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "activation_input",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": [
        {
          "scopeKind": "loop",
          "ownerId": "repeat",
          "action": "continue"
        }
      ]
    },
    {
      "id": "body",
      "source": {
        "nodeId": "repeat",
        "port": "body"
      },
      "target": {
        "nodeId": "fanout",
        "port": "in"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "loop_state",
              "scopeOwnerId": "repeat",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": [
        {
          "scopeKind": "loop",
          "ownerId": "repeat",
          "action": "body"
        }
      ]
    },
    {
      "id": "done",
      "source": {
        "nodeId": "repeat",
        "port": "done"
      },
      "target": {
        "nodeId": "success",
        "port": "in"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "loop_state",
              "scopeOwnerId": "repeat",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": [
        {
          "scopeKind": "loop",
          "ownerId": "repeat",
          "action": "done"
        }
      ]
    },
    {
      "id": "join_failed",
      "source": {
        "nodeId": "gather",
        "port": "failed"
      },
      "target": {
        "nodeId": "repeat",
        "port": "break"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "activation_input",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": [
        {
          "scopeKind": "loop",
          "ownerId": "repeat",
          "action": "break"
        }
      ]
    },
    {
      "id": "joined",
      "source": {
        "nodeId": "gather",
        "port": "completed"
      },
      "target": {
        "nodeId": "route",
        "port": "in"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "activation_output",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": []
    },
    {
      "id": "left",
      "source": {
        "nodeId": "fanout",
        "port": "left"
      },
      "target": {
        "nodeId": "gather",
        "port": "left"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "activation_input",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": [
        {
          "scopeKind": "parallel",
          "ownerId": "fanout",
          "action": "arrive",
          "branch": "left"
        },
        {
          "scopeKind": "parallel",
          "ownerId": "fanout",
          "action": "enter",
          "branch": "left"
        }
      ]
    },
    {
      "id": "loop_failed",
      "source": {
        "nodeId": "repeat",
        "port": "failed"
      },
      "target": {
        "nodeId": "failure",
        "port": "in"
      },
      "bindings": [],
      "scopeTransitions": [
        {
          "scopeKind": "loop",
          "ownerId": "repeat",
          "action": "failed"
        }
      ]
    },
    {
      "id": "right",
      "source": {
        "nodeId": "fanout",
        "port": "right"
      },
      "target": {
        "nodeId": "gather",
        "port": "right"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "activation_input",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": [
        {
          "scopeKind": "parallel",
          "ownerId": "fanout",
          "action": "arrive",
          "branch": "right"
        },
        {
          "scopeKind": "parallel",
          "ownerId": "fanout",
          "action": "enter",
          "branch": "right"
        }
      ]
    },
    {
      "id": "stop",
      "source": {
        "nodeId": "route",
        "port": "stop"
      },
      "target": {
        "nodeId": "repeat",
        "port": "break"
      },
      "bindings": [
        {
          "target": "value",
          "value": {
            "op": "load",
            "resultType": "string",
            "load": {
              "space": "activation_input",
              "path": [
                "value"
              ]
            }
          }
        }
      ],
      "scopeTransitions": [
        {
          "scopeKind": "loop",
          "ownerId": "repeat",
          "action": "break"
        }
      ]
    }
  ],
  "scopes": [
    {
      "kind": "parallel",
      "ownerId": "fanout",
      "parentPath": [
        {
          "kind": "loop",
          "ownerId": "repeat"
        }
      ],
      "parallel": {
        "activationSet": "all",
        "joinId": "gather",
        "mode": "all",
        "branches": [
          {
            "port": "left",
            "members": [],
            "entryEdges": [
              "left"
            ],
            "successArrivals": [
              "left"
            ],
            "failedTerminals": []
          },
          {
            "port": "right",
            "members": [],
            "entryEdges": [
              "right"
            ],
            "successArrivals": [
              "right"
            ],
            "failedTerminals": []
          }
        ]
      }
    },
    {
      "kind": "loop",
      "ownerId": "repeat",
      "parentPath": [],
      "loop": {
        "bodyEntryEdges": [
          "body"
        ],
        "members": [
          "fanout",
          "gather",
          "route"
        ],
        "continueEdges": [
          "again"
        ],
        "breakEdges": [
          "join_failed",
          "stop"
        ],
        "doneEdges": [
          "done"
        ],
        "failedEdges": [
          "loop_failed"
        ]
      }
    }
  ]
}
