{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aistory-archive.pages.dev/standards/iaga.schema.json",
  "title": "IAGA Affective Packet 1.0 — Public RC Projection",
  "description": "Public exchange projection of IAGA-AFFECT-PACKET. Qualitative Core state is normative; numeric axis values require an explicitly declared scale and measurement provenance.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_id",
    "version",
    "identifier",
    "measurement_status",
    "factors_14d",
    "core_state_12d",
    "provenance",
    "rights_consent"
  ],
  "properties": {
    "schema_id": {
      "const": "IAGA-AFFECT-PACKET"
    },
    "version": {
      "const": "1.0"
    },
    "identifier": {
      "type": "string",
      "minLength": 1
    },
    "measurement_status": {
      "$ref": "#/$defs/measurementStatus"
    },
    "factors_14d": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/factor"
      }
    },
    "core_state_12d": {
      "type": "array",
      "minItems": 12,
      "maxItems": 12,
      "items": {
        "$ref": "#/$defs/axisState"
      }
    },
    "temporal_records": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/temporalRecord"
      }
    },
    "bindings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/binding"
      }
    },
    "semantic_records": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/semanticRecord"
      }
    },
    "action_tendencies": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "personal_calibration_ref": {
      "type": "string"
    },
    "confidence": {
      "$ref": "#/$defs/confidence"
    },
    "residuals": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/residual"
      }
    },
    "provenance": {
      "$ref": "#/$defs/provenance"
    },
    "rights_consent": {
      "$ref": "#/$defs/rightsConsent"
    },
    "interoperability_mapping": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/mapping"
      }
    }
  },
  "$defs": {
    "measurementStatus": {
      "enum": [
        "measured",
        "estimated",
        "inferred",
        "reconstructed",
        "simulated",
        "unknown"
      ]
    },
    "confidence": {
      "oneOf": [
        {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        {
          "enum": [
            "LOW",
            "MEDIUM",
            "HIGH",
            "UNKNOWN"
          ]
        }
      ]
    },
    "factor": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "dimension_id",
        "factor_key"
      ],
      "properties": {
        "dimension_id": {
          "enum": [
            "D01",
            "D02",
            "D03",
            "D04",
            "D05",
            "D06",
            "D07",
            "D08",
            "D09",
            "D10",
            "D11",
            "D12",
            "D13",
            "D14"
          ]
        },
        "factor_key": {
          "type": "string",
          "minLength": 1
        },
        "qualitative_state": {
          "type": "string"
        },
        "target_ref": {
          "type": "string"
        },
        "source_ref": {
          "type": "string"
        },
        "confidence": {
          "$ref": "#/$defs/confidence"
        }
      }
    },
    "axisState": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "axis_id",
        "qualitative_state",
        "measurement_status"
      ],
      "properties": {
        "axis_id": {
          "enum": [
            "AX01",
            "AX02",
            "AX03",
            "AX04",
            "AX05",
            "AX06",
            "AX07",
            "AX08",
            "AX09",
            "AX10",
            "AX11",
            "AX12"
          ]
        },
        "qualitative_state": {
          "type": "string",
          "minLength": 1
        },
        "value": {
          "type": "number"
        },
        "value_scale_ref": {
          "type": "string",
          "minLength": 1
        },
        "measurement_status": {
          "$ref": "#/$defs/measurementStatus"
        },
        "measurement_provenance_ref": {
          "type": "string",
          "minLength": 1
        },
        "confidence": {
          "$ref": "#/$defs/confidence"
        },
        "note": {
          "type": "string"
        }
      },
      "allOf": [
        {
          "if": {
            "required": [
              "value"
            ]
          },
          "then": {
            "required": [
              "value_scale_ref",
              "measurement_provenance_ref"
            ]
          }
        }
      ]
    },
    "temporalRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "stage",
        "state_ref"
      ],
      "properties": {
        "stage": {
          "enum": [
            "T-1",
            "T0",
            "T1",
            "T2",
            "T3",
            "T4",
            "CUSTOM"
          ]
        },
        "state_ref": {
          "type": "string"
        },
        "note": {
          "type": "string"
        }
      }
    },
    "binding": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "binding_type",
        "axis_id"
      ],
      "properties": {
        "binding_type": {
          "type": "string"
        },
        "axis_id": {
          "type": "string"
        },
        "target_ref": {
          "type": "string"
        },
        "source_ref": {
          "type": "string"
        },
        "component_key": {
          "type": "string"
        },
        "qualitative_state": {
          "type": "string"
        },
        "confidence": {
          "$ref": "#/$defs/confidence"
        }
      }
    },
    "semanticRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "expression"
      ],
      "properties": {
        "concept_id": {
          "type": "string"
        },
        "expression": {
          "type": "string"
        },
        "language": {
          "type": "string"
        },
        "region": {
          "type": "string"
        }
      }
    },
    "residual": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "description"
      ],
      "properties": {
        "type": {
          "enum": [
            "R0",
            "R1",
            "R2",
            "R3",
            "R4",
            "R5"
          ]
        },
        "description": {
          "type": "string"
        },
        "confidence": {
          "$ref": "#/$defs/confidence"
        }
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "source_class"
      ],
      "properties": {
        "source_class": {
          "type": "string"
        },
        "source_id": {
          "type": "string"
        },
        "method": {
          "type": "string"
        },
        "timestamp": {
          "type": "string"
        }
      }
    },
    "rightsConsent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "record",
        "storage",
        "projection",
        "public_display",
        "training",
        "reconstruction",
        "induction"
      ],
      "properties": {
        "record": {
          "$ref": "#/$defs/permission"
        },
        "storage": {
          "$ref": "#/$defs/permission"
        },
        "projection": {
          "$ref": "#/$defs/permission"
        },
        "public_display": {
          "$ref": "#/$defs/permission"
        },
        "training": {
          "$ref": "#/$defs/permission"
        },
        "reconstruction": {
          "$ref": "#/$defs/permission"
        },
        "induction": {
          "$ref": "#/$defs/permission"
        }
      }
    },
    "permission": {
      "enum": [
        "allow",
        "deny",
        "conditional",
        "unknown",
        "not_applicable"
      ]
    },
    "mapping": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "target_standard",
        "relationship"
      ],
      "properties": {
        "target_standard": {
          "type": "string"
        },
        "relationship": {
          "type": "string"
        },
        "target_identifier": {
          "type": "string"
        },
        "note": {
          "type": "string"
        }
      }
    }
  }
}
