<?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"
                  id="Definitions_DefenseInDepth"
                  targetNamespace="http://kora-platform.luki-net.org/security"
                  exporter="kora-platform Security Hardening Saga (Phase 3 #3)"
                  exporterVersion="1.0.0">
  <bpmn:process id="Process_RequestPipeline" name="kora-platform Defense-in-Depth Request-Pipeline" isExecutable="false">

    <bpmn:startEvent id="StartEvent_Request" name="User Request">
      <bpmn:outgoing>Flow_Request_L5</bpmn:outgoing>
    </bpmn:startEvent>

    <bpmn:exclusiveGateway id="Gateway_L5" name="L5: Multi-turn Persona-Defense">
      <bpmn:incoming>Flow_Request_L5</bpmn:incoming>
      <bpmn:outgoing>Flow_L5_Block</bpmn:outgoing>
      <bpmn:outgoing>Flow_L5_Alpha</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:endEvent id="EndEvent_L5_Block" name="history_persist_filter β-Marker-Replace + Cache-Skip">
      <bpmn:incoming>Flow_L5_Block</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:exclusiveGateway id="Gateway_Alpha" name="α: Input-Filter">
      <bpmn:incoming>Flow_L5_Alpha</bpmn:incoming>
      <bpmn:outgoing>Flow_Alpha_Block</bpmn:outgoing>
      <bpmn:outgoing>Flow_Alpha_Cache</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:endEvent id="EndEvent_Alpha_Block" name="Pre-LLM-Block NO_TOKENS Refusal-Replacement">
      <bpmn:incoming>Flow_Alpha_Block</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:exclusiveGateway id="Gateway_Cache" name="Cache: Semantic Cosine&#x2265;0.95">
      <bpmn:incoming>Flow_Alpha_Cache</bpmn:incoming>
      <bpmn:outgoing>Flow_Cache_Hit</bpmn:outgoing>
      <bpmn:outgoing>Flow_Cache_L2</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:endEvent id="EndEvent_CacheHit" name="Cached Response">
      <bpmn:incoming>Flow_Cache_Hit</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:task id="Task_L2" name="L2: Operator-Template Persona-Cleanup + Spotlighting-Tags">
      <bpmn:incoming>Flow_Cache_L2</bpmn:incoming>
      <bpmn:outgoing>Flow_L2_LLM</bpmn:outgoing>
    </bpmn:task>

    <bpmn:task id="Task_LLMStream" name="LLM: vLLM Qwen3-14B + LookAheadBuffer K=16">
      <bpmn:incoming>Flow_L2_LLM</bpmn:incoming>
      <bpmn:outgoing>Flow_LLM_InlineL3</bpmn:outgoing>
    </bpmn:task>

    <bpmn:exclusiveGateway id="Gateway_InlineL3" name="Inline-L3: check_output(buffered text)">
      <bpmn:incoming>Flow_LLM_InlineL3</bpmn:incoming>
      <bpmn:outgoing>Flow_InlineL3_HardStop</bpmn:outgoing>
      <bpmn:outgoing>Flow_InlineL3_L4</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:endEvent id="EndEvent_HardStop" name="Hard-Stop SSE hard_stop=true clear_previous=true filter_layer=inline">
      <bpmn:incoming>Flow_InlineL3_HardStop</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:exclusiveGateway id="Gateway_L4" name="L4: Post-Stream-Fallback + SourceWireForm">
      <bpmn:incoming>Flow_InlineL3_L4</bpmn:incoming>
      <bpmn:outgoing>Flow_L4_Correction</bpmn:outgoing>
      <bpmn:outgoing>Flow_L4_Stream</bpmn:outgoing>
    </bpmn:exclusiveGateway>

    <bpmn:endEvent id="EndEvent_Correction" name="correction Event filter_layer=post_stream">
      <bpmn:incoming>Flow_L4_Correction</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:endEvent id="EndEvent_Stream" name="Token-Stream + SourceWireForm OHNE content-Feld">
      <bpmn:incoming>Flow_L4_Stream</bpmn:incoming>
    </bpmn:endEvent>

    <bpmn:sequenceFlow id="Flow_Request_L5" sourceRef="StartEvent_Request" targetRef="Gateway_L5"/>
    <bpmn:sequenceFlow id="Flow_L5_Block" name="Match" sourceRef="Gateway_L5" targetRef="EndEvent_L5_Block"/>
    <bpmn:sequenceFlow id="Flow_L5_Alpha" name="sauber" sourceRef="Gateway_L5" targetRef="Gateway_Alpha"/>
    <bpmn:sequenceFlow id="Flow_Alpha_Block" name="Match" sourceRef="Gateway_Alpha" targetRef="EndEvent_Alpha_Block"/>
    <bpmn:sequenceFlow id="Flow_Alpha_Cache" name="sauber" sourceRef="Gateway_Alpha" targetRef="Gateway_Cache"/>
    <bpmn:sequenceFlow id="Flow_Cache_Hit" name="Hit" sourceRef="Gateway_Cache" targetRef="EndEvent_CacheHit"/>
    <bpmn:sequenceFlow id="Flow_Cache_L2" name="Miss" sourceRef="Gateway_Cache" targetRef="Task_L2"/>
    <bpmn:sequenceFlow id="Flow_L2_LLM" sourceRef="Task_L2" targetRef="Task_LLMStream"/>
    <bpmn:sequenceFlow id="Flow_LLM_InlineL3" sourceRef="Task_LLMStream" targetRef="Gateway_InlineL3"/>
    <bpmn:sequenceFlow id="Flow_InlineL3_HardStop" name="Match" sourceRef="Gateway_InlineL3" targetRef="EndEvent_HardStop"/>
    <bpmn:sequenceFlow id="Flow_InlineL3_L4" name="kein Match" sourceRef="Gateway_InlineL3" targetRef="Gateway_L4"/>
    <bpmn:sequenceFlow id="Flow_L4_Correction" name="Match" sourceRef="Gateway_L4" targetRef="EndEvent_Correction"/>
    <bpmn:sequenceFlow id="Flow_L4_Stream" name="sauber" sourceRef="Gateway_L4" targetRef="EndEvent_Stream"/>
  </bpmn:process>

  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_RequestPipeline">
      <bpmndi:BPMNShape id="StartEvent_Request_di" bpmnElement="StartEvent_Request">
        <dc:Bounds x="50" y="200" width="36" height="36"/>
        <bpmndi:BPMNLabel><dc:Bounds x="40" y="243" width="56" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_L5_di" bpmnElement="Gateway_L5" isMarkerVisible="true">
        <dc:Bounds x="135" y="193" width="50" height="50"/>
        <bpmndi:BPMNLabel><dc:Bounds x="115" y="155" width="90" height="27"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_L5_Block_di" bpmnElement="EndEvent_L5_Block">
        <dc:Bounds x="142" y="350" width="36" height="36"/>
        <bpmndi:BPMNLabel><dc:Bounds x="100" y="393" width="120" height="40"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_Alpha_di" bpmnElement="Gateway_Alpha" isMarkerVisible="true">
        <dc:Bounds x="265" y="193" width="50" height="50"/>
        <bpmndi:BPMNLabel><dc:Bounds x="252" y="155" width="80" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_Alpha_Block_di" bpmnElement="EndEvent_Alpha_Block">
        <dc:Bounds x="272" y="350" width="36" height="36"/>
        <bpmndi:BPMNLabel><dc:Bounds x="230" y="393" width="120" height="40"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_Cache_di" bpmnElement="Gateway_Cache" isMarkerVisible="true">
        <dc:Bounds x="395" y="193" width="50" height="50"/>
        <bpmndi:BPMNLabel><dc:Bounds x="375" y="155" width="90" height="27"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_CacheHit_di" bpmnElement="EndEvent_CacheHit">
        <dc:Bounds x="402" y="350" width="36" height="36"/>
        <bpmndi:BPMNLabel><dc:Bounds x="376" y="393" width="88" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Task_L2_di" bpmnElement="Task_L2">
        <dc:Bounds x="510" y="178" width="100" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_LLMStream_di" bpmnElement="Task_LLMStream">
        <dc:Bounds x="660" y="178" width="100" height="80"/>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_InlineL3_di" bpmnElement="Gateway_InlineL3" isMarkerVisible="true">
        <dc:Bounds x="810" y="193" width="50" height="50"/>
        <bpmndi:BPMNLabel><dc:Bounds x="790" y="155" width="90" height="27"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_HardStop_di" bpmnElement="EndEvent_HardStop">
        <dc:Bounds x="817" y="350" width="36" height="36"/>
        <bpmndi:BPMNLabel><dc:Bounds x="775" y="393" width="120" height="55"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="Gateway_L4_di" bpmnElement="Gateway_L4" isMarkerVisible="true">
        <dc:Bounds x="940" y="193" width="50" height="50"/>
        <bpmndi:BPMNLabel><dc:Bounds x="920" y="155" width="90" height="27"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_Correction_di" bpmnElement="EndEvent_Correction">
        <dc:Bounds x="947" y="350" width="36" height="36"/>
        <bpmndi:BPMNLabel><dc:Bounds x="905" y="393" width="120" height="40"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape id="EndEvent_Stream_di" bpmnElement="EndEvent_Stream">
        <dc:Bounds x="1060" y="200" width="36" height="36"/>
        <bpmndi:BPMNLabel><dc:Bounds x="1015" y="243" width="125" height="40"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>

      <bpmndi:BPMNEdge id="Flow_Request_L5_di" bpmnElement="Flow_Request_L5">
        <di:waypoint x="86" y="218"/><di:waypoint x="135" y="218"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_L5_Block_di" bpmnElement="Flow_L5_Block">
        <di:waypoint x="160" y="243"/><di:waypoint x="160" y="350"/>
        <bpmndi:BPMNLabel><dc:Bounds x="165" y="290" width="36" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_L5_Alpha_di" bpmnElement="Flow_L5_Alpha">
        <di:waypoint x="185" y="218"/><di:waypoint x="265" y="218"/>
        <bpmndi:BPMNLabel><dc:Bounds x="208" y="200" width="38" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Alpha_Block_di" bpmnElement="Flow_Alpha_Block">
        <di:waypoint x="290" y="243"/><di:waypoint x="290" y="350"/>
        <bpmndi:BPMNLabel><dc:Bounds x="295" y="290" width="36" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Alpha_Cache_di" bpmnElement="Flow_Alpha_Cache">
        <di:waypoint x="315" y="218"/><di:waypoint x="395" y="218"/>
        <bpmndi:BPMNLabel><dc:Bounds x="338" y="200" width="38" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Cache_Hit_di" bpmnElement="Flow_Cache_Hit">
        <di:waypoint x="420" y="243"/><di:waypoint x="420" y="350"/>
        <bpmndi:BPMNLabel><dc:Bounds x="425" y="290" width="20" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Cache_L2_di" bpmnElement="Flow_Cache_L2">
        <di:waypoint x="445" y="218"/><di:waypoint x="510" y="218"/>
        <bpmndi:BPMNLabel><dc:Bounds x="465" y="200" width="25" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_L2_LLM_di" bpmnElement="Flow_L2_LLM">
        <di:waypoint x="610" y="218"/><di:waypoint x="660" y="218"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_LLM_InlineL3_di" bpmnElement="Flow_LLM_InlineL3">
        <di:waypoint x="760" y="218"/><di:waypoint x="810" y="218"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_InlineL3_HardStop_di" bpmnElement="Flow_InlineL3_HardStop">
        <di:waypoint x="835" y="243"/><di:waypoint x="835" y="350"/>
        <bpmndi:BPMNLabel><dc:Bounds x="840" y="290" width="36" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_InlineL3_L4_di" bpmnElement="Flow_InlineL3_L4">
        <di:waypoint x="860" y="218"/><di:waypoint x="940" y="218"/>
        <bpmndi:BPMNLabel><dc:Bounds x="876" y="200" width="58" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_L4_Correction_di" bpmnElement="Flow_L4_Correction">
        <di:waypoint x="965" y="243"/><di:waypoint x="965" y="350"/>
        <bpmndi:BPMNLabel><dc:Bounds x="970" y="290" width="36" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_L4_Stream_di" bpmnElement="Flow_L4_Stream">
        <di:waypoint x="990" y="218"/><di:waypoint x="1060" y="218"/>
        <bpmndi:BPMNLabel><dc:Bounds x="1003" y="200" width="38" height="14"/></bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
