{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.arkz.ai/protocol/v0/scope.schema.json",
  "title": "ARK Record scope v0",
  "description": "The scope.arp object of a derivative or a Custom ARK: what it may draw on, down to one piece of provenance. Authored by DotWin. Include first, then exclude; an empty or absent list means all of that dimension; include.record_refs is an explicit pick list unioned with the rest of include.",
  "type": "object",
  "required": [
    "v"
  ],
  "additionalProperties": false,
  "properties": {
    "v": {
      "const": 0
    },
    "include": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "facets": {
          "$ref": "#/$defs/facets"
        },
        "kinds": {
          "$ref": "#/$defs/kinds"
        },
        "domains": {
          "$ref": "#/$defs/strings"
        },
        "topics": {
          "$ref": "#/$defs/strings"
        },
        "authorship": {
          "$ref": "#/$defs/authorship"
        },
        "trust_min": {
          "description": "The lowest trust tier admitted: T2 admits T0, T1 and T2. Derived (T4) records are included only when kinds names them.",
          "enum": [
            "T0",
            "T1",
            "T2",
            "T3",
            "T4"
          ]
        },
        "privacy_max": {
          "description": "Never exceeds the derivative's own ceiling; the resolver only narrows. Vault is never available.",
          "enum": [
            "training",
            "licensable"
          ]
        },
        "provenance": {
          "$ref": "#/$defs/provenance"
        },
        "record_refs": {
          "$ref": "#/$defs/record_refs"
        },
        "since": {
          "description": "Lower bound on captured_at.",
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "until": {
          "description": "Upper bound on captured_at.",
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "exclude": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "facets": {
          "$ref": "#/$defs/facets"
        },
        "kinds": {
          "$ref": "#/$defs/kinds"
        },
        "domains": {
          "$ref": "#/$defs/strings"
        },
        "topics": {
          "$ref": "#/$defs/strings"
        },
        "authorship": {
          "$ref": "#/$defs/authorship"
        },
        "provenance": {
          "$ref": "#/$defs/provenance"
        },
        "record_refs": {
          "$ref": "#/$defs/record_refs"
        }
      }
    }
  },
  "$defs": {
    "strings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "facets": {
      "type": "array",
      "items": {
        "enum": [
          "identity",
          "belief_value",
          "knowledge",
          "framework",
          "position_decision",
          "experience_story",
          "preference_boundary",
          "voice",
          "likeness",
          "behavior_execution",
          "relationship",
          "provenance_consent",
          "disposition",
          "humor",
          "mannerism",
          "body_of_work"
        ]
      }
    },
    "kinds": {
      "type": "array",
      "items": {
        "enum": [
          "name",
          "bio",
          "expertise",
          "mastery",
          "role",
          "belief",
          "value",
          "opinion",
          "identity",
          "knowledge",
          "skill",
          "document",
          "passage",
          "raw",
          "process",
          "pattern",
          "definition",
          "correction",
          "decision",
          "position",
          "experience",
          "story",
          "journal",
          "preference",
          "boundary",
          "utterance",
          "marker",
          "profile_version",
          "audio_profile",
          "likeness_asset",
          "face_reference",
          "voiceprint",
          "motion_reference",
          "laugh_sample",
          "consent_scope",
          "likeness_model",
          "habit",
          "task",
          "project",
          "trade",
          "person",
          "interaction",
          "certificate",
          "grant",
          "attestation",
          "baseline",
          "state",
          "expression",
          "trigger",
          "coping",
          "profile",
          "sarcasm_index",
          "laugh",
          "bit",
          "never",
          "verbal",
          "physical",
          "ritual",
          "rhythm",
          "appearance",
          "work",
          "collection",
          "credit",
          "style_profile"
        ]
      }
    },
    "authorship": {
      "type": "array",
      "items": {
        "enum": [
          "self_verbatim",
          "self_paraphrase",
          "self_structured",
          "about_subject",
          "derived"
        ]
      }
    },
    "uuids": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
      }
    },
    "provenance": {
      "description": "Select by where a record came from.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "owner_sources": {
          "description": "The owner's own capture paths, by source type.",
          "$ref": "#/$defs/strings"
        },
        "documents": {
          "$ref": "#/$defs/uuids"
        },
        "sessions": {
          "$ref": "#/$defs/uuids"
        },
        "integrations": {
          "$ref": "#/$defs/uuids"
        },
        "grants": {
          "$ref": "#/$defs/uuids"
        },
        "credential_kinds": {
          "type": "array",
          "items": {
            "enum": [
              "owner",
              "api_key",
              "oauth",
              "source_key"
            ]
          }
        }
      }
    },
    "record_refs": {
      "description": "Each entry names one record by its ref or its id.",
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^(rec_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[a-z0-9_]+:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(:[a-z_]+)?)$"
      }
    }
  }
}
