Skip to content

Commit 0c07bbe

Browse files
committed
Merge branch 'main' into meinte/correctness
2 parents fc06891 + 7f7332d commit 0c07bbe

File tree

5 files changed

+55
-39
lines changed

5 files changed

+55
-39
lines changed

metametamodel/metametamodel.adoc

+18-12
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ Language elements contained in a Language are allowed to refer to these other La
9898
* within declared dependencies
9999
* within _transitive_ dependencies.
100100
+
101-
Example: if Language B depends on Language A, and Language C depends on B, then Language C can also refer to members of Language A without explicitly declaring a dependency.
101+
Example: if Language _B_ depends on Language _A_, and Language _C_ depends on _B_, then Language _C_ can also refer to members of Language _A_ without explicitly declaring a dependency.
102102

103103
A Language CAN declare a transitive dependency explicitly.
104-
In the example above, Language C CAN declare an explicit dependency on Language A.
104+
In the example above, Language _C_ CAN declare an explicit dependency on Language _A_.
105105

106-
##TODO: Dependency on builtins {fn-org153}##
106+
As any Language depends (at least transitively and <<Concept.extends, implicitly>>) on <<stdlib>> elements, a Language CAN declare a dependency on builtins -- but _does not_ need to.{fn-org153}
107107

108108
[[Concept]]
109109
==== Concept
@@ -139,12 +139,22 @@ A Concept `implements` zero or more <<ConceptInterface, ConceptInterfaces>>.
139139
A Concept can have any number of <<Classifier.features, `features`>>, given it is a <<Classifier>>.
140140

141141
.Constraints
142-
TBD
142+
A Concept MUST NOT extend itself, or form circles via `extends`.
143143

144144
[[Annotation]]
145145
==== Annotation
146-
An Annotation is a limited[*] additional, orthogonal information attached to potentially any node, sharing the node’s lifecycle.
146+
An Annotation is an additional piece of information attached to potentially any node, sharing the node’s lifecycle.
147147
The annotated node (or its concept) does not need to know about the annotation.{fn-org13}
148+
Annotations CAN be attached to other Annotations (although this structure is hard to comprehend, and should be used with caution).
149+
150+
Annotations should only have limited content because the more complex the annotation is, the more likely it should not be part of the annotated node's lifecycle -- We might want to reuse the complex annotation somewhere else. +
151+
Example: In MPS, the editor of a concept can be seen as an annotation of that concept.
152+
But even if we deleted the concept, we might want to reuse the editor for another (similar) concept.
153+
154+
Annotations' contents should be orthogonal to the annotated node, because actual content should be part of the original concepts, and unrelated contents should be somewhere else. +
155+
Example: Let's assume our Language defines a `Date` PrimitiveType.
156+
We might annotate `Date` with `@JavaImplementation(java.util.Date)` and `@TypeScriptImplementation(JsJoda.LocalDate)`.
157+
Our core model stays platform-independent, but we maintain the implementation details at the right place -- if we ever deleted `Date`, all related information would be gone without further cleanup.
148158

