{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:dominus-mundi:research-foundation:0.3.1",
  "title": "Dominus Mundi traceable research model",
  "type": "object",
  "required": [
    "meta",
    "sources",
    "domains",
    "families",
    "games",
    "activities",
    "variables",
    "evidence",
    "relationships",
    "mechanisms",
    "coverage",
    "instances",
    "rules",
    "scenarios",
    "claims",
    "requirements",
    "issues",
    "views",
    "checklist",
    "entities",
    "revisions"
  ],
  "additionalProperties": false,
  "properties": {
    "meta": {
      "type": "object",
      "required": [
        "title",
        "version",
        "completeness",
        "scope"
      ]
    },
    "sources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/source"
      }
    },
    "domains": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/domain"
      }
    },
    "families": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/family"
      }
    },
    "games": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/game"
      }
    },
    "activities": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/activity"
      }
    },
    "variables": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/variable"
      }
    },
    "evidence": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/evidence"
      }
    },
    "relationships": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/relationship"
      }
    },
    "mechanisms": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/mechanism"
      }
    },
    "coverage": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/coverage"
      }
    },
    "instances": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/instance"
      }
    },
    "rules": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/rule"
      }
    },
    "scenarios": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/scenario"
      }
    },
    "claims": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/claim"
      }
    },
    "requirements": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/requirement"
      }
    },
    "issues": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/issue"
      }
    },
    "views": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/view"
      }
    },
    "checklist": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/checklist"
      }
    },
    "entities": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entity"
      }
    },
    "revisions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/revision"
      }
    },
    "components": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "adoption"
        ]
      }
    },
    "family_roles": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "adoption"
        ]
      }
    },
    "policies": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "adoption"
        ]
      }
    },
    "entity_types": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "adoption"
        ]
      }
    },
    "reference_definitions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "adoption"
        ]
      }
    },
    "source_interpretations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "adoption"
        ]
      }
    }
  },
  "$defs": {
    "source": {
      "type": "object",
      "required": [
        "id",
        "title",
        "kind",
        "recovery",
        "authority"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "local_snapshot": {
          "type": "string"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      }
    },
    "domain": {
      "type": "object",
      "required": [
        "id",
        "label",
        "kind"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "family": {
      "type": "object",
      "required": [
        "id",
        "label",
        "memberships",
        "definition_status",
        "adoption"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "memberships": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "definition": {
          "type": [
            "string",
            "null"
          ]
        },
        "definition_status": {
          "enum": [
            "label_only",
            "defined"
          ]
        }
      }
    },
    "game": {
      "type": "object",
      "required": [
        "id",
        "label",
        "source_refs",
        "recovery",
        "adoption"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      }
    },
    "activity": {
      "type": "object",
      "required": [
        "id",
        "label",
        "expanded_procedure",
        "condensed_procedure",
        "evidence_refs",
        "adoption",
        "exhaustiveness"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      }
    },
    "variable": {
      "type": "object",
      "required": [
        "id",
        "owner",
        "label",
        "definition",
        "data_type",
        "unit",
        "value_kind",
        "scope",
        "default",
        "value_states",
        "evidence_refs",
        "adoption",
        "dimensions"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "definition": {
          "type": "string",
          "minLength": 5
        },
        "owner": {
          "type": "string"
        },
        "dimensions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "data_type": {
          "enum": [
            "number",
            "integer",
            "boolean",
            "string",
            "array",
            "object",
            "enum"
          ]
        },
        "value_kind": {
          "enum": [
            "parameter",
            "quantity",
            "stock",
            "flow",
            "rate",
            "capacity",
            "category",
            "profile",
            "belief",
            "relation",
            "event",
            "procedure",
            "evidence",
            "derived"
          ]
        },
        "default": {
          "type": "object",
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "enum": [
                "specified",
                "unspecified"
              ]
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "state": {
                    "const": "specified"
                  }
                }
              },
              "then": {
                "required": [
                  "value",
                  "origin"
                ]
              }
            }
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "adoption": {
          "enum": [
            "source_only",
            "proposal",
            "user_required",
            "adopted",
            "unresolved",
            "superseded"
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "data_type": {
                "const": "number"
              },
              "default": {
                "properties": {
                  "state": {
                    "const": "specified"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "properties": {
                  "value": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "data_type": {
                "const": "integer"
              },
              "default": {
                "properties": {
                  "state": {
                    "const": "specified"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "properties": {
                  "value": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "data_type": {
                "const": "string"
              },
              "default": {
                "properties": {
                  "state": {
                    "const": "specified"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "properties": {
                  "value": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "data_type": {
                "const": "boolean"
              },
              "default": {
                "properties": {
                  "state": {
                    "const": "specified"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "properties": {
                  "value": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "data_type": {
                "const": "object"
              },
              "default": {
                "properties": {
                  "state": {
                    "const": "specified"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "properties": {
                  "value": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "data_type": {
                "const": "array"
              },
              "default": {
                "properties": {
                  "state": {
                    "const": "specified"
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "properties": {
                  "value": {
                    "type": "array"
                  }
                }
              }
            }
          }
        }
      ]
    },
    "evidence": {
      "type": "object",
      "required": [
        "id",
        "source_id",
        "start_line",
        "end_line",
        "quote",
        "quote_sha256",
        "epistemic_status"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "source_id": {
          "type": "string"
        },
        "start_line": {
          "type": "integer",
          "minimum": 1
        },
        "end_line": {
          "type": "integer",
          "minimum": 1
        },
        "quote": {
          "type": "string"
        },
        "quote_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      }
    },
    "relationship": {
      "type": "object",
      "required": [
        "id",
        "source",
        "target",
        "kind",
        "adoption",
        "evidence_refs",
        "context",
        "effect_sign"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string"
        },
        "target": {
          "type": "string"
        },
        "kind": {
          "enum": [
            "contains",
            "groups",
            "defines",
            "compares_with",
            "mechanism_input",
            "mechanism_output",
            "causes",
            "enables",
            "constrains",
            "measures",
            "accounts_for",
            "owns",
            "authorizes",
            "informs",
            "summarizes"
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "mechanism_ref": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "mechanism": {
      "type": "object",
      "required": [
        "id",
        "label",
        "scope",
        "logic",
        "inputs",
        "outputs",
        "expression",
        "condition",
        "delay",
        "evidence_refs",
        "adoption"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "logic": {
          "enum": [
            "formula",
            "procedure",
            "conditional",
            "constraint"
          ]
        },
        "inputs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "ref",
              "role",
              "required"
            ],
            "properties": {
              "ref": {
                "type": "string"
              },
              "required": {
                "type": "boolean"
              }
            }
          }
        },
        "outputs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "ref",
              "role"
            ],
            "properties": {
              "ref": {
                "type": "string"
              }
            }
          }
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      }
    },
    "coverage": {
      "type": "object",
      "required": [
        "id",
        "source_item",
        "evidence_refs",
        "targets",
        "disposition",
        "review"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "targets": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "disposition": {
          "enum": [
            "definition_extracted",
            "label_recovered",
            "source_missing",
            "definition_pending",
            "excluded_with_reason"
          ]
        }
      }
    },
    "instance": {
      "type": "object",
      "required": [
        "id",
        "definition_id",
        "value_state",
        "scenario",
        "time",
        "evidence_refs",
        "adoption"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "value_state": {
          "enum": [
            "known",
            "unknown",
            "absent",
            "inapplicable"
          ]
        },
        "definition_id": {
          "type": "string"
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      }
    },
    "rule": {
      "type": "object",
      "required": [
        "id",
        "label",
        "mechanism_ref",
        "scope",
        "adoption",
        "evidence_refs"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "scenario": {
      "type": "object",
      "required": [
        "id",
        "label",
        "scope",
        "adoption"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "claim": {
      "type": "object",
      "required": [
        "id",
        "label",
        "claim",
        "epistemic_status",
        "adoption",
        "evidence_refs"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "requirement": {
      "type": "object",
      "required": [
        "id",
        "label",
        "quote",
        "status",
        "source_id",
        "adoption",
        "implementation_status"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "issue": {
      "type": "object",
      "required": [
        "id",
        "label",
        "state",
        "detail"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "state": {
          "enum": [
            "open",
            "resolved",
            "superseded"
          ]
        }
      }
    },
    "view": {
      "type": "object",
      "required": [
        "id",
        "label",
        "object_types",
        "note"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "checklist": {
      "type": "object",
      "required": [
        "id",
        "label",
        "status",
        "completion_claim"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "enum": [
            "pending",
            "in_progress",
            "blocked",
            "complete"
          ]
        }
      }
    },
    "entity": {
      "type": "object",
      "required": [
        "id",
        "label",
        "entity_type",
        "scope"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "revision": {
      "type": "object",
      "required": [
        "id",
        "target_id",
        "previous_version",
        "change",
        "evidence_refs"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      }
    }
  }
}
