mif-schema 0.6.0

JSON Schema validation for the MIF (Modeled Information Format) ecosystem
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mif-spec.dev/schema/mif.schema.json",
  "title": "MIF — Modeled Information Format (v1.0)",
  "description": "JSON Schema for validating the derived JSON-LD projection of a MIF v1.0 concept",
  "type": "object",
  "required": ["@context", "@type", "@id", "conceptType", "content", "created"],
  "properties": {
    "@context": {
      "description": "JSON-LD context",
      "oneOf": [
        { "type": "string", "format": "uri" },
        { "type": "array", "items": { "type": ["string", "object"] } },
        { "type": "object" }
      ]
    },
    "@type": {
      "description": "Type of the concept document",
      "oneOf": [
        { "const": "Concept" },
        { "const": "Memory" },
        { "type": "array", "contains": { "const": "Concept" } }
      ]
    },
    "@id": {
      "type": "string",
      "pattern": "^urn:mif:",
      "description": "Unique identifier in URN format"
    },
    "conceptType": {
      "type": "string",
      "enum": ["semantic", "episodic", "procedural"],
      "description": "Knowledge taxonomy: semantic (declarative knowledge), episodic (time-bound records), procedural (how-to knowledge)"
    },
    "memoryType": {
      "type": "string",
      "enum": ["semantic", "episodic", "procedural"],
      "description": "Deprecated v0.1 alias for conceptType; retained for backward compatibility"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "description": "OKF-recommended mirror of modified (or created)"
    },
    "description": {
      "type": "string",
      "description": "OKF-recommended description, mapped from MIF summary"
    },
    "content": {
      "type": "string",
      "minLength": 1,
      "description": "The memory content in Markdown format"
    },
    "title": {
      "type": "string",
      "description": "Human-readable title"
    },
    "created": {
      "type": "string",
      "format": "date-time",
      "description": "Creation timestamp (ISO 8601)"
    },
    "modified": {
      "type": "string",
      "format": "date-time",
      "description": "Last modification timestamp (ISO 8601)"
    },
    "ontology": {
      "$ref": "#/$defs/OntologyReference",
      "description": "Reference to the ontology this memory conforms to"
    },
    "entity": {
      "$ref": "#/$defs/EntityData",
      "description": "Structured entity data for ontology-typed memories"
    },
    "namespace": {
      "type": "string",
      "pattern": "^[a-zA-Z0-9_-]+(/[a-zA-Z0-9_-]+)*$",
      "description": "Hierarchical namespace path"
    },
    "tags": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Classification tags"
    },
    "aliases": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Alternative names for the memory"
    },
    "entities": {
      "type": "array",
      "items": { "$ref": "#/$defs/EntityReference" },
      "description": "Referenced entities"
    },
    "relationships": {
      "type": "array",
      "items": { "$ref": "#/$defs/Relationship" },
      "description": "Typed relationships to other memories"
    },
    "temporal": {
      "$ref": "#/$defs/TemporalMetadata",
      "description": "Temporal validity and decay data"
    },
    "provenance": {
      "$ref": "#/$defs/Provenance",
      "description": "Source and trust data"
    },
    "embedding": {
      "$ref": "#/$defs/EmbeddingReference",
      "description": "Embedding model reference"
    },
    "citations": {
      "type": "array",
      "items": { "$ref": "#/$defs/Citation" },
      "description": "Citation references (Level 3)"
    },
    "documents": {
      "type": "array",
      "items": { "$ref": "#/$defs/DocumentReference" },
      "description": "Source documents that travel alongside this memory by reference (not embedded). Vendor-neutral pointers to the underlying artifacts a memory was derived from."
    },
    "summary": {
      "type": "string",
      "maxLength": 500,
      "description": "Compressed content summary (Level 3, max 500 chars)"
    },
    "properties": {
      "type": "object",
      "additionalProperties": {
        "type": ["string", "number", "boolean", "null"]
      },
      "description": "First-class scalar properties: literal key/value pairs (e.g. from a knowledge-graph literal-object triple) that have no concept target and therefore cannot be a relationship. Values MUST be scalar (string, number, boolean, or null); nested objects/arrays are out of scope at Level 1."
    },
    "compressedAt": {
      "type": "string",
      "format": "date-time",
      "description": "When compression was applied (Level 3)"
    },
    "extensions": {
      "type": "object",
      "additionalProperties": true,
      "description": "Provider-specific extensions"
    }
  },
  "$defs": {
    "DocumentReference": {
      "type": "object",
      "description": "Vendor-neutral reference to a source document that travels alongside a memory by reference rather than by embedding a vendor-specific document schema. Locate the document by either `url` or `id`.",
      "required": ["@type"],
      "anyOf": [
        { "required": ["url"] },
        { "required": ["id"] }
      ],
      "properties": {
        "@type": {
          "const": "DocumentReference"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Stable identifier for the document (e.g. a URN or opaque key) when no resolvable URL is available"
        },
        "documentType": {
          "type": "string",
          "description": "Document category",
          "oneOf": [
            {
              "enum": [
                "pdf",
                "html",
                "markdown",
                "text",
                "transcript",
                "dataset",
                "spreadsheet",
                "presentation",
                "image",
                "audio",
                "video",
                "email",
                "other"
              ]
            },
            {
              "type": "string",
              "pattern": "^[a-zA-Z][a-zA-Z0-9]*:[a-zA-Z][a-zA-Z0-9-]*$",
              "description": "Custom namespaced type"
            }
          ]
        },
        "url": {
          "type": "string",
          "format": "uri",
          "minLength": 1,
          "description": "Resolvable location of the document"
        },
        "hash": {
          "type": "object",
          "description": "Content hash for integrity verification",
          "required": ["algorithm", "value"],
          "properties": {
            "algorithm": {
              "type": "string",
              "minLength": 1,
              "description": "Hash algorithm (e.g. sha256, sha512, blake3)"
            },
            "value": {
              "type": "string",
              "minLength": 1,
              "description": "Hash digest value"
            }
          },
          "additionalProperties": false
        },
        "contentType": {
          "type": "string",
          "minLength": 1,
          "description": "Media type of the document (e.g. application/pdf, text/html)"
        },
        "byteLength": {
          "type": "integer",
          "minimum": 0,
          "description": "Size of the document in bytes"
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "description": "Version token for the document (e.g. a commit SHA, ETag, or revision label)"
        },
        "retrievedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When the document was retrieved (ISO 8601)"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "description": "Human-readable document title"
        }
      },
      "additionalProperties": false
    },
    "Citation": {
      "type": "object",
      "required": ["@type", "citationType", "citationRole", "title", "url"],
      "properties": {
        "@type": {
          "const": "Citation"
        },
        "citationType": {
          "type": "string",
          "description": "Source category",
          "oneOf": [
            {
              "enum": [
                "article",
                "book",
                "paper",
                "website",
                "documentation",
                "repository",
                "video",
                "podcast",
                "specification",
                "dataset",
                "tool",
                "other"
              ]
            },
            {
              "type": "string",
              "pattern": "^[a-zA-Z][a-zA-Z0-9]*:[a-zA-Z][a-zA-Z0-9-]*$",
              "description": "Custom namespaced type"
            }
          ]
        },
        "citationRole": {
          "type": "string",
          "description": "Relationship to memory",
          "oneOf": [
            {
              "enum": [
                "supports",
                "refutes",
                "background",
                "methodology",
                "contradicts",
                "extends",
                "derived",
                "source",
                "example",
                "review"
              ]
            },
            {
              "type": "string",
              "pattern": "^[a-zA-Z][a-zA-Z0-9]*:[a-zA-Z][a-zA-Z0-9-]*$",
              "description": "Custom namespaced role"
            }
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "description": "Citation title"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Citation URL"
        },
        "author": {
          "description": "Author(s) as entity reference(s) or plain text",
          "oneOf": [
            { "$ref": "#/$defs/EntityReference" },
            {
              "type": "array",
              "items": { "$ref": "#/$defs/EntityReference" }
            },
            { "type": "string" }
          ]
        },
        "date": {
          "type": "string",
          "format": "date",
          "description": "Publication date (ISO 8601)"
        },
        "accessed": {
          "type": "string",
          "format": "date",
          "description": "Access date (ISO 8601)"
        },
        "relevance": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Relevance score (0.0-1.0)"
        },
        "note": {
          "type": "string",
          "maxLength": 1000,
          "description": "Free-form annotation"
        }
      },
      "additionalProperties": false
    },
    "EntityReference": {
      "$ref": "./definitions/entity-reference.schema.json"
    },
    "Relationship": {
      "type": "object",
      "description": "v1.0 typed relationship: authoritative in frontmatter, mirrored as an OKF-legible body markdown link (SPECIFICATION.md 4.4)",
      "required": ["type", "target"],
      "properties": {
        "type": {
          "type": "string",
          "description": "Relationship type as a kebab-case token (e.g. derived-from, supersedes, relates-to) or a custom namespaced type",
          "pattern": "^[a-z0-9][a-z0-9-]*(:[a-z0-9][a-z0-9-]*)?$"
        },
        "target": {
          "type": "string",
          "description": "Bundle-relative path to the target concept (e.g. /semantic/policy.md) or a urn:mif: identifier"
        },
        "strength": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Relationship strength"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "additionalProperties": false
    },
    "TemporalMetadata": {
      "type": "object",
      "properties": {
        "@type": {
          "const": "TemporalMetadata"
        },
        "validFrom": {
          "type": ["string", "null"],
          "format": "date-time"
        },
        "validUntil": {
          "type": ["string", "null"],
          "format": "date-time"
        },
        "recordedAt": {
          "type": "string",
          "format": "date-time"
        },
        "ttl": {
          "type": "string",
          "pattern": "^P",
          "description": "ISO 8601 duration"
        },
        "decay": {
          "type": "object",
          "properties": {
            "model": {
              "type": "string",
              "enum": ["none", "linear", "exponential", "step"]
            },
            "halfLife": {
              "type": "string",
              "pattern": "^P"
            },
            "currentStrength": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "strength": {
              "type": "number",
              "minimum": 0,
              "maximum": 1,
              "description": "Alias for currentStrength"
            },
            "lastReinforced": {
              "type": "string",
              "format": "date-time",
              "description": "When the memory was last reinforced"
            }
          },
          "additionalProperties": false
        },
        "accessCount": {
          "type": "integer",
          "minimum": 0
        },
        "lastAccessed": {
          "type": "string",
          "format": "date-time"
        },
        "reinforcementHistory": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["timestamp", "event"],
            "properties": {
              "timestamp": {
                "type": "string",
                "format": "date-time"
              },
              "event": {
                "type": "string"
              },
              "strengthDelta": {
                "type": "number"
              },
              "context": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          "description": "History of reinforcement events that strengthened or weakened the memory"
        }
      },
      "additionalProperties": false
    },
    "Provenance": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        },
        "sourceType": {
          "type": "string",
          "enum": [
            "user_explicit",
            "user_implicit",
            "agent_inferred",
            "external_import",
            "system_generated"
          ]
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "trustLevel": {
          "type": "string",
          "enum": [
            "verified",
            "user_stated",
            "high_confidence",
            "moderate_confidence",
            "low_confidence",
            "uncertain"
          ]
        },
        "sourceRef": {
          "type": "string",
          "description": "OPTIONAL reference to the originating source (e.g. conversation:conv-456)"
        },
        "agent": {
          "type": "string",
          "description": "OPTIONAL identifier of the agent that created the unit (e.g. claude-3-opus)"
        },
        "agentVersion": {
          "type": "string",
          "description": "OPTIONAL version of the creating agent"
        },
        "wasGeneratedBy": {
          "$ref": "#/$defs/ProvNode",
          "description": "OPTIONAL prov:wasGeneratedBy — the activity that produced this unit"
        },
        "wasAttributedTo": {
          "$ref": "#/$defs/ProvNode",
          "description": "OPTIONAL prov:wasAttributedTo — the agent the unit is attributed to"
        },
        "wasDerivedFrom": {
          "description": "OPTIONAL prov:wasDerivedFrom — the entity or entities this unit was derived from",
          "oneOf": [
            { "$ref": "#/$defs/ProvNode" },
            { "type": "array", "items": { "$ref": "#/$defs/ProvNode" } }
          ]
        }
      },
      "additionalProperties": true
    },
    "ProvNode": {
      "description": "A W3C-PROV node: either a plain IRI/identifier string or an open node object (e.g. {\"@id\": \"...\", \"@type\": \"prov:Activity\"}). Kept permissive because PROV graphs are open-ended.",
      "oneOf": [
        { "type": "string" },
        {
          "type": "object",
          "anyOf": [
            { "required": ["@id"] },
            { "required": ["id"] }
          ],
          "additionalProperties": true
        }
      ]
    },
    "EmbeddingReference": {
      "type": "object",
      "properties": {
        "@type": {
          "const": "EmbeddingReference"
        },
        "model": {
          "type": "string"
        },
        "modelVersion": {
          "type": "string"
        },
        "dimensions": {
          "type": "integer",
          "minimum": 1
        },
        "sourceText": {
          "type": "string"
        },
        "vectorUri": {
          "type": "string",
          "format": "uri"
        },
        "normalized": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "OntologyReference": {
      "type": "object",
      "description": "Reference to the ontology this memory conforms to",
      "required": ["id"],
      "properties": {
        "@type": {
          "const": "OntologyReference"
        },
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$",
          "description": "Ontology identifier (must match ontology.id in ontology definition)"
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+.*$",
          "description": "Semantic version of the ontology"
        },
        "uri": {
          "type": "string",
          "format": "uri",
          "description": "URI to the ontology definition"
        }
      },
      "additionalProperties": false
    },
    "EntityData": {
      "type": "object",
      "description": "Structured entity data for ontology-typed memories. Fields are defined by the entity_type schema in the referenced ontology.",
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "description": "Human-readable name for the entity"
        },
        "entity_type": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$",
          "description": "Entity type from ontology (e.g., grazing-plan, soil-profile)"
        },
        "entity_id": {
          "type": "string",
          "description": "Unique identifier for this entity instance"
        }
      },
      "additionalProperties": true
    }
  }
}