{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/commentary-dev/json-schema/commentary-dev-interaction-schema.json",
  "title": "Interaction",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/commentary-dev-interactions-api-openapi.yml#/components/schemas/Interaction",
  "type": "object",
  "required": [
    "id",
    "resource",
    "state",
    "currentRevisionId",
    "version",
    "createdAt",
    "updatedAt"
  ],
  "additionalProperties": true,
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^ixn_[A-Za-z0-9_-]{16,}$"
    },
    "resource": {
      "$ref": "#/$defs/InteractionResource"
    },
    "state": {
      "type": "string"
    },
    "currentRevisionId": {
      "type": "string"
    },
    "version": {
      "type": "integer",
      "minimum": 1
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "terminalAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "revisions": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "messages": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InteractionMessage"
      }
    }
  },
  "$defs": {
    "InteractionMessage": {
      "type": "object",
      "required": [
        "id",
        "revisionId",
        "actor",
        "body",
        "createdAt"
      ],
      "additionalProperties": true,
      "properties": {
        "id": {
          "type": "string"
        },
        "revisionId": {
          "type": "string"
        },
        "actor": {
          "type": "object"
        },
        "body": {
          "type": [
            "string",
            "null"
          ]
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "messageVersion": {
          "type": "integer",
          "minimum": 1
        },
        "editedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "editable": {
          "type": "boolean",
          "description": "Human conversational eligibility; never grants bearer edit authority."
        }
      }
    },
    "InteractionResource": {
      "type": "object",
      "required": [
        "type",
        "id"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "draft_review",
            "form",
            "research_study",
            "web_app_review"
          ]
        },
        "id": {
          "type": "string"
        }
      }
    }
  }
}