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

Adapt schemas to epochs and member exclusion #30

merged 21 commits into from
Apr 4, 2023

Conversation

Powersource
Copy link
Collaborator

@Powersource Powersource commented Mar 20, 2023

For ssbc/ssb-tribes2#73 and ssbc/ssb-tribes2#68

  • Test exclude schema
  • Fix array schemas
  • Make sure definitions are imported always
  • Allow recps in init
  • Update readmes
  • split init schemas
  • update tests
  • update/create readmes

@Powersource
Copy link
Collaborator Author

Just ran into this

the fuck. so this apparently doesn't seem to work (we use it in some schema)

recps: {
  type: 'array',
  item: { $ref: '#/definitions/groupId' },
  minItems: 1,
  maxItems: 1
},

but this seems to work (which we also use in some places

recps: {
  type: 'array',
  items: [{ $ref: '#/definitions/groupId' }],
  minItems: 1,
  maxItems: 1
},

@Powersource Powersource marked this pull request as ready for review March 21, 2023 13:55
@Powersource Powersource requested review from mixmix, arj03 and staltz March 21, 2023 13:55
@Powersource Powersource marked this pull request as draft March 21, 2023 14:16
@Powersource Powersource marked this pull request as ready for review March 21, 2023 15:15
Copy link
Member

@staltz staltz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smells fine by me, but I'm not the JSON schema person

group/exclude/schema.js Outdated Show resolved Hide resolved
group/init/README.md Outdated Show resolved Hide resolved

Note the differences between the root 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. In this example this is the first new epoch so the `previous` is the group root msg.
Copy link
Member

@mixmix mixmix Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The epoch tangle is not null and points at the root msg as well as the init for the last epoch. In this example this is the first new epoch so the `previous` is the group root msg.
* The epoch tangle is not null and points at the root msg as well as the init for the last epoch. In this example this is the first new epoch so the `previous` is just `[groupRoot]`.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just removed this sentence instead (was clarified in the code example anyway)

properties: {
group: { $ref: '#/definitions/tangle/root' },
group: { $ref: '#/definitions/tangle/any' },
Copy link
Member

@mixmix mixmix Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 I feel like this is generalising in a way which is not helpful/ safe. I suggest we split out:

  • group/init-root
  • group/init-epoch

or something, because otherwise validators built on this will let you make an incorrect group root message with no errors raised

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both can still have the same type (and should) but lets find some way to distinguish

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split them out into initRoot and initEpoch now

group/init/v2/schema.js Outdated Show resolved Hide resolved
test/exclude.test.js Outdated Show resolved Hide resolved
wrongPrev.tangles.group.previous = ['%yip', '%yap']
t.false(isValid(wrongPrev), 'fails if wrong tangle.previous')
wrongPrev.tangles.members.previous = ['%yip', '%yap']
t.false(isValid(wrongPrev), 'fails if wrong members.previous')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were these the tests failing with the schema item/items definition as it was?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuh idk, all tests were passing i think

Copy link
Member

@mixmix mixmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main request is that we seperate group/init and group/init (epoch) or whatever we call the two.

@Powersource Powersource marked this pull request as draft March 30, 2023 16:58
@Powersource Powersource marked this pull request as ready for review March 30, 2023 18:31
@Powersource Powersource requested a review from mixmix March 30, 2023 18:31
}
},
validator: {
group: {
init: Validator(groupInitSchema),
initRoot: Validator(groupInitRootSchema),
Copy link
Member

@mixmix mixmix Apr 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 this is a breaking change (the API is different). I think if we've not published this v2 init then it's fine, but otherwise we need to make this a major version change... or provide an init which is the same as initRoot ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah none of the new group/tribes2 stuff has been in production yet so this repo is still essentially "groups 2.0-release candidate. when it is in production we'll have to move it to the sip repo to freeze it

@Powersource Powersource merged commit 9227f7d into master Apr 4, 2023
@Powersource Powersource deleted the epochs branch April 4, 2023 13:37
@Powersource
Copy link
Collaborator Author

published v6 now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants