Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt schemas to epochs and member exclusion #30

Merged
merged 21 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ More detail:

A minimal amount of agreement to make coordination easier:

- [creating a new group](./group/init/README.md)
- [creating a new group](./group/initRoot/README.md)
- [creating a new epoch](./group/initEpoch/README.md)
- [adding someone to your group](./group/add-member/README.md)
- [posting a message to a group](./group/content/README.md)
- [excluding someone from a group](./group/exclude/README.md)

---

Expand Down
8 changes: 7 additions & 1 deletion generate-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
const { join } = require('path')
const fs = require('fs')

const types = ['group/init/v2', 'group/add-member/v2', 'group/content']
const types = [
'group/initRoot/v2',
'group/initEpoch/v2',
'group/add-member/v2',
'group/content',
'group/exclude'
]

module.exports = types

Expand Down
4 changes: 1 addition & 3 deletions group/add-member/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ Notes:
- provides partial ordering for all activity in the group
- all `group/add-member` type messages are part of the membership tangle (see `tangles.members`)
- this makes it easy to build a history of additions to the group
- the `tangles.group.root` and `tangles.members.root` are the same
- this isn't true of all tangles
- it's the same because it's a sub-tangle directly related to group initialisation
- `tangles.members.root` points at the root message of the current epoch you're in. The "list" of members is essentially reset on each new epoch, which is why the members tangle `root` and `previous` are set to null in all group/epoch init messages.
- all tangles info is "uncloaked" in this version of the spec
- i.e. sharing this message content leaks info about what other messages/ authors are in the group
8 changes: 5 additions & 3 deletions group/add-member/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@
},
"previous": {
"type": "array",
"item": {
"$ref": "#/definitions/messageId"
},
"items": [
{
"$ref": "#/definitions/messageId"
}
],
"minItems": 1
}
}
Expand Down
8 changes: 5 additions & 3 deletions group/content/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@
},
"previous": {
"type": "array",
"item": {
"$ref": "#/definitions/messageId"
},
"items": [
{
"$ref": "#/definitions/messageId"
}
],
"minItems": 1
}
}
Expand Down
4 changes: 2 additions & 2 deletions group/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const tangle = {
root: { $ref: '#/definitions/messageId' },
previous: {
type: 'array',
item: { $ref: '#/definitions/messageId' },
items: [{ $ref: '#/definitions/messageId' }],
minItems: 1
}
}
Expand Down Expand Up @@ -76,7 +76,7 @@ module.exports = {
tangle: {
root: tangle.root,
update: tangle.update,
any: tangle.update
any: tangle.any
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions group/exclude/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:warning: schema.json is generated so don't modify it directly

See the [group exclusion spec](https://github.com/ssbc/ssb-group-exclusion-spec) section [4.1. Excluding a member](https://github.com/ssbc/ssb-group-exclusion-spec#41-excluding-a-member) for details on this message type.
42 changes: 42 additions & 0 deletions group/exclude/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: 2022 Mix Irving
//
// SPDX-License-Identifier: LGPL-3.0-only

const { tangle, feedId, groupId } = require('../definitions')

module.exports = {
type: 'object',
required: ['type', 'excludes', 'recps', 'tangles'],
properties: {
type: {
type: 'string',
pattern: '^group/exclude$'
},
excludes: {
type: 'array',
items: [{ $ref: '#/definitions/feedId' }],
minItems: 1
},
mixmix marked this conversation as resolved.
Show resolved Hide resolved
recps: {
type: 'array',
items: [{ $ref: '#/definitions/groupId' }],
minItems: 1,
maxItems: 1
},
tangles: {
type: 'object',
required: ['group', 'members'],
additionalProperties: false,
properties: {
group: { $ref: '#/definitions/tangle/update' },
members: { $ref: '#/definitions/tangle/update' }
}
}
},
additionalProperties: false,
definitions: {
...feedId,
...groupId,
...tangle.update
}
}
89 changes: 89 additions & 0 deletions group/exclude/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"type": "object",
"required": [
"type",
"excludes",
"recps",
"tangles"
],
"properties": {
"type": {
"type": "string",
"pattern": "^group/exclude$"
},
"excludes": {
"type": "array",
"items": [
{
"$ref": "#/definitions/feedId"
}
],
"minItems": 1
},
"recps": {
"type": "array",
"items": [
{
"$ref": "#/definitions/groupId"
}
],
"minItems": 1,
"maxItems": 1
},
"tangles": {
"type": "object",
"required": [
"group",
"members"
],
"additionalProperties": false,
"properties": {
"group": {
"$ref": "#/definitions/tangle/update"
},
"members": {
"$ref": "#/definitions/tangle/update"
}
}
}
},
"additionalProperties": false,
"definitions": {
"feedId": {
"type": "string",
"pattern": "^ssb:feed/bendybutt-v1/[a-zA-Z0-9_\\-]{42}[AEIMQUYcgkosw048]=$"
},
"groupId": {
"type": "string",
"pattern": "^ssb:identity/group/[a-zA-Z0-9_\\-]{42}[AEIMQUYcgkosw048]=$"
},
"messageId": {
"type": "string",
"$comment": "42 chars + 1 char from a limited subset (last bits are 0) + 1 =",
"pattern": "^ssb:message/classic/[a-zA-Z0-9_\\-]{42}[AEIMQUYcgkosw048]=$"
},
"tangle": {
"update": {
"type": "object",
"required": [
"root",
"previous"
],
"properties": {
"root": {
"$ref": "#/definitions/messageId"
},
"previous": {
"type": "array",
"items": [
{
"$ref": "#/definitions/messageId"
}
],
"minItems": 1
}
}
}
}
}
}
39 changes: 39 additions & 0 deletions group/initEpoch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Creating a new epoch

This is a spec for how to initialise a new epoch (after the first initial "zero" epoch a.k.a. initRoot).

:warning: schema.json is generated so don't modify it directly

## Epoch init example

```js
const groupRoot = 'ssb:message/classic/Zz-Inkte70Qz1UVKUHIhOgo16Oj_n37PfgmIzLDBgZw=.sha256'
const groupId = 'ssb:identity/group/g_JTmMEjG4JP2aQAO0LM8tIoRtNkTq07Se6h1qwnQKb='

var plainText = {
type: 'group/init'
version: 'v2',
groupKey: group_key.toString('base64'),
tangles: {
group: {
root: groupRoot,
previous: [lastMessageOnPreviousEpoch]
},
epoch: {
root: groupRoot,
previous: [lastGroupInitOnPreviousEpoch]
}
members: {
root: null,
previous: null
}
},
recps: [groupId, myRootFeedId]
}
```

Note the differences between the root init msg (the "zero epoch") and epoch init messages:
* The group tangle is not null and like normal, points at the group root and the latest messages.
* The epoch tangle is not null and points at the root msg as well as the init for the last epoch.
* The members tangle is always null in "group/init" messages, since that tangle is reset there.
* Recps is defined, and includes the group id as well as your own root feed id.
47 changes: 47 additions & 0 deletions group/initEpoch/v2/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-FileCopyrightText: 2022 Mix Irving
//
// SPDX-License-Identifier: LGPL-3.0-only

const { groupKey, tangle, groupId, feedId } = require('../../definitions')

module.exports = {
type: 'object',
required: ['type', 'version', 'groupKey', 'tangles', 'recps'],
properties: {
type: {
type: 'string',
pattern: '^group/init$'
},
version: {
type: 'string',
pattern: '^v2$'
},
groupKey: { $ref: '#/definitions/groupKey' },
tangles: {
type: 'object',
required: ['group', 'epoch', 'members'],
additionalProperties: false,
properties: {
group: { $ref: '#/definitions/tangle/update' },
epoch: { $ref: '#/definitions/tangle/update' },
members: { $ref: '#/definitions/tangle/root' }
}
},
recps: {
type: 'array',
items: [
{ $ref: '#/definitions/groupId' },
{ $ref: '#/definitions/feedId' }
],
minItems: 2,
maxItems: 2
}
},
additionalProperties: false,
definitions: {
...groupKey,
...groupId,
...feedId,
...tangle.any // this pulls in tangle.root and tangle.update
}
}
Loading