<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     category="info"
     docName="draft-vidiniotis-crp-core-00"
     ipr="trust200902"
     submissionType="independent"
     xml:lang="en"
     version="3">

  <front>
    <title abbrev="CRP Core">Context Relay Protocol (CRP) — Core Specification</title>

    <seriesInfo name="Internet-Draft" value="draft-vidiniotis-crp-core-00"/>

    <author fullname="Constantinos Vidiniotis" initials="C." surname="Vidiniotis">
      <organization>AutoCyber AI Pty Ltd</organization>
      <address>
        <email>contact@crprotocol.io</email>
      </address>
    </author>

    <date year="2026" month="May" day="24"/>

    <area>ART</area>

    <keyword>AI</keyword>
    <keyword>LLM</keyword>
    <keyword>context</keyword>
    <keyword>safety</keyword>
    <keyword>governance</keyword>
    <keyword>hallucination</keyword>
    <keyword>provenance</keyword>
    <keyword>compliance</keyword>

    <abstract>
      <t>
        The Context Relay Protocol (CRP) defines a structured,
        language-agnostic protocol for managing AI context, safety
        governance, and compliance evidence in deployed large language
        model (LLM) systems.  CRP operates as an HTTP-compatible sidecar
        protocol, enriching every AI request/response cycle with
        standardised headers carrying context quality, hallucination
        risk, provenance integrity, and regulatory classification
        metadata.
      </t>
      <t>
        This document defines the foundational axioms, request/response
        model, sidecar architecture, and the normative relationship
        between CRP's subsystems: the Context Envelope, Contextual
        Knowledge Fabric (CKF), Decision Provenance Engine (DPE), and
        the Audit Chain.
      </t>
    </abstract>

    <note title="Feedback">
      <t>
        This is a working draft of the CRP Core Specification, published
        for review and comment.  Feedback may be submitted via email to
        <eref target="mailto:contact@autocyberai.com">contact@autocyberai.com</eref>
        or
        <eref target="mailto:contact@crprotocol.io">contact@crprotocol.io</eref>,
        or at the CRP GitHub repository at
        <eref target="https://github.com/crprotocol/spec">github.com/crprotocol/spec</eref>.
      </t>
    </note>
  </front>

  <middle>

    <!-- ============================================================ -->
    <section anchor="introduction">
      <name>Introduction</name>

      <section anchor="background">
        <name>Background</name>
        <t>
          Large language model systems deployed in production lack a
          standardised mechanism for communicating the quality, safety,
          and compliance state of their outputs to consuming applications,
          intermediary services, and governance platforms.  Each system
          operator builds bespoke instrumentation to capture hallucination
          risk, session state, and audit trails — leading to fragmented,
          non-interoperable approaches.
        </t>
        <t>The Context Relay Protocol addresses this gap by defining:</t>
        <ul spacing="normal">
          <li>
            A <strong>wire-level header vocabulary</strong> (see CRP-SPEC-002)
            analogous to HTTP headers, carrying AI-specific metadata on
            every request/response.
          </li>
          <li>
            A <strong>session state relay mechanism</strong> (see CRP-SPEC-007)
            analogous to HTTP cookies, enabling stateless context
            continuity.
          </li>
          <li>
            A <strong>safety policy directive language</strong> (see CRP-SPEC-006)
            analogous to Content Security Policy, enabling declarative AI
            safety enforcement at the transport layer.
          </li>
          <li>
            A <strong>provenance and audit chain</strong> (see CRP-SPEC-011)
            enabling tamper-evident, cryptographically verifiable
            compliance evidence.
          </li>
        </ul>
      </section>

      <section anchor="relationship-to-existing-protocols">
        <name>Relationship to Existing Protocols</name>
        <t>
          CRP is designed to complement, not replace, existing AI agent
          protocols:
        </t>
        <table>
          <thead>
            <tr>
              <th align="left">Protocol</th>
              <th align="left">Role</th>
              <th align="left">CRP Relationship</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">MCP (Model Context Protocol)</td>
              <td align="left">Tool/resource access for agents</td>
              <td align="left">CRP governs the AI calls MCP agents make</td>
            </tr>
            <tr>
              <td align="left">A2A (Agent-to-Agent)</td>
              <td align="left">Inter-agent communication</td>
              <td align="left">CRP headers propagate safety state across A2A hops</td>
            </tr>
            <tr>
              <td align="left">OpenAI API</td>
              <td align="left">LLM inference</td>
              <td align="left">CRP gateway proxies OpenAI-compatible endpoints</td>
            </tr>
            <tr>
              <td align="left">HTTP/1.1, HTTP/2</td>
              <td align="left">Transport</td>
              <td align="left">CRP headers are carried as standard HTTP header fields</td>
            </tr>
          </tbody>
        </table>
      </section>

      <section anchor="goals">
        <name>Goals</name>
        <ol spacing="normal" type="1">
          <li>Provide a universal, language-agnostic metadata contract for AI request/response cycles.</li>
          <li>Enable safety enforcement at the transport layer, not the application layer.</li>
          <li>Generate continuous compliance evidence without developer instrumentation.</li>
          <li>Remain compatible with all major LLM providers and agent frameworks.</li>
          <li>Be implementable as an RFC-based open standard.</li>
        </ol>
      </section>

      <section anchor="non-goals">
        <name>Non-Goals</name>
        <ul spacing="normal">
          <li>CRP does not modify LLM model weights or training.</li>
          <li>CRP does not replace application-level business logic.</li>
          <li>CRP does not mandate a specific LLM provider.</li>
          <li>CRP does not define agent behaviour beyond the dispatch interface.</li>
        </ul>
      </section>

    </section>

    <!-- ============================================================ -->
    <section anchor="terminology">
      <name>Terminology</name>
      <t>
        The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
        "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
        "OPTIONAL" in this document are to be interpreted as described
        in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/>.
      </t>

      <dl newline="false" spacing="normal">
        <dt>AI call:</dt>
        <dd>A single request/response cycle to a large language model.</dd>

        <dt>CRP Gateway:</dt>
        <dd>
          An HTTP-compatible reverse proxy that implements the CRP
          protocol, sitting between a client application and one or
          more LLM providers.
        </dd>

        <dt>Context Envelope:</dt>
        <dd>
          The structured set of facts, knowledge fragments, and
          instructions assembled by the CRP gateway for injection into
          an LLM request.
        </dd>

        <dt>Contextual Knowledge Fabric (CKF):</dt>
        <dd>
          The persistent fact graph (Tier 3 of the CRP memory
          hierarchy) from which Context Envelopes are assembled.
        </dd>

        <dt>Decision Provenance Engine (DPE):</dt>
        <dd>
          The CRP module responsible for post-generation analysis of
          LLM outputs, producing hallucination risk scores, attribution
          analysis, and provenance records.
        </dd>

        <dt>Safety Budget:</dt>
        <dd>
          A session-scoped counter representing remaining risk
          tolerance, decremented by each high-risk AI call.  Exposed
          as <tt>CRP-Agent-Safety-Budget</tt>.
        </dd>

        <dt>Window:</dt>
        <dd>
          A single AI call within a continuation chain.  Windows are
          connected in a directed acyclic graph (DAG) for context
          enlargement across multiple calls.
        </dd>
      </dl>
    </section>

    <!-- ============================================================ -->
    <section anchor="axioms">
      <name>The Ten Axioms</name>
      <t>
        CRP's design is governed by ten foundational axioms.  All
        conformant CRP implementations MUST uphold these axioms.
      </t>

      <dl newline="false" spacing="normal">
        <dt>Axiom 1 — Completeness:</dt>
        <dd>
          The Context Envelope MUST include all factual content
          necessary for the LLM to answer the query without reliance on
          parametric memory, where such content exists in the CKF.
        </dd>

        <dt>Axiom 2 — Accuracy:</dt>
        <dd>
          Facts included in the envelope MUST be drawn from verified
          source material.  The DPE MUST assess output accuracy against
          envelope content.
        </dd>

        <dt>Axiom 3 — Relevance:</dt>
        <dd>
          The envelope packing algorithm MUST prioritise facts by
          relevance score.  Irrelevant facts MUST NOT consume token
          budget at the cost of relevant facts.
        </dd>

        <dt>Axiom 4 — Transparency boundary:</dt>
        <dd>
          CRP headers MUST NOT be forwarded to LLM providers.  The
          model MUST remain ignorant of the protocol layer.
        </dd>

        <dt>Axiom 5 — Oversight capability:</dt>
        <dd>
          All CRP implementations MUST support human oversight
          triggering.  The <tt>CRP-Oversight-Mode: halt</tt> directive
          MUST be honoured unconditionally.
        </dd>

        <dt>Axiom 6 — Resource constraint awareness:</dt>
        <dd>
          The gateway MUST track token budget consumption and expose it
          via <tt>CRP-Context-Tokens-Used</tt> and
          <tt>CRP-Context-Window</tt> headers.
        </dd>

        <dt>Axiom 7 — Provenance integrity:</dt>
        <dd>
          Every AI call MUST produce a tamper-evident audit record.
          HMAC chain integrity MUST be verifiable by any party holding
          the session key.
        </dd>

        <dt>Axiom 8 — Continuity:</dt>
        <dd>
          Continuation sessions MUST preserve context quality across
          window boundaries.  The <tt>CRP-Context-Continuation-Id</tt>
          header MUST enable stateless session relay.
        </dd>

        <dt>Axiom 9 — Regulatory alignment:</dt>
        <dd>
          CRP outputs MUST be classifiable against EU AI Act, GDPR,
          NIST AI RMF, and ISO 42001 frameworks.  Classification MUST
          be emitted as response headers.
        </dd>

        <dt>Axiom 10 — Provider neutrality:</dt>
        <dd>
          CRP MUST support any LLM provider exposing an
          OpenAI-compatible API.  Provider selection MUST be
          transparent to consuming applications.
        </dd>
      </dl>
    </section>

    <!-- ============================================================ -->
    <section anchor="protocol-architecture">
      <name>Protocol Architecture</name>

      <section anchor="overview">
        <name>Overview</name>
        <artwork type="ascii-art" name="CRP Gateway Architecture"><![CDATA[
+----------------------------------------------------------+
|                   Client Application                     |
|  (sends CRP-Accept-*, CRP-Safety-Policy, CRP-Session)    |
+-------------------------+--------------------------------+
                          | HTTP request with CRP req headers
                          v
+----------------------------------------------------------+
|                      CRP Gateway                         |
|  +----------+  +----------+  +----------+  +----------+ |
|  | Envelope |  |   DPE    |  |  Audit   |  |  Comply  | |
|  | Builder  |  | (Safety) |  |  Chain   |  |   Feed   | |
|  +----------+  +----------+  +----------+  +----------+ |
+-------------------------+--------------------------------+
                          | Stripped request (no CRP headers)
                          v
+----------------------------------------------------------+
|                     LLM Provider                         |
|          (OpenAI / Anthropic / Gemini / Ollama)          |
+----------------------------------------------------------+
        ]]></artwork>
      </section>

      <section anchor="request-flow">
        <name>Request Flow</name>
        <ol spacing="normal" type="1">
          <li>Client sends HTTP request to CRP gateway with optional CRP request headers.</li>
          <li>Gateway authenticates request using CRP API key.</li>
          <li>Gateway checks <tt>CRP-Context-If-Match</tt> — returns 304 if ETag matches.</li>
          <li>Gateway assembles Context Envelope from CKF (3-phase: select, rank, pack).</li>
          <li>Gateway selects dispatch strategy from <tt>CRP-Accept-Strategy</tt> or TaskIntent detection.</li>
          <li>Gateway strips all CRP headers, forwards packed request to LLM provider.</li>
          <li>LLM provider returns raw completion.</li>
          <li>Gateway runs DPE pipeline on completion (13 modules).</li>
          <li>Gateway evaluates completion against <tt>CRP-Safety-Policy</tt>.</li>
          <li>If policy violation (e.g., <tt>halt-on CRITICAL</tt>): returns HTTP 451, fires report-uri webhook.</li>
          <li>Gateway injects all response CRP headers.</li>
          <li>Gateway updates HMAC chain, issues updated <tt>CRP-Set-Session</tt> token.</li>
          <li>Gateway streams audit event to CRP Comply (if configured).</li>
          <li>Gateway returns response with CRP headers to client.</li>
        </ol>
      </section>

      <section anchor="memory-hierarchy">
        <name>Memory Hierarchy</name>
        <t>CRP implements a four-tier memory hierarchy:</t>
        <table>
          <thead>
            <tr>
              <th align="left">Tier</th>
              <th align="left">Name</th>
              <th align="left">Latency</th>
              <th align="left">Persistence</th>
              <th align="left">CRP Header</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">0</td>
              <td align="left">Active (in-context)</td>
              <td align="left">&lt;1ms</td>
              <td align="left">Call-scoped</td>
              <td align="left"><tt>CRP-Context-Window</tt></td>
            </tr>
            <tr>
              <td align="left">1</td>
              <td align="left">Hot (session cache)</td>
              <td align="left">&lt;10ms</td>
              <td align="left">Session-scoped</td>
              <td align="left"><tt>CRP-Context-Session-Id</tt></td>
            </tr>
            <tr>
              <td align="left">2</td>
              <td align="left">Warm (recent CKF)</td>
              <td align="left">&lt;100ms</td>
              <td align="left">Cross-session</td>
              <td align="left"><tt>CRP-Memory-CKF-Hits</tt></td>
            </tr>
            <tr>
              <td align="left">3</td>
              <td align="left">Cold (full CKF graph)</td>
              <td align="left">&lt;1000ms</td>
              <td align="left">Persistent</td>
              <td align="left"><tt>CRP-Memory-Knowledge-Age</tt></td>
            </tr>
          </tbody>
        </table>
      </section>

    </section>

    <!-- ============================================================ -->
    <section anchor="conformance-levels">
      <name>Conformance Levels</name>
      <t>CRP defines three conformance levels:</t>

      <dl newline="false" spacing="normal">
        <dt>CRP-Basic:</dt>
        <dd>
          Implements core headers (<tt>CRP-Context-Quality-Tier</tt>,
          <tt>CRP-Safety-Hallucination-Risk</tt>,
          <tt>CRP-Provenance-HMAC</tt>), session tokens, and HTTP 451
          halt.  This is the minimum viable governance level.
        </dd>

        <dt>CRP-Standard:</dt>
        <dd>
          Implements all 58 headers, Safety Policy directives, ETag
          caching, agentic dispatch headers, and compliance headers.
          Required for CRP Comply integration.
        </dd>

        <dt>CRP-Full:</dt>
        <dd>
          Implements all of Standard plus streaming safety enforcement,
          stop-sequence injection, multi-agent safety budget
          propagation, and SIEM export.  Required for CRP
          Certification.
        </dd>
      </dl>
    </section>

    <!-- ============================================================ -->
    <section anchor="security-considerations">
      <name>Security Considerations</name>

      <section anchor="header-injection">
        <name>Header Injection</name>
        <t>
          CRP headers on responses MUST be generated by the CRP
          gateway, not by LLM output.  Implementations MUST validate
          that no CRP-prefixed headers are present in raw LLM responses
          before injection.
        </t>
      </section>

      <section anchor="session-token-security">
        <name>Session Token Security</name>
        <t>
          The <tt>CRP-Set-Session</tt> token MUST be signed with
          HMAC-SHA256 using a session key not derivable from the token
          payload.  Tokens MUST include an expiry and MUST NOT be
          accepted after expiry.
        </t>
      </section>

      <section anchor="hmac-chain-integrity">
        <name>HMAC Chain Integrity</name>
        <t>
          The HMAC chain MUST be computed as:
          <tt>HMAC-SHA256(window_content || previous_HMAC, session_key)</tt>.
          Any break in the chain (verified via
          <tt>CRP-Provenance-Chain-Integrity: BROKEN</tt>) MUST trigger
          an audit incident.
        </t>
      </section>

      <section anchor="llm-provider-credentials">
        <name>LLM Provider Credentials</name>
        <t>
          CRP gateways that vault LLM provider credentials MUST store
          keys encrypted at rest.  Client applications MUST NOT be
          required to hold LLM provider credentials when using a CRP
          gateway.
        </t>
      </section>

    </section>

    <!-- ============================================================ -->
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>
        This document requests registration of the <tt>CRP-</tt> prefix
        in the HTTP Field Name Registry at
        <eref target="https://www.iana.org/assignments/http-fields">https://www.iana.org/assignments/http-fields</eref>
        per <xref target="RFC9110"/> Section 16.3.
      </t>
      <t>
        A complete list of headers for registration is provided in
        CRP-SPEC-002 (Header Specification).
      </t>
    </section>

  </middle>

  <back>

    <!-- ============================================================ -->
    <references>
      <name>References</name>

      <references anchor="normative-references">
        <name>Normative References</name>

        <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author initials="S." surname="Bradner" fullname="Scott Bradner">
              <organization>Harvard University</organization>
            </author>
            <date year="1997" month="March"/>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>

        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author initials="B." surname="Leiba" fullname="Barry Leiba">
              <organization>Huawei Technologies</organization>
            </author>
            <date year="2017" month="May"/>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>

        <reference anchor="RFC9110" target="https://www.rfc-editor.org/info/rfc9110">
          <front>
            <title>HTTP Semantics</title>
            <author initials="R." surname="Fielding" fullname="Roy Fielding">
              <organization>Adobe</organization>
            </author>
            <author initials="M." surname="Nottingham" fullname="Mark Nottingham">
              <organization>Fastly</organization>
            </author>
            <author initials="J." surname="Reschke" fullname="Julian Reschke">
              <organization>greenbytes GmbH</organization>
            </author>
            <date year="2022" month="June"/>
          </front>
          <seriesInfo name="STD" value="97"/>
          <seriesInfo name="RFC" value="9110"/>
          <seriesInfo name="DOI" value="10.17487/RFC9110"/>
        </reference>

        <reference anchor="RFC6265" target="https://www.rfc-editor.org/info/rfc6265">
          <front>
            <title>HTTP State Management Mechanism</title>
            <author initials="A." surname="Barth" fullname="Adam Barth">
              <organization>Google, Inc.</organization>
            </author>
            <date year="2011" month="April"/>
          </front>
          <seriesInfo name="RFC" value="6265"/>
          <seriesInfo name="DOI" value="10.17487/RFC6265"/>
        </reference>

      </references>

      <references anchor="informative-references">
        <name>Informative References</name>

        <reference anchor="EU-AI-ACT">
          <front>
            <title>Regulation (EU) 2024/1689 of the European Parliament and of the Council laying down harmonised rules on artificial intelligence (Artificial Intelligence Act)</title>
            <author>
              <organization>European Parliament and Council of the European Union</organization>
            </author>
            <date year="2024"/>
          </front>
        </reference>

        <reference anchor="ISO42001">
          <front>
            <title>ISO/IEC 42001:2023 — Artificial intelligence — Management system</title>
            <author>
              <organization>International Organization for Standardization</organization>
            </author>
            <date year="2023"/>
          </front>
        </reference>

        <reference anchor="NIST-AI-RMF" target="https://airc.nist.gov/RMF">
          <front>
            <title>Artificial Intelligence Risk Management Framework (AI RMF 1.0)</title>
            <author>
              <organization>National Institute of Standards and Technology (NIST)</organization>
            </author>
            <date year="2023" month="January"/>
          </front>
        </reference>

        <reference anchor="GDPR">
          <front>
            <title>Regulation (EU) 2016/679 of the European Parliament and of the Council on the protection of natural persons with regard to the processing of personal data (General Data Protection Regulation)</title>
            <author>
              <organization>European Parliament and Council of the European Union</organization>
            </author>
            <date year="2016"/>
          </front>
        </reference>

      </references>
    </references>

    <!-- ============================================================ -->
    <section anchor="appendix-b-change-history" numbered="false">
      <name>Change History</name>
      <table>
        <thead>
          <tr>
            <th align="left">Version</th>
            <th align="left">Date</th>
            <th align="left">Changes</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td align="left">1.0.0</td>
            <td align="left">2024-01-01</td>
            <td align="left">Initial protocol release</td>
          </tr>
          <tr>
            <td align="left">2.0.0</td>
            <td align="left">2024-06-01</td>
            <td align="left">DPE integration, HMAC chain</td>
          </tr>
          <tr>
            <td align="left">3.0.0</td>
            <td align="left">2026-05-24</td>
            <td align="left">Header specification, Safety Policy, Session Token</td>
          </tr>
        </tbody>
      </table>
    </section>

  </back>
</rfc>
