<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:nano="https://nanobpm.io/schema/shapes/1.0" id="Definitions_nano_workforce_retro" targetNamespace="http://nanobpm.io/nano-workforce">
  <bpmn:process id="retro" name="Epic Retrospective" isExecutable="true">
    <bpmn:extensionElements>
      <nano:shapes>
        <nano:shape id="RetroGatherIn" name="Gather learnings — input">
          <nano:extend name="planKey" type="string" />
        </nano:shape>
        <nano:shape id="RetroRecordIn" name="Record retro — input">
          <nano:extend name="planKey" type="string" />
          <nano:extend name="retroLearnings" type="integer" optional="true" />
          <nano:extend name="status" type="string" optional="true" />
          <nano:extend name="pr" type="string" optional="true" />
          <nano:extend name="summary" type="string" optional="true" />
        </nano:shape>
        <nano:shape id="ConformanceRecordIn" name="Record conformance — input">
          <nano:extend name="planKey" type="string" />
          <nano:extend name="status" type="string" optional="true" />
          <nano:extend name="commentUrl" type="string" optional="true" />
          <nano:extend name="slicesMet" type="integer" optional="true" />
          <nano:extend name="slicesReduced" type="integer" optional="true" />
          <nano:extend name="slicesNotVerified" type="integer" optional="true" />
          <nano:extend name="deviationsRaised" type="integer" optional="true" />
          <nano:extend name="deviationsUnraised" type="integer" optional="true" />
          <nano:extend name="hasDeviations" type="boolean" optional="true" />
          <nano:extend name="summary" type="string" optional="true" />
        </nano:shape>
      </nano:shapes>
    </bpmn:extensionElements>
    <bpmn:startEvent id="Start" name="Epic complete">
      <bpmn:outgoing>f_start</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:serviceTask id="gather" name="Gather learnings">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="pr.retro-gather" />
        <zeebe:properties>
          <zeebe:property name="io.nanobpm.dataEnvelope.in" value="RetroGatherIn" />
        </zeebe:properties>
      </bpmn:extensionElements>
      <bpmn:incoming>f_start</bpmn:incoming>
      <bpmn:outgoing>f_toConformance</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="conformance" name="Verify implementation vs spec (agent)">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="senior:conformance" />
        <zeebe:agentDefinition agentType="external" />
        <zeebe:linkedResources>
          <zeebe:linkedResource resourceId="prompts/conformance.md" bindingType="latest" resourceType="GenericScript" linkName="prompt" />
        </zeebe:linkedResources>
        <zeebe:ioMapping>
          <zeebe:input source="=conformanceDigest" target="appendPrompt" />
        </zeebe:ioMapping>
      </bpmn:extensionElements>
      <bpmn:incoming>f_toConformance</bpmn:incoming>
      <bpmn:outgoing>f_toRecordConformance</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="record-conformance" name="Record conformance">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="pr.conformance-record" />
        <zeebe:properties>
          <zeebe:property name="io.nanobpm.dataEnvelope.in" value="ConformanceRecordIn" />
        </zeebe:properties>
      </bpmn:extensionElements>
      <bpmn:incoming>f_toRecordConformance</bpmn:incoming>
      <bpmn:outgoing>f_toDeviationsGw</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:exclusiveGateway id="gw-deviations" name="deviations?" default="f_noDeviations">
      <bpmn:incoming>f_toDeviationsGw</bpmn:incoming>
      <bpmn:outgoing>f_deviations</bpmn:outgoing>
      <bpmn:outgoing>f_noDeviations</bpmn:outgoing>
    </bpmn:exclusiveGateway>
    <bpmn:userTask id="conformance-escalation" name="Conformance review (human)">
      <bpmn:extensionElements>
        <zeebe:formDefinition formId="conformance-escalation" />
        <zeebe:userTask />
        <zeebe:assignmentDefinition candidateGroups="operators" />
      </bpmn:extensionElements>
      <bpmn:incoming>f_deviations</bpmn:incoming>
      <bpmn:outgoing>f_toConformanceAck</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:serviceTask id="record-conformance-ack" name="Record acknowledgement">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="pr.conformance-ack" />
        <zeebe:ioMapping>
          <zeebe:input source="=planKey" target="planKey" />
          <zeebe:input source="=if (is defined(note)) then note else null" target="note" />
        </zeebe:ioMapping>
      </bpmn:extensionElements>
      <bpmn:incoming>f_toConformanceAck</bpmn:incoming>
      <bpmn:outgoing>f_ackToSynthesize</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="synthesize" name="Synthesize &#38; promote (agent)">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="senior:retro" />
        <zeebe:agentDefinition agentType="external" />
        <zeebe:linkedResources>
          <zeebe:linkedResource resourceId="prompts/retro.md" bindingType="latest" resourceType="GenericScript" linkName="prompt" />
        </zeebe:linkedResources>
        <zeebe:ioMapping>
          <zeebe:input source="=retroDigest" target="appendPrompt" />
        </zeebe:ioMapping>
      </bpmn:extensionElements>
      <bpmn:incoming>f_noDeviations</bpmn:incoming>
      <bpmn:incoming>f_ackToSynthesize</bpmn:incoming>
      <bpmn:outgoing>f_toRecord</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:serviceTask id="record" name="Record retro">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="pr.retro-record" />
        <zeebe:properties>
          <zeebe:property name="io.nanobpm.dataEnvelope.in" value="RetroRecordIn" />
        </zeebe:properties>
      </bpmn:extensionElements>
      <bpmn:incoming>f_toRecord</bpmn:incoming>
      <bpmn:outgoing>f_toEnd</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:endEvent id="End" name="Retro filed">
      <bpmn:incoming>f_toEnd</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="f_start" sourceRef="Start" targetRef="gather" />
    <bpmn:sequenceFlow id="f_toConformance" sourceRef="gather" targetRef="conformance" />
    <bpmn:sequenceFlow id="f_toRecordConformance" sourceRef="conformance" targetRef="record-conformance" />
    <bpmn:sequenceFlow id="f_toDeviationsGw" sourceRef="record-conformance" targetRef="gw-deviations" />
    <bpmn:sequenceFlow id="f_deviations" name="deviations" sourceRef="gw-deviations" targetRef="conformance-escalation">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=hasDeviations = true</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="f_noDeviations" sourceRef="gw-deviations" targetRef="synthesize" />
    <bpmn:sequenceFlow id="f_toConformanceAck" sourceRef="conformance-escalation" targetRef="record-conformance-ack" />
    <bpmn:sequenceFlow id="f_ackToSynthesize" sourceRef="record-conformance-ack" targetRef="synthesize" />
    <bpmn:sequenceFlow id="f_toRecord" sourceRef="synthesize" targetRef="record" />
    <bpmn:sequenceFlow id="f_toEnd" sourceRef="record" targetRef="End" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_retro">
    <bpmndi:BPMNPlane id="BPMNPlane_retro" bpmnElement="retro">
      <bpmndi:BPMNShape id="BPMNShape_Start" bpmnElement="Start">
        <dc:Bounds x="80" y="102" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="67" y="143" width="63" height="28" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_gather" bpmnElement="gather">
        <dc:Bounds x="216" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_conformance" bpmnElement="conformance">
        <dc:Bounds x="416" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_record-conformance" bpmnElement="record-conformance">
        <dc:Bounds x="616" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_gw-deviations" bpmnElement="gw-deviations" isMarkerVisible="true">
        <dc:Bounds x="816" y="95" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="801" y="76" width="81" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_conformance-escalation" bpmnElement="conformance-escalation">
        <dc:Bounds x="966" y="240" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_record-conformance-ack" bpmnElement="record-conformance-ack">
        <dc:Bounds x="1166" y="240" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_synthesize" bpmnElement="synthesize">
        <dc:Bounds x="1366" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_record" bpmnElement="record">
        <dc:Bounds x="1566" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="BPMNShape_End" bpmnElement="End">
        <dc:Bounds x="1766" y="102" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1744" y="143" width="80" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="BPMNEdge_f_start" bpmnElement="f_start">
        <di:waypoint x="116" y="120" />
        <di:waypoint x="216" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_toConformance" bpmnElement="f_toConformance">
        <di:waypoint x="316" y="120" />
        <di:waypoint x="416" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_toRecordConformance" bpmnElement="f_toRecordConformance">
        <di:waypoint x="516" y="120" />
        <di:waypoint x="616" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_toDeviationsGw" bpmnElement="f_toDeviationsGw">
        <di:waypoint x="716" y="120" />
        <di:waypoint x="816" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_noDeviations" bpmnElement="f_noDeviations">
        <di:waypoint x="866" y="120" />
        <di:waypoint x="1366" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_toRecord" bpmnElement="f_toRecord">
        <di:waypoint x="1466" y="120" />
        <di:waypoint x="1566" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_toEnd" bpmnElement="f_toEnd">
        <di:waypoint x="1666" y="120" />
        <di:waypoint x="1766" y="120" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_deviations" bpmnElement="f_deviations">
        <di:waypoint x="841" y="145" />
        <di:waypoint x="841" y="280" />
        <di:waypoint x="966" y="280" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="846" y="206" width="74" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_toConformanceAck" bpmnElement="f_toConformanceAck">
        <di:waypoint x="1066" y="280" />
        <di:waypoint x="1166" y="280" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="BPMNEdge_f_ackToSynthesize" bpmnElement="f_ackToSynthesize">
        <di:waypoint x="1266" y="280" />
        <di:waypoint x="1416" y="280" />
        <di:waypoint x="1416" y="160" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
