XEP-0237: Roster Sequencing

This specification proposes a modification to the XMPP roster management protocol to support sequencing of roster changes for more efficient downloading of the roster information.


WARNING: This Standards-Track document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the XMPP Standards Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems should not deploy implementations of this protocol until it advances to a status of Draft.


Document Information

Series: XEP
Number: 0237
Publisher: XMPP Standards Foundation
Status: Experimental
Type: Standards Track
Version: 0.2
Last Updated: 2008-03-06
Approving Body: XMPP Council
Dependencies: XMPP Core, XMPP IM
Supersedes: None
Superseded By: None
Short Name: NOT YET ASSIGNED
Wiki Page: <http://wiki.jabber.org/index.php/Roster Sequencing (XEP-0237)>


Author Information

Peter Saint-Andre

JabberID: stpeter@jabber.org
URI: https://stpeter.im/


Legal Notices

Copyright

This XMPP Extension Protocol is copyright (c) 1999 - 2008 by the XMPP Standards Foundation (XSF).

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.

Disclaimer of 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. In no event shall the XMPP Standards Foundation or the authors of this Specification be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification. ##

Limitation of 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 out of the use or inability to use 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.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which may be found at <http://www.xmpp.org/extensions/ipr-policy.shtml> or obtained by writing to XSF, P.O. Box 1641, Denver, CO 80201 USA).

Discussion Venue

The preferred venue for discussion of this document is the Standards discussion list: <http://mail.jabber.org/mailman/listinfo/standards>.

Errata may be sent to <editor@xmpp.org>.

Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Conformance Terms

The following keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".


Table of Contents


1. Introduction
2. Protocol
    2.1. Advertising Support
    2.2. Roster Get
    2.3. Roster Result (Unchanged)
    2.4. Roster Result (Changed)
    2.5. Roster Pushes
3. Security Considerations
4. IANA Considerations
5. XMPP Registrar Considerations
    5.1. Protocol Namespaces
6. XML Schemas
    6.1. Roster Management
    6.2. Stream Feature
7. Acknowledgements
Notes
Revision History


1. Introduction

Note: This document describes a protocol or best practice that is intended for incorporation into the specification that will supersede RFC 3921 [1] within the Internet Standards Process, i.e., rfc3921bis [2]. This document is provided only for the purpose of open community discussion of the potential modification and will be obsoleted as soon as the relevant RFC is published.

RFC 3921 specifies that an XMPP client must retrieve the entire roster on login. However, XMPP rosters can be quite large and often the roster has not changed since it was last retrieved. If the client could cache the roster and retrieve only changes to the roster, the login process could be significantly streamlined, which could be especially valuable over low-bandwidth connections such as those common in mobile environments. This document defines a method for such streamlining, via the concept of roster sequencing.

Note: This document is provided for discussion purposes in order to improve roster management in XMPP systems. It is not meant to supersede the text in RFC 3921. However, the recommendations in this document may be folded into rfc3921bis.

2. Protocol

This document specifies the addition of a 'sequence' attribute to the <query/> element qualified by the 'jabber:iq:roster' namespace, as well as a 'diff' attribute for use in roster results.

The value of the 'sequence' attribute MUST be a non-negative integer representing a strictly increasing sequence number that is increased with any change to the roster (whether or not the client supports this extension) but MAY be a unique identifer that is opaque to the client but understood by the server. In any case, the 'sequence' attribute contained in roster pushes MUST be unique. A "change to the roster" is any addition, update, or removal of a roster item that would result in a roster push, including changes in subscription states, as described in RFC 3921 or rfc3921bis.

The attribute is used as described in the following sections.

2.1 Advertising Support

If a server supports roster sequencing, it MUST inform the client when returning stream features during the stream setup process, at the latest when informing the client that resource binding is required. This is done by including a <roster-sequencing/> element qualified by the 'urn:xmpp:tmp:roster-sequencing' namespace (see Protocol Namespaces regarding issuance of one or more permanent namespaces).

Example 1. Stream features

<stream:features>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <required/>
  </bind>
  <roster-sequencing xmlns='urn:xmpp:tmp:roster-sequencing'>
</stream:features>
    

2.2 Roster Get

If a client supports roster sequencing and knows that the server does so, it SHOULD include the 'sequence' attribute in its request for the roster, set to the sequence number associated with its last cache of the roster.

Example 2. Roster get with sequence number

<iq id='r1' type='get'>
  <query xmlns='jabber:iq:roster' sequence='305'/>
</iq>
    

If the client has not yet cached the roster or the cache is lost or corrupted, but the client wishes to bootstrap the use of roster sequencing, it SHOULD include the 'sequence' attribute set to a value of zero (0).

2.3 Roster Result (Unchanged)

If the roster has not changed since the sequence enumerated by the client, the server MUST return an empty IQ-result.

Example 3. Roster result (unchanged)

<iq id='r1' type='result'/>
    

2.4 Roster Result (Changed)

If the roster sequence number has increased since the sequence number enumerated by the client, the server MUST return a <query/> element that includes the latest sequence number.

The <query/> element SHOULD include the effective "diff" since the roster sequence number enumerated by the client (including the complete roster item with name, group, and subscription state). If the roster result is a diff and not the complete roster, the server MUST include a 'diff' attribute set to a value of "true" or "1" [3]. If the roster result is the complete roster and not a "diff" (e.g., because the server does not remember the "diff" as far back as the sequence number communicated by the client), the server SHOULD NOT include the 'diff' attribute (which defaults to "false" or "0").

