Skip to content

Schema JSON for Delta Structures #338

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

Merged
merged 13 commits into from
Apr 5, 2025

Conversation

pjmolina
Copy link

@pjmolina pjmolina commented Mar 7, 2025

Schema JSON for Delta Structures

This PR provides:

  1. An Essential format representation for Delta Protocol Structures delta-protocol.ess. This file was created manually converting from the C# implementation.
  2. A JSON Schema serialization from (1) derived automatically by Essential applying a transformation. derived/delta.json.schema It can used for OpenAPI specs, f.e.

Validation

Sample online validator for JSON Schema: https://json-schema.hyperjump.io/

Discussion

Translation considerations from C# to Essential:

  1. The tranlation removed some type aliases to types used in C# and interfaces.
  2. The inheritance structure is still preserved in this version.

Design considerations

  1. Inheritance and interfaces are convenient on C# but not really needed on JSON. We should consider pros & cons about preserving it or flattening the inheritance to simple structures.
  2. Non public types and intermediate types & abstractions can be avoided from the final JSON Schema to make it as simple as possible.
  3. There are many concepts with some kind of variant permutations. Any simplification we can come up will definelty increase adoption chances.

@pjmolina pjmolina requested review from dslmeinte and enikao March 7, 2025 15:06
@pjmolina pjmolina self-assigned this Mar 7, 2025
@pjmolina pjmolina added the delta label Mar 7, 2025
@enikao
Copy link
Contributor

enikao commented Mar 7, 2025

Shall we have abstract base types?

Shall we group our messages through types like IDeltaContent, IDeltaQuery, INodeCommand etc?

Pro:

  • Useful for processing them, probably in most host languages
  • Shows the semantic structure of our messages
  • We do need some of them (e.g. ISingleDeltaCommand as type to use inside CompositeCommand)

Con:

  • Not strictly needed
  • Blows up already big spec
  • It's easier to add more interfaces in an implementation than to remove them

Decision: We won't have abstract base types if not absolutely needed

#346

@enikao
Copy link
Contributor

enikao commented Mar 7, 2025

Shall we have convenience types?

Some classes like DeltaProperty or DeltaContainment are only in because the combination of (in case of DeltaProperty) string Parent + MetaPointer Property appears in lots of places. Do we want them in the schema?

NOTE: Some other types like SerializedNode or MetaPointer also appear at different places, but we do need them -- they represent first-class concepts.

Pro:

  • Useful for processing them, at least in C#
  • Schema becomes less verbose

Con:

  • Schema becomes more complicated
  • Flat structures map more directly to the spec
  • Easier to change if we have to fix only one usage
  • Binary formats (e.g. protobuf) deal better with flat structures

Decision: Flatten types, don't use convenience structures

#347

@enikao
Copy link
Contributor

enikao commented Mar 7, 2025

Please feel free to edit my comments above to add more pros/cons.

@@ -0,0 +1,842 @@
namespace Lion.WebCore.Serialization
Copy link
Contributor

@enikao enikao Mar 7, 2025

Choose a reason for hiding this comment

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

As discussed with Pedro, we don't want to merge this file in the end. It's just more convenient to discuss the structures in this format than raw JSONSchema.

the inheritance to simple structures.
2. Non public types and intermediate types & abstractions can be avoided
from the final JSON Schema to make it as simple as possible.
3. There are many concepts with some kind of variant permutations.
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree: some kind of usage of traits/mixins might be useful to cut down on the apparent complexity due to the sheer number of variations.

@pjmolina pjmolina requested review from dslmeinte and enikao March 10, 2025 10:53
from the final JSON Schema to make it as simple as possible.
3. There are many concepts with some kind of variant permutations.
Any simplification we can come up will definelty increase adoption chances.
Any simplification we can come up will definetly increase adoption chances.
Copy link
Contributor

Choose a reason for hiding this comment

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

It’s definitely “definitely” ;)

Copy link
Author

Choose a reason for hiding this comment

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

oh my good. Fixing! ;-)

@@ -20,6 +20,13 @@ namespace Lion.WebCore.Serialization
}
class SerializedNode
{
string Id;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn’t it be useful to have a type alias Id?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there are type aliases in JsonSchema

Copy link
Contributor

Choose a reason for hiding this comment

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

But this is (C#-like) Essential code.

Copy link
Contributor

Choose a reason for hiding this comment

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

... which will never be merged, as per #338 (comment)

"required": []
"properties": {
"Id": {
"type": "string"
Copy link
Contributor

@dslmeinte dslmeinte Mar 10, 2025

Choose a reason for hiding this comment

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

Wouldn’t it be useful to have an explicit type Id? btw: We have a JSON Schema for the serialization format: https://github.com/LionWeb-io/specification/blob/main/2023.1/serialization/serialization.schema.json

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that this would be useful, "type": LionWebId" is more informative.

@enikao
Copy link
Contributor

enikao commented Mar 10, 2025

I would like to mainly discuss structure here, not human language style

@enikao
Copy link
Contributor

enikao commented Apr 3, 2025

@joswarmer
Copy link
Contributor

The DeltaSerializationChunk only has nodes. Shouldn't this be the SerializationChunk as we defined in the bulk protocol, including SerializationVersion, used languages etc. ?

@enikao
Copy link
Contributor

enikao commented Apr 4, 2025

The DeltaSerializationChunk only has nodes. Shouldn't this be the SerializationChunk as we defined in the bulk protocol, including SerializationVersion, used languages etc. ?

In the most recent version, I changed that to be just the array of nodes.
I think the LW version should be part of login, we won't change it during one participation -- so we don't need to re-transmit every time.
The list of languages was always redundant, and I don't see much value for it in delta.

That's my reasoning, but I don't have a very strong opinion on it. Mentioning the LW version opens another option for inconsistency, but I could live with it.

@enikao
Copy link
Contributor

enikao commented Apr 5, 2025

I merge this with #288, as they develop together

@enikao enikao merged commit 323b6e5 into niko/delta-api-spec Apr 5, 2025
@enikao
Copy link
Contributor

enikao commented Apr 5, 2025

The DeltaSerializationChunk only has nodes. Shouldn't this be the SerializationChunk as we defined in the bulk protocol, including SerializationVersion, used languages etc. ?

I put this into #358

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

Successfully merging this pull request may close these issues.

4 participants