{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://contextualagentic.ai/assets/context-model.schema.json",
  "title": "Proposed contextual discovery model, version 1.0",
  "description": "An original engagement schema for discussion, not a canonical CAE ontology or an implemented enterprise runtime.",
  "type": "object",
  "additionalProperties": false,
  "required": ["modelId", "version", "owner", "purpose", "entities", "relationships"],
  "properties": {
    "modelId": {"type":"string","minLength":1},
    "version": {"type":"string","pattern":"^[0-9]+\\.[0-9]+\\.[0-9]+$"},
    "owner": {"type":"string","minLength":1},
    "purpose": {"type":"string","minLength":1},
    "entities": {"type":"array","items":{"$ref":"#/$defs/entity"}},
    "relationships": {"type":"array","items":{"$ref":"#/$defs/relationship"}}
  },
  "$defs": {
    "evidenceRefs": {"type":"array","items":{"type":"string","minLength":1}},
    "entity": {
      "type":"object","additionalProperties":false,
      "required":["id","type","label","owner","classification","reviewStatus","evidenceRefs"],
      "properties": {
        "id":{"type":"string","minLength":1},
        "type":{"enum":["Outcome","Workflow","Activity","Role","System","Information","Concept","Policy","Authority","Decision","Action","Evidence","Measure"]},
        "label":{"type":"string","minLength":1},
        "owner":{"type":"string","minLength":1},
        "classification":{"enum":["public","internal","confidential","restricted","unclassified"]},
        "reviewStatus":{"enum":["declared","inferred","reviewed","disputed","unknown"]},
        "evidenceRefs":{"$ref":"#/$defs/evidenceRefs"},
        "validFrom":{"type":"string","format":"date-time"},
        "validUntil":{"type":"string","format":"date-time"}
      }
    },
    "relationship": {
      "type":"object","additionalProperties":false,
      "required":["from","to","relation","owner","reviewStatus","evidenceRefs"],
      "properties": {
        "from":{"type":"string","minLength":1},"to":{"type":"string","minLength":1},
        "relation":{"enum":["guides","measuredBy","uses","governedBy","ownedBy","representedIn","supportedBy","describedBy","grantedTo","constrains","cites","authorises","madeBy","supports","records","informs"]},
        "owner":{"type":"string","minLength":1},
        "reviewStatus":{"enum":["declared","inferred","reviewed","disputed","unknown"]},
        "evidenceRefs":{"$ref":"#/$defs/evidenceRefs"}
      }
    }
  }
}
