{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://governedai.ai/schemas/evidence_packet.schema.json",
  "title": "Evidence Packet",
  "description": "An evidence packet emitted to a counterparty (auditor, regulator, counsel). Packets are scoped to a specific engagement and emitted at the tier of the most-restricted source.",
  "type": "object",
  "required": [
    "packet_id",
    "schema_version",
    "emitted_at",
    "emitted_by",
    "counterparty",
    "scope",
    "disclosure_tier",
    "source_categories",
    "evidence",
    "verification"
  ],
  "additionalProperties": false,
  "properties": {
    "packet_id": {
      "type": "string",
      "pattern": "^EP-[0-9]{4}-[0-9]{2}-[0-9]{2}-[A-Z0-9]{8}$",
      "description": "Globally unique packet identifier (date-stamped + random suffix)"
    },
    "schema_version": {
      "type": "string",
      "const": "0.1.0"
    },
    "emitted_at": {
      "type": "string",
      "format": "date-time"
    },
    "emitted_by": {
      "type": "object",
      "required": ["organization", "role", "named_signer"],
      "properties": {
        "organization": { "type": "string" },
        "role": { "type": "string" },
        "named_signer": { "type": "string" }
      },
      "additionalProperties": false
    },
    "counterparty": {
      "type": "object",
      "required": ["counterparty_id", "engagement_id"],
      "properties": {
        "counterparty_id": {
          "type": "string",
          "description": "Reference to counterparty_registry entry"
        },
        "engagement_id": {
          "type": "string",
          "description": "Specific engagement under the counterparty relationship"
        },
        "nda_reference": {
          "type": "string",
          "description": "Reference to NDA-status record"
        }
      },
      "additionalProperties": false
    },
    "scope": {
      "type": "object",
      "required": ["use_case", "time_window"],
      "properties": {
        "use_case": {
          "type": "string",
          "description": "What governed-AI artifact is the packet scoped to"
        },
        "time_window": {
          "type": "object",
          "required": ["from", "to"],
          "properties": {
            "from": { "type": "string", "format": "date-time" },
            "to": { "type": "string", "format": "date-time" }
          }
        },
        "platforms": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "additionalProperties": false
    },
    "disclosure_tier": {
      "type": "string",
      "enum": ["TIER_1_PARTNER", "TIER_2_NDA", "TIER_3_INTERNAL_ONLY"],
      "description": "Evidence packets are never TIER_0_PUBLIC; their existence is disclosable, their contents are not"
    },
    "source_categories": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["direct_incident", "postmortem", "design_decision", "architectural_principle", "regulatory_requirement", "external_evidence"]
      },
      "minItems": 1
    },
    "evidence": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["evidence_id", "evidence_type", "source_category", "sha256"],
        "properties": {
          "evidence_id": { "type": "string" },
          "evidence_type": {
            "type": "string",
            "enum": ["receipt", "audit_artifact", "replay_command", "scanner_output", "tribunal_packet", "attestation"]
          },
          "source_category": {
            "type": "string",
            "enum": ["direct_incident", "postmortem", "design_decision", "architectural_principle", "regulatory_requirement", "external_evidence"]
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$|^not_recorded$",
            "description": "SHA-256 of the canonical-form evidence. 'not_recorded' if no anchor exists; never invent."
          },
          "summary": {
            "type": "string",
            "description": "Public-safe summary; no restricted runtime specifics"
          }
        },
        "additionalProperties": false
      }
    },
    "verification": {
      "type": "object",
      "required": ["replay_command", "verifier_class"],
      "properties": {
        "replay_command": {
          "type": "string",
          "description": "Exact command that reproduces the audit"
        },
        "verifier_class": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["static_scan", "schema_check", "semantic_scan", "temporal_scan", "authority_scan", "behavioral_scan"]
          }
        },
        "external_verifier_required": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": false
    },
    "audit_notes": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Audit-time notes (e.g. no_git_context, no_content_scanned)"
    }
  }
}
