<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Message Processing Hints</title>
  <abstract>This document defines a way to include hints to entities routing or receiving a message.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0334</number>
  <status>Draft</status>
  <lastcall>2024-04-08</lastcall>
  <lastcall>2017-03-01</lastcall>
  <lastcall>2017-02-22</lastcall>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>hints</shortname>
  
  <author>
    <firstname>Matthew</firstname>
    <surname>Wild</surname>
    <email>mwild1@gmail.com</email>
    <jid>me@matthewwild.co.uk</jid>
  </author>

   <revision>
    <version>1.0.0</version>
    <date>2024-04-17</date>
    <initials>XEP Editor (dg)</initials>
    <remark>Accept as Stable as per Council Vote from 2024-04-17</remark>
  </revision>
  <revision>
    <version>0.5.0</version>
    <date>2024-03-25</date>
    <initials>mw</initials>
    <remark>
      <p>Incorporate last call feedback from 2017.</p>
      <p>Differences between this specification and XEP-0079 have been clarified.</p>
      <p>A note about handling of hints found in error stanzas has been added.</p>
    </remark>
  </revision>
  <revision>
    <version>0.4.0</version>
    <date>2024-03-25</date>
    <initials>XEP Editor (dg)</initials>
    <remark>Move back to Experimental</remark>
  </revision>
  <revision>
    <version>0.3.0</version>
    <date>2018-01-25</date>
    <initials>XEP Editor (jwi)</initials>
    <remark>Defer due to lack of activity.</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2015-09-01</date>
    <initials>dg</initials>
    <remark>
      <p>Fixed the wrong use of no-storage instead of no-store</p>
      <p>Added a message hint &lt;store/&gt;</p>
    </remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2013-07-11</date>
    <initials>psa</initials>
    <remark><p>Initial published version approved by the XMPP Council.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2013-06-18</date>
    <initials>mw</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>Message types ('normal', 'chat', 'headline', etc.) provide an existing framework for determining how an entity should deliver or handle a message. For example <span class="ref"><link url="http://tools.ietf.org/html/rfc6121">XMPP IM</link></span> <note>RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence &lt;<link url="http://tools.ietf.org/html/rfc6121">http://tools.ietf.org/html/rfc6121</link>&gt;.</note> defines that messages of type 'headline' should not be stored offline by the server, and that messages of type 'groupchat' must not be directed to other resources.</p>
  <p>However this framework of rules is quite inflexible, and new extensions are being developed that push at the boundaries of what is capable of. This specification defines a more flexible approach that allows the sender to add finer-grained 'hints' to messages, which can be used as a generic mechanism for XMPP entities to handle messages.</p>
</section1>
<section1 topic="Requirements" anchor="reqs">
  <p>This specification aims to solve the following common problems, and allow a sender to hint to
    the recipient:</p>
  <ul>
    <li>Whether to store a message (e.g. for archival or as an 'offline message').</li>
    <li>Whether to copy a message to other resources.</li>
    <li>Whether to store a message that would not have been stored under normal conditions</li>
  </ul>
  <section2 topic="Comparison with XEP-0079: Advanced Message Processing" anchor="amp">
    <p>Previous work has been done to make XMPP's routing rules extensible, most notably in <span class="ref"><link url="https://xmpp.org/extensions/xep-0079.html">Advanced Message Processing (XEP-0079)</link></span> <note>XEP-0079: Advanced Message Processing &lt;<link url="https://xmpp.org/extensions/xep-0079.html">https://xmpp.org/extensions/xep-0079.html</link>&gt;.</note>. However, this specification failed to gain widespread adoption, likely due to its complexity. This specification aims to be much simpler for both senders and routing entities to incorporate into their existing stanza handling.</p>
    <p>Some other differences include:</p>
    <ul>
      <li>XEP-0079 provides a rule-based prescriptive approach to routing. Hints only convey the stanza's semantics from the perspective of the sender, leaving the exact processing up to the receiving/routing entities.</li>
      <li>XEP-0079 requires multiple discovery steps before you can send a message. Hints are lighter, but provide no guarantee to the sender about how entities will process a hint.</li>
      <li>Reuse of XEP-0079 within other XEPs is harder. The "semantic building blocks" of hints fit well into many protocols, and are already used in this way.</li>
      <li>XEP-0079 has lots of potential edge cases, e.g. when it comes to interaction with group chats. Hints are more adaptable and even forwards-compatible, as the relatively simple semantics can be remapped onto future protocols.</li>
      <li>Hints intentionally do not include time restrictions, tracking, or any of the advanced features XEP-0079 provides.</li>
    </ul>
    <p>Implementations are free to support both XEP-0079 and hints simultaneously - they are not mutually exclusive.</p>
  </section2>
</section1>
<section1 topic="Use Cases" anchor="usecases">
  <section2 topic="Session-based stanzas" anchor="usecases-session">
  <p>Suppose that Romeo and Juliet are avoiding the surveillance of Prince Escalus and communicating using a session-based
    encryption protocol between their laptops. In order to prevent Juliet's tablet computer that uses <span class="ref"><link url="https://xmpp.org/extensions/xep-0280.html">Message Carbons (XEP-0280)</link></span> <note>XEP-0280: Message Carbons &lt;<link url="https://xmpp.org/extensions/xep-0280.html">https://xmpp.org/extensions/xep-0280.html</link>&gt;.</note> from receiving
    copies of the encrypted messages (and not being able to decrypt them), Romeo inserts the &lt;no-copy/&gt; hint into the
    messages he sends. Since it is also useless for these messages to be archived, he additionally adds the &lt;no-store/&gt;
    hint:</p>
  <example caption="Sending a message with no-copy and no-store hints"><![CDATA[
<message
    from='romeo@montague.lit/laptop'
    to='juliet@capulet.lit/laptop'>
  <body>V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug</body>
  <no-copy xmlns="urn:xmpp:hints"/>
  <no-store xmlns="urn:xmpp:hints"/>
</message>
]]></example>
</section2>
<section2 topic="Notifications" anchor="usecases-notification">
  <p>Some automated notifications may be transient, and there would be no purpose in delaying their delivery. Such
    messages may be marked with the &lt;no-store/&gt; hint.</p>