149159
.Example
150160
We design a fancy documentation language, and can annotate any other node with such documentation.
@@ -166,13 +176,13 @@ An Annotation is a <<Classifier>>, and indirectly a <<LanguageEntity>> (as it is
166176
Each Annotation specifies which <<Classifier, `Classifiers`>> it `annotates`.
167177
If it should be applicable to any node, it annotates <<Node>>.
168178

169-
As Annotations can specify which Concept or Annotation it [[Annotation.extends, Annotation.extends]]`extends` and which interfaces it [[Annotation.implements, Annotation.implements]] `implements`.
170-
An Annotation can have any number of <<Classifier.features, `features`>>, given it is a <<Classifier>>.
179+
Annotations can specify which Annotation it [[Annotation.extends, Annotation.extends]]`extends` and which interfaces it [[Annotation.implements, Annotation.implements]] `implements`.
180+
An Annotation CAN have any number of <<Classifier.features, `features`>>, given it is a <<Classifier>>.
171181

172182
.Constraints
173183
We CANNOT redefine `multiple` and `annotates` in a sub-annotation (i.e. an annotation that `extends` another).{fn-org154}
174184

175-
We can attach an instance of an Annotation only to instances of the Concept the Annotation `annotates` (and sub-concepts thereof).
185+
We MUST attach an instance of an Annotation only to instances of the Concept the Annotation `annotates` (and sub-concepts thereof).
176186

177187
.Annotation examples
178188
--
@@ -293,10 +303,6 @@ CompanyAddress <-[#red]- CompanyRole
293303
----
294304
--
295305

296-
.Remarks
297-
[*] "limited" because the more complex the annotation is, the more likely it should not be part of the annotated node's lifecycle -- We might want to reuse the complex annotation somewhere else.
298-
Example: In MPS, the editor of a concept can be seen as an annotation of that concept. But even if we deleted the concept, we might want to reuse the editor for another (similar) concept.
299-
300306
[[ConceptInterface]]
301307
==== ConceptInterface
302308
A ConceptInterface represents a category of entities sharing some similar characteristics.

serialization/serialization.adoc

+29-19
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
include::../shared/issue-footnotes.adoc[]
22

33
:m3: ../metametamodel/metametamodel
4+
:refarch: ../reference-architecture/reference-architecture
45
:fn-mof: footnote:mof[https://en.wikipedia.org/wiki/Meta-Object_Facility[Meta-Object Facility], also known as M3 model]
56

67
= LIonWeb Serialization Format
8+
:toc: preamble
9+
:toclevels: 3
10+
11+
This document describes the serialization format for LIonWeb chunks.
712

813
== Conventions used in this document
914
* _italic_ words refer to concepts defined by JSON.
@@ -17,6 +22,9 @@ We do not take any measures to reduce the amount of transmitted data.{fn-org73}
1722
== Description
1823
LIonWeb node serialization format is defined in JSON (https://datatracker.ietf.org/doc/html/rfc8259[RFC 8259]).
1924

25+
We follow the advice of RFC 8259 to be "interoperable", i.e. we assume object keys are unique, and their order is undefined.
26+
Any violations SHOULD be reported as error.{fn-org159}
27+
2028
== Overview of structures
2129

2230
plantuml::serialization.puml[format=svg]
@@ -29,18 +37,18 @@ Root level MUST be an _object_ with three members, called *serialization chunk*.
2937
##TODO: Are more members allowed?{fn-org67}##
3038

3139
[[SerializationChunk.serializationFormatVersion]]
32-
The first member MUST be _key_ `serializationFormatVersion` with a _string_ _value_.{fn-org58}
40+
The first member SHOULD be _key_ `serializationFormatVersion` with a _string_ _value_.{fn-org58}{fn-org159}
3341
The value MUST be a decimal integer (without leading or trailing whitespace) describing the serialization format version used to create the processed document, according to <<versions>>.
3442

3543
[[SerializationChunk.languages]]
36-
The second member MUST be _key_ `languages` with an _array_ _value_.{fn-org76}{fn-org78}
44+
The second member SHOULD be _key_ `languages` with an _array_ _value_.{fn-org76}{fn-org78}{fn-org159}
3745
Each _element_ in the value array MUST adhere to <<language>>.
3846
The order of _elements_ is undefined.
3947
_elements_ MUST contain all language/version referred to by any <<meta-pointer>> in the processed document.
4048
Each _element_ must be unique with respect to all its _members_.
4149

4250
[[SerializationChunk.nodes]]
43-
The third member MUST be _key_ `nodes` with an _array_ _value_.{fn-org33}
51+
The third member SHOULD be _key_ `nodes` with an _array_ _value_.{fn-org33}{fn-org159}
4452
Each _element_ in the value array MUST adhere to <<node>>.
4553
The order of _elements_ is undefined.
4654
Each _element_ must be unique with respect to the value of its _key_ `id`.
@@ -49,9 +57,11 @@ Each _element_ must be unique with respect to the value of its _key_ `id`.
4957
=== Language structure
5058
[[UsedLanguage]]
5159
Each *used language* MUST be an _object_.{fn-org129}
52-
##TODO: include builtins in used language? {fn-org153}##
5360
The order of _members_ is undefined.
5461

62+
NOTE: If the chunk describes a language (M2), it might include instances of builtins' language entities.
63+
In this case, builtins MUST be listed as *used language* like any other language.{fn-org153}
64+
5565
The _object_ MUST contain the following _members_:{fn-org76}
5666

5767
* [[UsedLanguage.key]] _key_ `key` with _string_ _value_, adhering to <<language-key>>.
@@ -96,13 +106,13 @@ The _object_ MUST contain the following _members_:{fn-org59}{fn-java33}{fn-org55
96106
* [[Node.concept]] _key_ `concept`{fn-org37-name} with _object_ _value_, adhering to <<meta-pointer>>.
97107
The *meta-pointer*'s ``key``'s _value_ refers to the <<{m3}.adoc#IKeyed.key, *key*>> of the <<{m3}.adoc#Concept, *Concept*>> this *node* is an instance of.
98108
* [[Node.properties]] _key_ `properties` with _array_ _value_, each _element_ adhering to <<property>>.
99-
The order of _elements_ is undefined.
109+
The order of _elements_ is undefined.{fn-org156}
100110
* [[Node.children]] _key_ `children`{fn-org55-name-children} with _array_ _value_, each _element_ adhering to <<child>>.
101-
The order of _elements_ is undefined.
111+
The order of _elements_ is undefined.{fn-org156}
102112
* [[Node.references]] _key_ `references`{fn-org55-name-references} with _array_ _value_, each _element_ adhering to <<reference>>.
103-
The order of _elements_ is undefined.
113+
The order of _elements_ is undefined.{fn-org156}
104114
* [[Node.annotations]] _key_ `annotations`{fn-org150} with _array_ _value_, each _element_ adhering to <<annotation>>.
105-
The order of _elements_ is undefined.
115+
The order of _elements_ MUST be maintained as set by <<{refarch}.adoc#client, model client>>.{fn-org157}
106116
* [[Node.parent]] _key_ `parent` with _string_ or _null_ _value_, adhering to <<parent>>.
107117

108118
##TODO: How to store invalid text?{fn-org62}##
@@ -143,7 +153,7 @@ The _object_ MUST contain the following _members_:
143153
The *meta-pointer*'s ``key``'s _value_ refers to the <<{m3}.adoc#IKeyed.key, *key*>> of the <<{m3}.adoc#Containment, *Containment*>> this *child* is an instance of.
144154
* [[Child.children]] _key_ `children` with _array_ _value_ with _string_ _elements_.
145155
Each _element_ adheres to <<{m3}.adoc#identifiers, Identifier spec>>, and refers to the *id* of the contained *node*.
146-
The order of _elements_ is undefined.
156+
The order of _elements_ MUST be maintained as set by <<{refarch}.adoc#client, model client>>.{fn-org157}
147157
+
148158
NOTE: Each *child* element is the inverse relation of a *parent*.
149159
+
@@ -159,7 +169,8 @@ The _object_ MUST contain the following _members_:
159169

160170
* [[Reference.reference]] _key_ `reference` with _object_ _value_, adhering to <<meta-pointer>>.
161171
The *meta-pointer*'s ``key``'s _value_ refers to the <<{m3}.adoc#IKeyed.key, *key*>> of the <<{m3}.adoc#Reference, *Reference*>> this *reference* is an instance of.
162-
* [[Reference.targets]] _key_ `targets` with __object_ _elements_.
172+
* [[Reference.targets]] _key_ `targets` with _array_ _value_ with __object_ _elements_.
173+
The order of _elements_ MUST be maintained as set by <<{refarch}.adoc#client, model client>>.{fn-org157}
163174
Each _element_ MUST have the following _members_ in undefined order:{fn-org55-name-references}
164175
** [[Reference.reference.resolveInfo]] _key_ `resolveInfo`{fn-org36} with _value_ as one of:
165176
*** _string_ containing *resolveInfo*, a textual hint that might be used to find the target *node* of this reference.
@@ -178,17 +189,11 @@ NOTE: The referred *node* CAN be contained in the processed document, but also C
178189
[[annotation]]
179190
==== Annotation
180191
[[Annotation]]
181-
Each *annotation* MUST be an _object_.
182-
The order of _members_ is undefined.
183-
184-
The _object_ MUST contain the following _members_:
192+
Each *annotation* MUST be a _string_.
193+
It adheres to <<{m3}.adoc#identifiers, Identifier spec>>, and refers to the *id* of the contained annotation *node*.
185194

186-
* [[Annotation.annotations]] _key_ `annotations` with _array_ _value_ with _string_ _elements_.
187-
Each _element_ adheres to <<{m3}.adoc#identifiers, Identifier spec>>, and refers to the *id* of the contained *node*.
188-
The order of _elements_ is undefined.
189-
+
190195
NOTE: Each *annotation* element is the inverse relation of a *parent*.
191-
+
196+
192197
NOTE: The annotation *node* CAN be contained in the processed document, but also CAN be outside the processed document (i.e. not contained in the processed document).
193198

194199
[[parent]]
@@ -211,6 +216,7 @@ NOTE: The referred *node* CAN be contained in the processed document, but also C
211216
All property values MUST be serialized as JSON _string_.{fn-org34}{fn-org9}.
212217
An unset property CAN be serialized as JSON _null_.
213218

219+
[[string]]
214220
==== String
215221
<<{m3}.adoc#String, LIonCore Strings>> might be any string, of any length, including (but not limited to):
216222

@@ -220,6 +226,7 @@ An unset property CAN be serialized as JSON _null_.
220226
* containing extended Unicode characters: `"😐"`
221227
* containing escaped Unicode characters: `"\uD83D\uDE10"`
222228

229+
[[boolean]]
223230
==== Boolean
224231
<<{m3}.adoc#Boolean, LIonCore Booleans>> MUST be encoded as exactly one of these JSON _strings_:
225232

@@ -228,6 +235,7 @@ An unset property CAN be serialized as JSON _null_.
228235

229236
Booleans MUST NOT be encoded with leading or trailing whitespace, uppercase characters, short forms (like `t` or `f`), or decimal representation (like `1`, `0`, `-1`).
230237

238+
[[integer]]
231239
==== Integer
232240
<<{m3}.adoc#Integer, LIonCore Integers>> MUST be encoded as JSON _string_.
233241

@@ -262,6 +270,7 @@ Booleans MUST NOT be encoded with leading or trailing whitespace, uppercase char
262270
* `" 5"`
263271
* `"-6 "`
264272

273+
[[json]]
265274
==== JSON
266275
<<{m3}.adoc#JSON, LIonCore JSON>> MUST be encoded as JSON _string_.
267276
All double quotes, line breaks, etc. MUST be escaped to form a proper JSON _string_.
@@ -273,6 +282,7 @@ The value MUST adhere to JSON spec (RFC 8259).
273282
.Invalid example
274283
`{ "key": "my value", "myArray": [1, -2, true] }`
275284

285+
[[literal]]
276286
==== Enumeration literals
277287
<<{m3}.adoc#EnumerationLiteral, LIonCore Enumeration literals>> MUST be encoded as JSON _string_ _value_ according to <<{m3}.adoc#keys, Key spec>>.
278288
MUST refer to the <<{m3}.adoc#IKeyed.key, key>> of an <<{m3}.adoc#EnumerationLiteral, EnumerationLiteral>> of the <<{m3}.adoc#Enumeration, Enumeration>> defined as <<{m3}.adoc#Property.type, type>> of this *Property*.{fn-org128}

serialization/serialization.puml

+3-7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SerializationChunk *--> "0..*" Node: nodes
1919
class Node {
2020
id: Id
2121
parent: Id
22+
annotations: Id[] <<ordered>>
2223
}
2324

2425
Node *--> "1" MetaPointer: concept
@@ -31,7 +32,7 @@ class MetaPointer {
3132

3233
Node *--> "0..*" Child: children
3334
class Child {
34-
children: String[]
35+
children: Id[] <<ordered>>
3536
}
3637
Child *--> "1" MetaPointer: containment
3738

@@ -45,15 +46,10 @@ Property *--> "1" MetaPointer: property
4546
Node *--> "0..*" Reference: references
4647
class Reference
4748
Reference *--> "1" MetaPointer: reference
48-
Reference *--> "0..*" ReferenceTarget: targets
49+
Reference *--> "0..*" ReferenceTarget: <<ordered>>\ntargets
4950
class ReferenceTarget {
5051
reference: Id
5152
resolveInfo: String
5253
}
5354

54-
Node *--> "0..*" Annotation: annotations
55-
class Annotation {
56-
annotations: String[]
57-
}
58-
5955
@enduml

serialization/serialization.schema.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@
177177
"additionalProperties": false,
178178
"minProperties": 7,
179179
"maxProperties": 7
180-
}
180+
},
181+
"uniqueItems": true
181182
}
182183
},
183184
"required": [

shared/issue-footnotes.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,6 @@
145145
:fn-org150: footnote:org150[https://github.com/LIonWeb-org/organization/issues/150[How to represent annotations in serialization #150]]
146146
:fn-org153: footnote:org153[https://github.com/LIonWeb-org/organization/issues/153[Details on builtin language #153]]
147147
:fn-org154: footnote:org154[https://github.com/LIonWeb-org/organization/issues/154[Details on Annotations #154]]
148+
:fn-org156: footnote:org156[https://github.com/LIonWeb-org/organization/issues/156[Keep serialization order between different features? #156]]
149+
:fn-org157: footnote:org157[https://github.com/LIonWeb-org/organization/issues/157[Maintain order in serialization of each containment / reference / annotation #157]]
150+
:fn-org159: footnote:org159[https://github.com/LIonWeb-org/organization/issues/159[Don't rely on valid, but ambiguous JSON structures #159]]

0 commit comments

Comments
 (0)