{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://loptr-lab.github.io/pixie-ecosystem-guide/assets/evidence-package.schema.json",
  "title": "PIXIE portable evidence package",
  "description": "Data interchange specification only; no authentication, ingestion, storage or release authority is implemented. Unknown metadata remains explicit.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "exported_at",
    "package_id",
    "title",
    "visibility",
    "professional_review",
    "evidence",
    "timeline",
    "contributors",
    "permissions",
    "authorities",
    "decisions"
  ],
  "properties": {
    "schema_version": {
      "const": "1.0.0"
    },
    "exported_at": {
      "type": "string",
      "minLength": 1
    },
    "package_id": {
      "type": "string",
      "minLength": 1
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "visibility": {
      "enum": [
        "public_synthetic",
        "private_restricted"
      ]
    },
    "professional_review": {
      "const": "PENDING"
    },
    "evidence": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact_id",
          "case_id",
          "source_application",
          "source_record_reference",
          "original_filename",
          "mime_type",
          "size_bytes",
          "sha256",
          "source_creation",
          "source_publication",
          "acquired_at",
          "observed_at",
          "actor_claim",
          "custody_event_ids",
          "permission_id",
          "legal_hold",
          "release_status",
          "verification_method",
          "limitations",
          "evidence_status",
          "visibility",
          "supersedes"
        ],
        "properties": {
          "artifact_id": {
            "type": "string",
            "minLength": 1
          },
          "case_id": {
            "type": "string",
            "minLength": 1
          },
          "source_application": {
            "type": "string",
            "minLength": 1
          },
          "source_record_reference": {
            "type": "string",
            "minLength": 1
          },
          "original_filename": {
            "type": "string",
            "minLength": 1
          },
          "mime_type": {
            "type": "string",
            "minLength": 1
          },
          "size_bytes": {
            "oneOf": [
              {
                "type": "string",
                "const": "unknown"
              },
              {
                "type": "integer",
                "minimum": 0
              }
            ]
          },
          "sha256": {
            "type": "string",
            "pattern": "^(unknown|[a-f0-9]{64})$"
          },
          "source_creation": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "value",
              "timezone",
              "clock_source",
              "basis"
            ],
            "properties": {
              "value": {
                "type": "string",
                "minLength": 1
              },
              "timezone": {
                "type": "string",
                "minLength": 1
              },
              "clock_source": {
                "type": "string",
                "minLength": 1
              },
              "basis": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "source_publication": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "value",
              "timezone",
              "clock_source",
              "basis"
            ],
            "properties": {
              "value": {
                "type": "string",
                "minLength": 1
              },
              "timezone": {
                "type": "string",
                "minLength": 1
              },
              "clock_source": {
                "type": "string",
                "minLength": 1
              },
              "basis": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "acquired_at": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "value",
              "timezone",
              "clock_source",
              "basis"
            ],
            "properties": {
              "value": {
                "type": "string",
                "minLength": 1
              },
              "timezone": {
                "type": "string",
                "minLength": 1
              },
              "clock_source": {
                "type": "string",
                "minLength": 1
              },
              "basis": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "observed_at": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "value",
              "timezone",
              "clock_source",
              "basis"
            ],
            "properties": {
              "value": {
                "type": "string",
                "minLength": 1
              },
              "timezone": {
                "type": "string",
                "minLength": 1
              },
              "clock_source": {
                "type": "string",
                "minLength": 1
              },
              "basis": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "actor_claim": {
            "type": "string",
            "minLength": 1
          },
          "custody_event_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "permission_id": {
            "type": "string",
            "minLength": 1
          },
          "legal_hold": {
            "enum": [
              "unknown",
              "preserve",
              "released"
            ]
          },
          "release_status": {
            "enum": [
              "HOLD",
              "PROPOSED",
              "AUTHORIZED_FOR_SPECIFIED_USE"
            ]
          },
          "verification_method": {
            "type": "string",
            "minLength": 1
          },
          "limitations": {
            "type": "string",
            "minLength": 1
          },
          "evidence_status": {
            "enum": [
              "verified_legal_authority",
              "verified_project_implementation",
              "user_supplied_claim",
              "proposed_implementation",
              "legal_interpretation",
              "unresolved_fact",
              "professional_review_pending",
              "fictional_example"
            ]
          },
          "visibility": {
            "enum": [
              "public_synthetic",
              "private_restricted"
            ]
          },
          "supersedes": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "timeline": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "event_id",
          "artifact_id",
          "case_id",
          "kind",
          "event_time",
          "recorded_at",
          "actor_claim",
          "description",
          "input_hash",
          "output_hash",
          "supersedes"
        ],
        "properties": {
          "event_id": {
            "type": "string",
            "minLength": 1
          },
          "artifact_id": {
            "type": "string",
            "minLength": 1
          },
          "case_id": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "enum": [
              "creation_claim",
              "publication_claim",
              "acquisition",
              "observation",
              "transformation",
              "custody_transfer",
              "correction"
            ]
          },
          "event_time": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "value",
              "timezone",
              "clock_source",
              "basis"
            ],
            "properties": {
              "value": {
                "type": "string",
                "minLength": 1
              },
              "timezone": {
                "type": "string",
                "minLength": 1
              },
              "clock_source": {
                "type": "string",
                "minLength": 1
              },
              "basis": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "recorded_at": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "value",
              "timezone",
              "clock_source",
              "basis"
            ],
            "properties": {
              "value": {
                "type": "string",
                "minLength": 1
              },
              "timezone": {
                "type": "string",
                "minLength": 1
              },
              "clock_source": {
                "type": "string",
                "minLength": 1
              },
              "basis": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "actor_claim": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          },
          "input_hash": {
            "type": "string",
            "minLength": 1
          },
          "output_hash": {
            "type": "string",
            "minLength": 1
          },
          "supersedes": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "contributors": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "contributor_id",
          "case_id",
          "role",
          "claim",
          "evidence_ids",
          "status"
        ],
        "properties": {
          "contributor_id": {
            "type": "string",
            "minLength": 1
          },
          "case_id": {
            "type": "string",
            "minLength": 1
          },
          "role": {
            "type": "string",
            "minLength": 1
          },
          "claim": {
            "type": "string",
            "minLength": 1
          },
          "evidence_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "status": {
            "enum": [
              "verified_legal_authority",
              "verified_project_implementation",
              "user_supplied_claim",
              "proposed_implementation",
              "legal_interpretation",
              "unresolved_fact",
              "professional_review_pending",
              "fictional_example"
            ]
          }
        }
      }
    },
    "permissions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "permission_id",
          "case_id",
          "rights_type",
          "claimed_holder",
          "scope",
          "evidence_reference",
          "territory",
          "term",
          "status",
          "limitations"
        ],
        "properties": {
          "permission_id": {
            "type": "string",
            "minLength": 1
          },
          "case_id": {
            "type": "string",
            "minLength": 1
          },
          "rights_type": {
            "type": "string",
            "minLength": 1
          },
          "claimed_holder": {
            "type": "string",
            "minLength": 1
          },
          "scope": {
            "type": "string",
            "minLength": 1
          },
          "evidence_reference": {
            "type": "string",
            "minLength": 1
          },
          "territory": {
            "type": "string",
            "minLength": 1
          },
          "term": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "enum": [
              "unknown",
              "proposed",
              "documented_for_specified_use",
              "denied"
            ]
          },
          "limitations": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "authorities": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_id",
          "title",
          "url",
          "jurisdiction",
          "version",
          "effective_date",
          "verified_on",
          "section",
          "limitations"
        ],
        "properties": {
          "source_id": {
            "type": "string",
            "minLength": 1
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "minLength": 1
          },
          "jurisdiction": {
            "type": "string",
            "minLength": 1
          },
          "version": {
            "type": "string",
            "minLength": 1
          },
          "effective_date": {
            "type": "string",
            "minLength": 1
          },
          "verified_on": {
            "type": "string",
            "minLength": 1
          },
          "section": {
            "type": "string",
            "minLength": 1
          },
          "limitations": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "decisions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "decision_id",
          "case_id",
          "question",
          "decision",
          "reason",
          "needed_evidence",
          "next_action",
          "responsible_role",
          "professional_review",
          "source_ids"
        ],
        "properties": {
          "decision_id": {
            "type": "string",
            "minLength": 1
          },
          "case_id": {
            "type": "string",
            "minLength": 1
          },
          "question": {
            "type": "string",
            "minLength": 1
          },
          "decision": {
            "enum": [
              "proceed",
              "hold",
              "choose_another_option"
            ]
          },
          "reason": {
            "type": "string",
            "minLength": 1
          },
          "needed_evidence": {
            "type": "string",
            "minLength": 1
          },
          "next_action": {
            "type": "string",
            "minLength": 1
          },
          "responsible_role": {
            "type": "string",
            "minLength": 1
          },
          "professional_review": {
            "const": "PENDING"
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    }
  }
}
