├── meeting-notes-2020-11-05.txt ├── README.md └── LICENSES └── CC-BY-4.0.txt /meeting-notes-2020-11-05.txt: -------------------------------------------------------------------------------- 1 | 6 | 7 | Link to Henry's notes: https://hackmd.io/I6OWJw-4SWSZCQ4kmd_MYw 8 | 9 | Better name for proof would be claim. It is not a proof in the sense 10 | that it could be false. 11 | 12 | You still need a protocol to define what you are talking 13 | about. Meaning defining the subset. Which would be RPC based. 14 | 15 | The result would then be shared as a feed. 16 | 17 | Discoverability: cft raised the point of discoverability of these 18 | feeds (results), as they could potentially be reused. Imagine someone 19 | writes a subfeed consisting of their contact messages, then this would 20 | be useful for all peers wanting to do partial replication. 21 | 22 | A point was raised about reduced state. It would be possible for the 23 | subfeed to be a reduced state instead of just the linear messages. 24 | 25 | Subfeeds could be used to rewrite a feed or run a parallel feed on a 26 | different feed format. 27 | 28 | Feed writers (for the result) come in different levels of trust: 29 | - original author 30 | - writer with a certain hops count of you (more likely with rooms) 31 | - stranger 32 | 33 | Depending on the level of trust it would be valuable to add claims 34 | about the defined subset. We briefly touched on the posibility of 35 | includes a hops metric or something similar to limit the claims you 36 | would receive. 37 | 38 | We talked about if one should just link to the messages of the 39 | original feed, or if one should write messages (or links) using the 40 | feed writers key. 41 | 42 | Most of the above related to single feeds. We also talked about 43 | multiple feeds such as tangles where it is not so easy to define a 44 | linearity. Imagine a case where you already got 10 messages related to 45 | some root messages and now you connect to a complely different 46 | peer. We briefly discussed set replication or sending differences by 47 | including more information in the "query". Another option would be to 48 | not have a single feed as the result but multiple feed, one for each 49 | author. 50 | 51 | Coming back to discoverability we talked about having a meta feed. 52 | 53 | Lastly the lifetime of feeds. Currently there is no concept of 54 | lifetime and it might make sense to make that more explicit. This 55 | would also open the door to ephemeral feeds. 56 | 57 | A lot of this is optimization, one could always fall back to full 58 | replication. But not only optimization. 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Subset replication for SSB 8 | 9 | Status: Design phase 10 | 11 | This module aims to provide methods for synchronizing a subset of one 12 | or more SSB feeds. The main motivation is to enable faster initial 13 | sync by only replicating a certain subset of messages that can then be 14 | supplimented with a frontier sync such as [EBT]. 15 | 16 | Feeds in classical SSB can said to contain multiple subset of 17 | messages, this could be messages of a certain type (eg. contact or 18 | chess moves) or could be private messages pertaining to a [private 19 | group]. 20 | 21 | In classical SSB, feeds up to a hops count (normally 2 or 3) are 22 | replicated in full. There also exists a method to get a particular 23 | message out of order, the security of this hinges on the fact that you 24 | get the ooo message by the hash and so is a special case of engtangled 25 | messages. 26 | 27 | Here we are interested in adding APIs that, given [ssb-meta-feed], 28 | allows two peers to exchange feeds and subset of feeds to allow for 29 | partial replication. 30 | 31 | We are mainly interested in two classes of messages: a subset of 32 | messages of a classical SSB feed and a tangle of messages given a 33 | common root message. 34 | 35 | ## getSubset(query, options): source 36 | 37 | This method can be seen as a more general version of 38 | createHistoryStream where the id, or what you are interesting in, 39 | first needs to be defined. Query specifies what data you are 40 | interested in. 41 | 42 | The query parameter is an instance of the query language defined 43 | in `options.querylang`. 44 | 45 | To support pagination, `startFrom`, `pageSize` and `descending` can be 46 | specified in the options parameter. 47 | 48 | It is up to the receiving end of the query to determine if the query 49 | results in too much load. This could be if someone tries to get data 50 | for a large number of feeds without proper pagination, or if the query 51 | includes arguments in a form that strains the query planner. 52 | 53 | To get the latest 10 public post messages of a particular feed the 54 | following `query` and `options` arguments can be used: 55 | 56 | ```json 57 | { 58 | "author": "@6CAxOI3f+LUOVrbAl0IemqiS7ATpQvr9Mdw9LC4+Uv0=.ed25519", 59 | "type": "post", 60 | "private": false 61 | } 62 | ``` 63 | 64 | ``` 65 | { 66 | "querylang": "ssb-ql-0", 67 | "descending": true, 68 | "pageSize": 10 69 | } 70 | ``` 71 | 72 | Result: 73 | 74 | ``` 75 | [msg1, msg2, ..., msg10] 76 | ``` 77 | 78 | ### Query language 79 | 80 | #### ssb-ql-0 81 | 82 | We start by supporting a proof-of-concept query language called 83 | "ssb-ql-0" which is a precursor for the more powerful "ssb-ql-1" 84 | (see below). 85 | 86 | Queries in ssb-ql-0 are merely JSON objects with three *required* 87 | fields: 88 | 89 | - `author`: a valid feed ID as a string 90 | - `type`: a message type, can be any non-empty string, or null, 91 | which signals that messages of any type are accepted 92 | - `private`: a boolean 93 | 94 | If `private: true` then `type` **MUST** be `null`. This is to prevent 95 | leaking metadata about private messages to the public. 96 | 97 | #### ssb-ql-1 98 | 99 | *Status: under design. We recommend using ssb-ql-0 in the meantime. 100 | ssb-ql-1 has challenges such as determining when two queries are 101 | equivalent, which may be an NP complete problem. Read more on this 102 | SSB thread:* `%FjK8SdR2Q8n3XBwFKiI8ebdSr/Tp7bMzhr2R6YMq+b0=.sha256` 103 | 104 | Here we define a mini query language that can be used to specify a 105 | subset of data. The goal of this format is to be easy to parse and 106 | also be restrictive in the number of operations supported to make it 107 | easier to map to indexes and to limit the attack surface. 108 | 109 | The query uses an object notation for operators that looks very 110 | similar to JSON. The objects contains two keys: `op` the name of the 111 | operation and a second parameter for the arguments given the 112 | operation. 113 | 114 | Base operators: 115 | 116 | op | args name | args type 117 | ------ | --------- | --------- 118 | and | args | [op, ...] 119 | or | args | [op, ...] 120 | type | string | string 121 | author | feed | string 122 | 123 | Note that `ssb-ql-1` is only for public messages and is incapable of 124 | querying private messages, unlike `ssb-ql-0`. 125 | 126 | The spec is open for implementations to add new operators relatively 127 | easy. This allows experimentation and implementations should simply 128 | error if presented with an unsupported operator. A new potential 129 | operator could be `isPrivate` or `isBox2` but extreme care must be 130 | taken not to leak information using these queries around private 131 | information. 132 | 133 | ## getTangle (TBD) 134 | 135 | Tangles in SSB behave differently than other types of messages in 136 | that they are linked together across multiple feeds using links. This 137 | allows for a different kind of synchonization than `getSubset`. There 138 | are two common examples of where this could be useful: for getting all 139 | the messages of an old message threads that is outside the frontier of 140 | messages and to synchronize a private group (as all messages in those 141 | are part of a single tangle). While private groups are by definition 142 | private to external observers, the fact that nodes connecting in SSB 143 | are authenticated by their ID and that rooms allow direct connections 144 | between peer allows synchronization of a private group directly with 145 | another group member who also knows which messages belong to the group. 146 | 147 | As private groups can grow quite large it becomes important that there 148 | is a way to synchronize only subsets but also changes or the latest 149 | part of a tangle. The membership part of a private group has a tangle 150 | root and thus can be replicated on its own. 151 | 152 | Consider using [set-reconciliation] for this. 153 | 154 | # Prior work 155 | 156 | Earlier threads on SSB discussing partial replication: 157 | 158 | - %L9m5nHRqpXM4Zkha1ENTk5wNOXQMduve8Hc9+F0RLZI=.sha256 159 | - %VNCOf3pfP7hjL3lcFvBSSOzRPtR0WHDtvlXvkBcha3I=.sha256 160 | - %gaYxXAEoSKf3dnw2OlI2EuoduFmkiU4kU+CncbBImPk=.sha256 161 | - %jM6Dw0BEg9IPVkDH5VaoiVSbt3gCnUfSoO1BhX2Ntpw=.sha256 162 | - %SEXkvEQCJd2jBrUXDQcFPVix/5eUffoKBURWyy5yYrU=.sha256 163 | 164 | [JITDB]: https://github.com/arj03/jitdb 165 | [ssb-meta-feed]: https://github.com/arj03/ssb-meta-feed 166 | [set-reconciliation]: https://github.com/AljoschaMeyer/set-reconciliation 167 | [EBT]: https://github.com/ssbc/epidemic-broadcast-trees/ 168 | [private group]: https://github.com/ssbc/private-group-spec 169 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-4.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 4.0 International 2 | 3 | Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 4 | 5 | Using Creative Commons Public Licenses 6 | 7 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 8 | 9 | Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. 10 | 11 | Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. 12 | 13 | Creative Commons Attribution 4.0 International Public License 14 | 15 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 16 | 17 | Section 1 – Definitions. 18 | 19 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 20 | 21 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 22 | 23 | c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 24 | 25 | d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 26 | 27 | e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 28 | 29 | f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 30 | 31 | g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 32 | 33 | h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 34 | 35 | i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 36 | 37 | j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 38 | 39 | k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 40 | 41 | Section 2 – Scope. 42 | 43 | a. License grant. 44 | 45 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 46 | 47 | A. reproduce and Share the Licensed Material, in whole or in part; and 48 | 49 | B. produce, reproduce, and Share Adapted Material. 50 | 51 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 52 | 53 | 3. Term. The term of this Public License is specified in Section 6(a). 54 | 55 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 56 | 57 | 5. Downstream recipients. 58 | 59 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 60 | 61 | B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 62 | 63 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 64 | 65 | b. Other rights. 66 | 67 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 68 | 69 | 2. Patent and trademark rights are not licensed under this Public License. 70 | 71 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. 72 | 73 | Section 3 – License Conditions. 74 | 75 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 76 | 77 | a. Attribution. 78 | 79 | 1. If You Share the Licensed Material (including in modified form), You must: 80 | 81 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 82 | 83 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 84 | 85 | ii. a copyright notice; 86 | 87 | iii. a notice that refers to this Public License; 88 | 89 | iv. a notice that refers to the disclaimer of warranties; 90 | 91 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 92 | 93 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 94 | 95 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 96 | 97 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 98 | 99 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 100 | 101 | 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. 102 | 103 | Section 4 – Sui Generis Database Rights. 104 | 105 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 106 | 107 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; 108 | 109 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 110 | 111 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 112 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 113 | 114 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 115 | 116 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 117 | 118 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 119 | 120 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 121 | 122 | Section 6 – Term and Termination. 123 | 124 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 125 | 126 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 127 | 128 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 129 | 130 | 2. upon express reinstatement by the Licensor. 131 | 132 | c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 133 | 134 | d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 135 | 136 | e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 137 | 138 | Section 7 – Other Terms and Conditions. 139 | 140 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 141 | 142 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 143 | 144 | Section 8 – Interpretation. 145 | 146 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 147 | 148 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 149 | 150 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 151 | 152 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 153 | 154 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 155 | 156 | Creative Commons may be contacted at creativecommons.org. 157 | --------------------------------------------------------------------------------