Example 4. Roster result (changed)

<iq id='r1' type='result'>
  <query xmlns='jabber:iq:roster' sequence='317'>
    <item jid='bill@shakespeare.lit' subscription='both'/>
    <item jid='nurse@capulet.lit' name='Nurse' subscription='both'>
      <group>Servants</group>
    </item
    <item jid='shylock@shakespeare.lit' subscription='remove'/>
  </query>
</iq>
    

The "roster diff" can be understood as follows:

  1. Imagine that the client had an active presence session for the entire time between its cached roster sequence number (in this case, 305) and the new roster sequence number (317).
  2. During that time, the client might have received roster pushes related to roster sequence numbers 306, 307, 310, 311, 313, 314, 315, and 317 (the sequence numbers must be strictly increasing but there is no requirement that the sequence shall be continuous).
  3. However, some of those roster pushes might have contained intermediate updates to the same roster item (e.g., changes in the subscription state for bill@shakespeare.lit from "none" to "to" and from "to" to "both").
  4. The roster result would not include all of the intermediate steps, only the final result of all changes applied while the client was in fact offline.

2.5 Roster Pushes

When the server sends subsequent roster pushes to the client, it MUST include the updated roster sequence number.

Example 5. Roster push

<iq id='p1' type='set'>
  <query xmlns='jabber:iq:roster' sequence='318'>
    <item jid='bill@shakespeare.lit' name='The Bard' subscription='both'/>
  </query>
</iq>
    

3. Security Considerations

It is possible that caching of the roster (rather than holding it in memory only for the life of the session) could introduce new vulnerabilities. Client implementations should take care to appropriately protect the cached roster information.

4. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [4].

5. XMPP Registrar Considerations

5.1 Protocol Namespaces

Until this specification advances to a status of Draft, the associated namespace for its stream feature shall be "urn:xmpp:tmp:roster-sequencing"; upon advancement of this specification, the XMPP Registrar [5] shall issue a permanent namespace in accordance with the process defined in Section 4 of XMPP Registrar Function [6].

6. XML Schemas

6.1 Roster Management

If this modification to the roster management protocol is added to rfc3921bis and approved by the IESG in the speficiation that supersedes RFC 3921, the schema for the roster management namespace would be changed as follows.

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='jabber:iq:roster'
    xmlns='jabber:iq:roster'
    elementFormDefault='qualified'>

  <xs:element name='query'>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref='item'
                    minOccurs='0'
                    maxOccurs='unbounded'/>
      </xs:sequence>
      <xs:attribute name='diff' use='optional' type='xs:boolean' default='false'>
      <xs:attribute name='sequence' use='optional' type='xs:nonNegativeInteger'>
    </xs:complexType>
  </xs:element>

  <xs:element name='item'>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref='group'
                    minOccurs='0'
                    maxOccurs='unbounded'/>
      </xs:sequence>
      <xs:attribute name='ask' use='optional'>
        <xs:simpleType>
          <xs:restriction base='xs:NCName'>
            <xs:enumeration value='subscribe'/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute name='jid' type='xs:string' use='required'/>
      <xs:attribute name='name' type='xs:string' use='optional'/>
      <xs:attribute name='subscription' use='optional'>
        <xs:simpleType>
          <xs:restriction base='xs:NCName'>
            <xs:enumeration value='both'/>
            <xs:enumeration value='from'/>
            <xs:enumeration value='none'/>
            <xs:enumeration value='remove'/>
            <xs:enumeration value='to'/>
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>

  <xs:element name='group' type='xs:string'/>

</xs:schema>
    

6.2 Stream Feature

<?xml version='1.0' encoding='UTF-8'?>

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

  <xs:element name='roster-sequencing' type='empty'>

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

</xs:schema>
    

7. Acknowledgements

Thanks to Dave Cridland, Richard Dobson, Alexander Gnauck, Juha Hartikainen, Justin Karneges, and Pedro Melo for their comments.


Notes

1. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc3921>.

2. rfc3921bis: proposed revisions to Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/draft-saintandre-rfc3921bis>. (work in progress)

3. In accordance with Section 3.2.2.1 of XML Schema Part 2: Datatypes, the allowable lexical representations for the xs:boolean datatype are the strings "0" and "false" for the concept 'false' and the strings "1" and "true" for the concept 'true'; implementations MUST support both styles of lexical representation.

4. 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 <http://www.iana.org/>.

5. 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 <http://www.xmpp.org/registrar/>.

6. XEP-0053: XMPP Registrar Function <http://www.xmpp.org/extensions/xep-0053.html>.


Revision History

Version 0.2 (2008-03-06)

Renamed to roster sequencing; clarified server behavior.

(psa)

Version 0.1 (2008-03-05)

Initial published version; per Council consensus, removed optionality regarding semantics of the version attribute.

(psa)

Version 0.0.3 (2008-03-05)

Corrected semantics of version attribute (should be a strictly increasing sequence number but may be any unique identifier).

(psa)

Version 0.0.2 (2008-03-04)

Clarified description of roster diff; added diff attribute and specified its use in roster results; specified use of version attribute in roster pushes.

(psa)

Version 0.0.1 (2008-03-04)

First draft.

(psa)

END