Subject: [Asdf] Extension point mechanism thoughts

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 07:51:00 -0700

If we provide a generalized schema extension mechanism, it should be easy to use it to add a generic extension that applies the dataqualities constraint, and reuse that to provide a more developer-friendly interface that doesn't require the developer to add schema extensions for the simple use case of adding custom metadata to definitions.

extensionNamespace: { ext:" https://example.com/sdfextension" }

at https://example.com/sdfextension we define a schema extension that adds the "meta" quality to commonqualities and applies the existing dataqualities constraint to items that are defined by the new extension ( here in jso language but could also be cddl ):

{
  id: https://example.com/sdfextension 
  schemaextension: ...sdfSchema/commonqualities: { additionalProperties: meta: { $ref:dataqualities } }
}

now we can use ext:meta when we want to attach custom metadata to a definition

sdfThing:

  ObjectTemplate:
    ...
    ext:meta:
      TypeID: 
        type: integer
        minimum: 0
        maximum: 65535
      InstanceID:
        type: integer
        minimum: 0
        maximum: 65535
    # resources, etc.
    sdfProperty: {}
    sdfThing: {}

  Timer:
    sdfRef: /#/sdfThing/ObjectTemplate
    ext:meta:
      TypeID: { const: 43000 }
      InstanceID: { default: 0 }
    # resources, etc.

  TimerInstance:
     sdfRef: /#/sdfThing/Timer
    ext:meta:
      InstanceID: { const: 1001 }
    # resources, etc.

---

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 08:08:43 -0700

I intended to add another entity to the schema that works in the same way as sdfData and can be applied to any definition, but is intended to provide named metadata items to any definition.

It'sr a way of adding a category as an extension, rather than a simple quality.

> On Mar 30, 2022, at 7:51 AM, Michael Koster <[email-masked]> wrote:
> 
> extensionNamespace: { ext:" https://example.com/sdfextension <https://example.com/sdfextension>" }
> 
> at https://example.com/sdfextension <https://example.com/sdfextension> we define a schema extension that adds the "meta" quality to commonqualities and applies the existing dataqualities constraint to items that are defined by the new extension ( here in jso language but could also be cddl ):
> 
should say category, not quality, and it needs to be added to thingqualities, objectqualities, proertyqualities, actionqualities, and eventqualities
> {
>   id: https://example.com/sdfextension <https://example.com/sdfextension>

---

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 08:20:03 -0700

One more point, the schema extension mechanism provides for the first stage of development for new language features to be deployed in an organized way. 

For example, ext:meta could be the larval stage of a proposal for a built-in category "sdfMeta" in a later version of SDF. 

> On Mar 30, 2022, at 8:08 AM, Michael Koster <[email-masked]> wrote:
> 
>> On Mar 30, 2022, at 7:51 AM, Michael Koster <[email-masked] <mailto:[email-masked]>> wrote:
>>

---

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 08:23:55 -0700

Is there a well defined way to merge schema fragments into a schema at schema-defined places? For JSO we could use JSON pointer (JSON path would be more robust...) and JSON merge-patch behavior; what about cddl?

> On Mar 30, 2022, at 8:20 AM, Michael Koster <[email-masked]> wrote:
> 
>> On Mar 30, 2022, at 8:08 AM, Michael Koster <[email-masked] <mailto:[email-masked]>> wrote:
>>

---

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 08:30:24 -0700

Schema extensions that merge-patch the schema could be used to do other things besides adding new terms and their definitions...

> On Mar 30, 2022, at 8:23 AM, Michael Koster <[email-masked]> wrote:
> 
>> On Mar 30, 2022, at 8:20 AM, Michael Koster <[email-masked] <mailto:[email-masked]>> wrote:
>>

---

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 08:57:36 -0700

A more comprehensive merge-patch list example for the meta extension would be:

[
  "#/definitions/thingqualities/properties/meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" },
  "#/definitions/objectqualities/properties/meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" },
  "#/definitions/propertyqualities/properties/meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" },
  "#/definitions/actionqualities/properties/meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" }
  "#/definitions/eventqualities/properties/meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" }
]

> On Mar 30, 2022, at 8:30 AM, Michael Koster <[email-masked]> wrote:
> 
>> On Mar 30, 2022, at 8:23 AM, Michael Koster <[email-masked] <mailto:[email-masked]>> wrote:
>>

---

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 09:05:00 -0700

one more try; we're defining a new "meta" property in the class schemas that allows named definitions using dataqualities constraints:

[
  "#/definitions/thingqualities/properties": { 
    "meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" } 
  },
  "#/definitions/objectqualities/properties": { 
    "meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" } 
  },
  "#/definitions/propertyqualities/properties": { 
    "meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" } 
  },
  "#/definitions/actionqualities/properties": { 
    "meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" } 
  },
  "#/definitions/eventqualities/properties": { 
    "meta": { "type": "object", "additionalProperties": "$ref": "#/definitions/dataqualities" } 
  },
]

> On Mar 30, 2022, at 8:57 AM, Michael Koster <[email-masked]> wrote:
> 
> [

---

From: Michael Koster <[email-masked]>
Date: Wed, 30 Mar 2022 09:20:53 -0700

I guess the RFC7386 format merge-patch object would look like (valid JSON this time):

{
 "definitions": {
    "thingqualities": {
      "properties": {
        "meta": { 
          "type": "object", "additionalProperties": { "$ref": "#/definitions/dataqualities" } 
        }
      }
    },
    "objectqualities": {
      "properties": {
        "meta": { 
          "type": "object", "additionalProperties": { "$ref": "#/definitions/dataqualities" } 
        }
      }
    }, 
    "propertyqualities": {
      "properties": {
        "meta": { 
          "type": "object", "additionalProperties": { "$ref": "#/definitions/dataqualities" } 
        }
      }
    }, 
    "actionqualities": {
      "properties": {
        "meta": { 
          "type": "object", "additionalProperties": { "$ref": "#/definitions/dataqualities" } 
        }
      }
    }, 
    "eventqualities": {
      "properties": {
        "meta": { 
          "type": "object", "additionalProperties": { "$ref": "#/definitions/dataqualities" } 
        } 
      }
    }
  }
}

> On Mar 30, 2022, at 9:05 AM, Michael Koster <[email-masked]> wrote:
>