</section2>
<section2 topic="Sensitive messages" anchor="usercases-sensitive">
  <p>A sender may want to indicate their preference to have no permanent record of a message (also known as "off the
    record" messages), but may be happy for it to be stored temporarily as a normal part of delivery (e.g. if the
    recipient is offline at the time of sending). Such a message can be marked with the &lt;no-permanent-store/&gt; hint.
  </p>
</section2>
<section2 topic="Storage-worthy messages" anchor="store-worthy">
  <p>Offline storage and <span class="ref"><link url="https://xmpp.org/extensions/xep-0313.html">Message Archive Management (XEP-0313)</link></span> <note>XEP-0313: Message Archive Management &lt;<link url="https://xmpp.org/extensions/xep-0313.html">https://xmpp.org/extensions/xep-0313.html</link>&gt;.</note> can define their own rules on what messages to store and usually only store messages that contain a body element. However a sender may want to indicate that a message is worth storing even though it might not match those rules (e.g. an encrypted message that carries the payload outside the body element). Such a message can be marked with a &lt;store/&gt; hint.</p>
</section2>
</section1>
<section1 topic="Hints" anchor="hints">
  <section2 topic="No permanent store" anchor="no-permanent-store">
    <p>The &lt;no-permanent-store/&gt; hint informs entities that they shouldn't store the message in
      any permanent or semi-permanent public or private archive (such as described in <span class="ref"><link url="https://xmpp.org/extensions/xep-0136.html">Message Archiving (XEP-0136)</link></span> <note>XEP-0136: Message Archiving &lt;<link url="https://xmpp.org/extensions/xep-0136.html">https://xmpp.org/extensions/xep-0136.html</link>&gt;.</note> and <span class="ref"><link url="https://xmpp.org/extensions/xep-0313.html">Message Archive Management (XEP-0313)</link></span> <note>XEP-0313: Message Archive Management &lt;<link url="https://xmpp.org/extensions/xep-0313.html">https://xmpp.org/extensions/xep-0313.html</link>&gt;.</note>)
      or in logs (such as chatroom logs).
    </p>
  </section2>
  <section2 topic="No store" anchor="no-store">
    <p>A message containing a &lt;no-store/&gt; hint should not be stored by a server either permanently (as above)
    or temporarily, e.g. for later delivery to an offline client, or to users not currently present in a chatroom.
    </p>
  </section2>
  <section2 topic="No copies" anchor="no-copy">
    <p>Messages with the &lt;no-copy/&gt; hint should not be copied to addresses other than the one to which it is
      addressed, for example through <span class="ref"><link url="https://xmpp.org/extensions/xep-0280.html">Message Carbons (XEP-0280)</link></span> <note>XEP-0280: Message Carbons &lt;<link url="https://xmpp.org/extensions/xep-0280.html">https://xmpp.org/extensions/xep-0280.html</link>&gt;.</note>.</p>
    <p>This hint MUST only be included on messages addressed to full JIDs and explicitly does not override the behaviour
      defined in <span class="ref"><link url="http://tools.ietf.org/html/rfc6121">XMPP IM</link></span> <note>RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence &lt;<link url="http://tools.ietf.org/html/rfc6121">http://tools.ietf.org/html/rfc6121</link>&gt;.</note> for handling messages to bare JIDs, which may involve copying to multiple resources, or multiple
      occupants in a <span class="ref"><link url="https://xmpp.org/extensions/xep-0045.html">Multi-User Chat (XEP-0045)</link></span> <note>XEP-0045: Multi-User Chat &lt;<link url="https://xmpp.org/extensions/xep-0045.html">https://xmpp.org/extensions/xep-0045.html</link>&gt;.</note> room.
    </p>
  </section2>
  <section2 topic="Store">
    <p>A message containing the &lt;store/&gt; hint that is not of type 'error' SHOULD be stored by the entity.</p>
  </section2>
</section1>
<section1 topic="Business Rules" anchor="rules">
  <p>It is important to note that message hints are, as the name implies, just hints. Implementations
    MUST NOT rely on other entities interpretation of the hints for any particular purpose.</p>
  <p>In particular, if an entity supports both this protocol and the protocol defined in XEP-0079,
    the directives in the latter SHOULD take precedence over any hints present in a stanza.</p>
  <p>Hints contained within a stanza of type 'error' SHOULD be ignored. This is because error
    stanzas often include the unmodified payload of an original stanza that caused the error,
    while an implementation may want to apply different logic to an error response for such a stanza.</p>
</section1>
<section1 topic="Security Considerations" anchor="security">
  <p>This specification introduces no known security considerations.</p>
</section1>
<section1 topic="IANA Considerations" anchor="iana">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>This document requires no interaction with <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note>.</p>
</section1>
<section1 topic="XML Schema">
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:hints'
    xmlns='urn:xmpp:hints'
    elementFormDefault='qualified'>

  <xs:element name='no-permanent-store' type='empty'/>
  <xs:element name='no-store' type='empty'/>
  <xs:element name='no-copy' type='empty'/>
  <xs:element name='store' type='empty'/>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
]]></code>
</section1>
</xep>
