{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://event.nowonacra.com/schemas/organizational-event.schema.json",
  "title": "Organizational Event — Research Schema v0.1",
  "description": "A preliminary, non-production schema for preserving the distinctions observed in the Nowonacra Organizational Event laboratory.",
  "type": "object",
  "required": ["id", "source", "candidate", "confirmation", "semantic_status", "visibility"],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[A-Z][A-Z0-9-]{1,16}-[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{3}$"
    },
    "event_type": {
      "type": "string",
      "enum": ["Decision", "Discovery", "Risk", "Change", "Blocker"]
    },
    "source": {
      "type": "object",
      "required": ["human", "ai_workspace", "project"],
      "properties": {
        "human": { "type": "string" },
        "ai_workspace": { "type": "string" },
        "project": { "type": "string" },
        "workspace": { "type": "string" }
      },
      "additionalProperties": false
    },
    "candidate": {
      "type": "object",
      "required": ["text", "created_at"],
      "properties": {
        "text": { "type": "string", "minLength": 1 },
        "created_at": { "type": "string", "format": "date-time" },
        "created_by": { "type": "string" },
        "evidence_references": {
          "type": "array",
          "items": { "type": "string" },
          "default": []
        },
        "embedded_event_references": {
          "type": "array",
          "items": { "type": "string" },
          "default": []
        }
      },
      "additionalProperties": false
    },
    "confirmation": {
      "type": "object",
      "required": ["status", "human"],
      "properties": {
        "status": {
          "type": "string",
          "enum": ["candidate", "confirmed", "edited-and-confirmed", "rejected", "keep-local", "evidence-required"]
        },
        "human": { "type": "string" },
        "confirmed_at": { "type": ["string", "null"], "format": "date-time" },
        "confirmed_text": { "type": ["string", "null"] },
        "confirmation_evidence": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "transport": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": ["not-prepared", "prepared", "sent", "received", "intake-completed"]
        },
        "transported_at": { "type": ["string", "null"], "format": "date-time" },
        "transported_by": { "type": ["string", "null"] },
        "destination": { "type": ["string", "null"] },
        "transported_text": { "type": ["string", "null"] },
        "channel": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "core_intake": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": ["not-received", "received", "reviewing", "evidence-requested", "completed"]
        },
        "response_text": { "type": ["string", "null"] },
        "completed_at": { "type": ["string", "null"], "format": "date-time" },
        "relationships": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["type", "target_event_id", "origin", "status"],
            "properties": {
              "type": {
                "type": "string",
                "enum": ["RELATED_TO", "DEPENDS_ON", "CONTRADICTS", "SUPPORTS", "SUPERSEDES", "DERIVED_FROM", "AFFECTS", "RESOLVES", "REOPENS"]
              },
              "target_event_id": { "type": "string" },
              "origin": {
                "type": "string",
                "enum": ["embedded-in-candidate", "human-supplied", "core-suggested", "independently-retrieved", "later-use-confirmed"]
              },
              "status": {
                "type": "string",
                "enum": ["suggested", "human-accepted", "human-rejected", "unresolved"]
              },
              "evidence": { "type": ["string", "null"] }
            },
            "additionalProperties": false
          },
          "default": []
        }
      },
      "additionalProperties": false
    },
    "visibility": {
      "type": "object",
      "required": ["access_scope", "notification_scope", "action_owners"],
      "properties": {
        "access_scope": { "type": "array", "items": { "type": "string" } },
        "notification_scope": { "type": "array", "items": { "type": "string" } },
        "action_owners": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "semantic_status": {
      "type": "string",
      "enum": ["candidate", "confirmed", "active", "superseded", "reversed", "rejected", "local-only"]
    },
    "evidence_status": {
      "type": "string",
      "enum": ["evidence-pending", "semantically-sufficient", "partially-sufficient", "insufficient"]
    },
    "retrieval_status": {
      "type": "string",
      "enum": ["not-tested", "embedded-reference", "independently-retrieved", "presented", "used-in-reasoning", "affected-decision"]
    },
    "audit": {
      "type": "object",
      "properties": {
        "created_at": { "type": "string", "format": "date-time" },
        "updated_at": { "type": "string", "format": "date-time" },
        "version": { "type": "integer", "minimum": 1 },
        "history": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["at", "action", "actor"],
            "properties": {
              "at": { "type": "string", "format": "date-time" },
              "action": { "type": "string" },
              "actor": { "type": "string" },
              "note": { "type": ["string", "null"] }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "x-research-status": "preliminary",
  "x-warning": "This schema documents an evolving research model and is not a stable production contract."
}
