<commit_before><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
                   package="io.aeron.cluster.codecs"
                   id="1"
                   version="1"
                   semanticVersion="5.2"
                   description="Message Codecs for communicating with, and within, an Aeron Cluster"
                   byteOrder="littleEndian">
    <types>
        <composite name="messageHeader" description="Message identifiers and length of message root">
            <type name="blockLength" primitiveType="uint16"/>
            <type name="templateId"  primitiveType="uint16"/>
            <type name="schemaId"    primitiveType="uint16"/>
            <type name="version"     primitiveType="uint16"/>
        </composite>
        <composite name="groupSizeEncoding" description="Repeating group dimensions">
            <type name="blockLength" primitiveType="uint16"/>
            <type name="numInGroup"  primitiveType="uint16"/>
        </composite>
        <composite name="varAsciiEncoding">
            <type name="length"      primitiveType="uint32" maxValue="1073741824"/>
            <type name="varData"     primitiveType="uint8" length="0" characterEncoding="US-ASCII"/>
        </composite>
        <composite name="varDataEncoding">
            <type name="length"      primitiveType="uint32" maxValue="1073741824"/>
            <type name="varData"     primitiveType="uint8" length="0"/>
        </composite>
        <enum name="BooleanType" encodingType="int32">
            <validValue name="FALSE">0</validValue>
            <validValue name="TRUE">1</validValue>
        </enum>
        <enum name="EventCode" encodingType="int32" description="Type of event for a response">
            <validValue name="OK">0</validValue>
            <validValue name="ERROR">1</validValue>
            <validValue name="REDIRECT">2</validValue>
            <validValue name="AUTHENTICATION_REJECTED">3</validValue>
        </enum>
        <enum name="CloseReason" encodingType="int32" description="Reason why a session was closed">
            <validValue name="CLIENT_ACTION">0</validValue>
            <validValue name="SERVICE_ACTION">1</validValue>
            <validValue name="TIMEOUT">2</validValue>
        </enum>
        <enum name="ClusterAction" encodingType="int32" description="Action to be taken by a cluster nodes">
            <validValue name="SUSPEND">0</validValue>
            <validValue name="RESUME">1</validValue>
            <validValue name="SNAPSHOT">2</validValue>
            <validValue name="SHUTDOWN">3</validValue>
            <validValue name="ABORT">4</validValue>
        </enum>
        <enum name="SnapshotMark" encodingType="int32" description="Mark within a snapshot">
            <validValue name="BEGIN">0</validValue>
            <validValue name="SECTION">1</validValue>
            <validValue name="END">2</validValue>
        </enum>
        <type name="time_t" primitiveType="int64" description="Epoch time in milliseconds since 1 Jan 1970 UTC"/>
    </types>

    <!--
        Cluster Session Protocol
        ========================

        Protocol is:
            -> session-connect, [*ingress-message | *session-keep-alive], session-close
                      \
            <-          *session-event, [*egress-message | *session-event | *new-leader-event]

        1. Session Connect
          - An attempt is made to establish a connection with the cluster via multicast or multi-destination-cast.
          - If successful, a OK session-event will be sent in the return path with the list of endpoint destinations
            for the cluster members. The leader will come first.
          - Followers can respond with a REDIRECT code and a list of member endpoint destinations in the
            detail that will have the leader first.
          - If a change of leader occurs mid session then a new-leader-event will be sent from the new leader.

        2. Ingress/Egress Messages - Messages which make up application protocol.
          - Messages are sent to a clustered service with a IngressMessageHeader followed by an application payload.
          - The service may emit responses and events with a EgressMessageHeader followed by an application payload.
          - The application protocol is the user defined messages for interacting with the service being clustered.
          - Keep alive messages should be sent when insufficient ingress messages are sent to keep the session open.

        3. Session Close
          - A cluster session can be closed with a CloseSessionRequest
          - If the session is not explicitly closed then it will timeout if the connection becomes unavailable.

        Cluster Authentication Protocol
        ===============================

        Connect protocol can occur in multiple valid sequences

        1. Authenticated via Session Connect
            -> session-connect, ...
                      \
            <-          *session-event (OK), ...

        2. Authenticated via Challenge Response
            -> session-connect,   challenge-response, ...
                      \            /              \
            <-          challenge,                  session-event (OK), ...

        3. Rejected via Session Connect
            -> session-connect
                      \
            <-          *session-event (AUTHENTICATION_REJECTED)

        4. Rejected via Challenge Response
            -> session-connect,   challenge-response
                      \            /              \
            <-          challenge,                  session-event (AUTHENTICATION_REJECTED)

    -->

    <sbe:message name="IngressMessageHeader"
                 id="1"
                 description="Header for ingress messages from a client to the cluster services">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="leadershipTermId"     id="3" type="int64"/>
    </sbe:message>

    <sbe:message name="EgressMessageHeader"
                 id="2"
                 description="Header for egress messages from a service to the cluster client">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="timestamp"            id="3" type="time_t"/>
    </sbe:message>

    <sbe:message name="SessionEvent"
                 id="3"
                 description="Response to a connect request or async event. Details will be empty if code is OK">
        <field name="clusterSessionId"     id="1" type="int64"
               description="Session id for a multiplexed session over a shared connection, i.e. same Image"/>
        <field name="correlationId"        id="2" type="int64"
               description="Request correlation id with which this event is associated"/>
        <field name="leadershipTermId"     id="3" type="int64"
               description="Current leadership term identifier"/>
        <field name="leaderMemberId"       id="4" type="int32"
               description="current leader of the cluster"/>
        <field name="code"                 id="5" type="EventCode"
               description="code type of the response"/>
        <data  name="detail"               id="6" type="varAsciiEncoding"
               description="Further detail such as an error message or list of cluster member endpoints"/>
    </sbe:message>

    <sbe:message name="SessionConnectRequest"
                 id="4"
                 description="Connect to the cluster and if successful then open a session">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="responseStreamId"     id="3" type="int32"/>
        <data  name="responseChannel"      id="4" type="varAsciiEncoding"/>
        <data  name="encodedCredentials"   id="5" type="varDataEncoding"/>
    </sbe:message>

    <sbe:message name="SessionCloseRequest"
                 id="5"
                 description="Close an open cluster session">
        <field name="clusterSessionId"     id="1" type="int64"/>
    </sbe:message>

    <sbe:message name="SessionKeepAlive"
                 id="6"
                 description="Keep a cluster session open by indicating the client is alive">
        <field name="clusterSessionId"     id="1" type="int64"/>
        <field name="leadershipTermId"     id="2" type="int64"/>
    </sbe:message>

    <sbe:message name="NewLeaderEvent"
                 id="7"
                 description="Event to indicate a new leader has been elected for the cluster">
        <field name="clusterSessionId"     id="1" type="int64"/>
        <field name="leadershipTermId"     id="2" type="int64"/>
        <field name="leaderMemberId"       id="3" type="int32"/>
        <data  name="memberEndpoints"      id="4" type="varAsciiEncoding"/>
    </sbe:message>

    <sbe:message name="Challenge"
                 id="8"
                 description="Challenge the client to provide credentials">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <data  name="encodedChallenge"     id="3" type="varDataEncoding"/>
    </sbe:message>

    <sbe:message name="ChallengeResponse"
                 id="9"
                 description="Respond to a cluster challenge with credentials">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <data  name="encodedCredentials"   id="3" type="varDataEncoding"/>
    </sbe:message>

    <!-- Events from the leader consensus module to the followers and services which get appended to the log  -->

    <sbe:message name="SessionHeader"
                 id="20"
                 description="Header for ingress messages from clients appended to the log">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="timestamp"            id="3" type="time_t"/>
    </sbe:message>

    <sbe:message name="TimerEvent"
                 id="21"
                 description="Timer triggered event as the result of a deadline passing on a registered timer">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="timestamp"            id="2" type="time_t"/>
    </sbe:message>

    <sbe:message name="SessionOpenEvent"
                 id="22"
                 description="Event for the state machine to notify a session has been opened">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="timestamp"            id="3" type="time_t"/>
        <field name="responseStreamId"     id="4" type="int32"/>
        <data  name="responseChannel"      id="5" type="varAsciiEncoding"/><commit_msg>[Java] Comment.<commit_after><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
                   package="io.aeron.cluster.codecs"
                   id="1"
                   version="1"
                   semanticVersion="5.2"
                   description="Message Codecs for communicating with, and within, an Aeron Cluster"
                   byteOrder="littleEndian">
    <types>
        <composite name="messageHeader" description="Message identifiers and length of message root">
            <type name="blockLength" primitiveType="uint16"/>
            <type name="templateId"  primitiveType="uint16"/>
            <type name="schemaId"    primitiveType="uint16"/>
            <type name="version"     primitiveType="uint16"/>
        </composite>
        <composite name="groupSizeEncoding" description="Repeating group dimensions">
            <type name="blockLength" primitiveType="uint16"/>
            <type name="numInGroup"  primitiveType="uint16"/>
        </composite>
        <composite name="varAsciiEncoding">
            <type name="length"      primitiveType="uint32" maxValue="1073741824"/>
            <type name="varData"     primitiveType="uint8" length="0" characterEncoding="US-ASCII"/>
        </composite>
        <composite name="varDataEncoding">
            <type name="length"      primitiveType="uint32" maxValue="1073741824"/>
            <type name="varData"     primitiveType="uint8" length="0"/>
        </composite>
        <enum name="BooleanType" encodingType="int32">
            <validValue name="FALSE">0</validValue>
            <validValue name="TRUE">1</validValue>
        </enum>
        <enum name="EventCode" encodingType="int32" description="Type of event for a response">
            <validValue name="OK">0</validValue>
            <validValue name="ERROR">1</validValue>
            <validValue name="REDIRECT">2</validValue>
            <validValue name="AUTHENTICATION_REJECTED">3</validValue>
        </enum>
        <enum name="CloseReason" encodingType="int32" description="Reason why a session was closed">
            <validValue name="CLIENT_ACTION">0</validValue>
            <validValue name="SERVICE_ACTION">1</validValue>
            <validValue name="TIMEOUT">2</validValue>
        </enum>
        <enum name="ClusterAction" encodingType="int32" description="Action to be taken by a cluster nodes">
            <validValue name="SUSPEND">0</validValue>
            <validValue name="RESUME">1</validValue>
            <validValue name="SNAPSHOT">2</validValue>
            <validValue name="SHUTDOWN">3</validValue>
            <validValue name="ABORT">4</validValue>
        </enum>
        <enum name="SnapshotMark" encodingType="int32" description="Mark within a snapshot">
            <validValue name="BEGIN">0</validValue>
            <validValue name="SECTION">1</validValue>
            <validValue name="END">2</validValue>
        </enum>
        <type name="time_t" primitiveType="int64" description="Epoch time in milliseconds since 1 Jan 1970 UTC"/>
    </types>

    <!--
        Cluster Session Protocol
        ========================

        Protocol is:
            -> session-connect, [*ingress-message | *session-keep-alive], session-close
                      \
            <-          *session-event, [*egress-message | *session-event | *new-leader-event]

        1. Session Connect
          - An attempt is made to establish a connection with the cluster via multicast or multi-destination-cast.
          - If successful, a OK session-event will be sent in the return path with the list of endpoint destinations
            for the cluster members. The leader will come first.
          - Followers can respond with a REDIRECT code and a list of member endpoint destinations in the
            detail that will have the leader first.
          - If a change of leader occurs mid session then a new-leader-event will be sent from the new leader.

        2. Ingress/Egress Messages - Messages which make up application protocol.
          - Messages are sent to a clustered service with a IngressMessageHeader followed by an application payload.
          - The service may emit responses and events with a EgressMessageHeader followed by an application payload.
          - The application protocol is the user defined messages for interacting with the service being clustered.
          - Keep alive messages should be sent when insufficient ingress messages are sent to keep the session open.

        3. Session Close
          - A cluster session can be closed with a CloseSessionRequest
          - If the session is not explicitly closed then it will timeout if the connection becomes unavailable.

        Cluster Authentication Protocol
        ===============================

        Connect protocol can occur in multiple valid sequences

        1. Authenticated via Session Connect
            -> session-connect, ...
                      \
            <-          *session-event (OK), ...

        2. Authenticated via Challenge Response
            -> session-connect,   challenge-response, ...
                      \            /              \
            <-          challenge,                  session-event (OK), ...

        3. Rejected via Session Connect
            -> session-connect
                      \
            <-          *session-event (AUTHENTICATION_REJECTED)

        4. Rejected via Challenge Response
            -> session-connect,   challenge-response
                      \            /              \
            <-          challenge,                  session-event (AUTHENTICATION_REJECTED)

    -->

    <sbe:message name="IngressMessageHeader"
                 id="1"
                 description="Header for ingress messages from a client to the cluster services">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="leadershipTermId"     id="3" type="int64"/>
    </sbe:message>

    <sbe:message name="EgressMessageHeader"
                 id="2"
                 description="Header for egress messages from a service to the cluster client">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="timestamp"            id="3" type="time_t"/>
    </sbe:message>

    <sbe:message name="SessionEvent"
                 id="3"
                 description="Response to a connect request or async event. Details will be empty if code is OK">
        <field name="clusterSessionId"     id="1" type="int64"
               description="Session id for a multiplexed session over a shared connection, i.e. same Image"/>
        <field name="correlationId"        id="2" type="int64"
               description="Request correlation id with which this event is associated"/>
        <field name="leadershipTermId"     id="3" type="int64"
               description="Current leadership term identifier"/>
        <field name="leaderMemberId"       id="4" type="int32"
               description="current leader of the cluster"/>
        <field name="code"                 id="5" type="EventCode"
               description="code type of the response"/>
        <data  name="detail"               id="6" type="varAsciiEncoding"
               description="Further detail such as an error message or list of cluster member endpoints"/>
    </sbe:message>

    <sbe:message name="SessionConnectRequest"
                 id="4"
                 description="Connect to the cluster and if successful then open a session">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="responseStreamId"     id="3" type="int32"/>
        <data  name="responseChannel"      id="4" type="varAsciiEncoding"/>
        <data  name="encodedCredentials"   id="5" type="varDataEncoding"/>
    </sbe:message>

    <sbe:message name="SessionCloseRequest"
                 id="5"
                 description="Close an open cluster session">
        <field name="clusterSessionId"     id="1" type="int64"/>
    </sbe:message>

    <sbe:message name="SessionKeepAlive"
                 id="6"
                 description="Keep a cluster session open by indicating the client is alive">
        <field name="clusterSessionId"     id="1" type="int64"/>
        <field name="leadershipTermId"     id="2" type="int64"/>
    </sbe:message>

    <sbe:message name="NewLeaderEvent"
                 id="7"
                 description="Event to indicate a new leader has been elected for the cluster">
        <field name="clusterSessionId"     id="1" type="int64"/>
        <field name="leadershipTermId"     id="2" type="int64"/>
        <field name="leaderMemberId"       id="3" type="int32"/>
        <data  name="memberEndpoints"      id="4" type="varAsciiEncoding"/>
    </sbe:message>

    <sbe:message name="Challenge"
                 id="8"
                 description="Challenge the client to provide credentials">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <data  name="encodedChallenge"     id="3" type="varDataEncoding"/>
    </sbe:message>

    <sbe:message name="ChallengeResponse"
                 id="9"
                 description="Respond to a cluster challenge with credentials">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <data  name="encodedCredentials"   id="3" type="varDataEncoding"/>
    </sbe:message>

    <!-- Codecs for messages that get encoded into the log by the Consensus Module -->

    <sbe:message name="SessionHeader"
                 id="20"
                 description="Header for ingress messages from clients appended to the log">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="timestamp"            id="3" type="time_t"/>
    </sbe:message>

    <sbe:message name="TimerEvent"
                 id="21"
                 description="Timer triggered event as the result of a deadline passing on a registered timer">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="timestamp"            id="2" type="time_t"/>
    </sbe:message>

    <sbe:message name="SessionOpenEvent"
                 id="22"
                 description="Event for the state machine to notify a session has been opened">
        <field name="correlationId"        id="1" type="int64"/>
        <field name="clusterSessionId"     id="2" type="int64"/>
        <field name="timestamp"            id="3" type="time_t"/>
        <field name="responseStreamId"     id="4" type="int32"/>
        <data  name="responseChannel"      id="5" type="varAsciiEncoding"/>
{'fraction_non_alphanumeric': 0.118265025474548, 'fraction_numerical': 0.01830560440055909, 'mean_word_length': 2.2033506643558636, 'pattern_counts': {'":': 0, '<': 277, '<?xml version=': 2, '>': 277, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '11467', 'n_tokens_mistral': 5860, 'n_tokens_neox': 5547, 'n_words': 1624}