{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://limecloud.github.io/agentevidence/schemas/agentevidence-pack.schema.json",
  "title": "Agent Evidence pack",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "evidence_pack_id",
    "schema_version",
    "scope",
    "status",
    "created_at",
    "updated_at",
    "producer",
    "completeness"
  ],
  "properties": {
    "evidence_pack_id": {
      "$ref": "#/$defs/id"
    },
    "schema_version": {
      "type": "string",
      "const": "0.1.0"
    },
    "scope": {
      "$ref": "#/$defs/scope"
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "collecting",
        "ready",
        "partial",
        "verified",
        "reviewed",
        "exported",
        "redacted",
        "expired",
        "invalid"
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "producer": {
      "$ref": "#/$defs/producer"
    },
    "claims": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/claim"
      }
    },
    "claim_map_ref": {
      "type": "string"
    },
    "sources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/source_ref"
      }
    },
    "source_map_ref": {
      "type": "string"
    },
    "support_edges": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/support_edge"
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": true
    },
    "provenance_ref": {
      "type": "string"
    },
    "verification_results": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/verification_result"
      }
    },
    "reviews": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/review_verdict"
      }
    },
    "replay_cases": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "redactions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/redaction_record"
      }
    },
    "redaction_summary": {
      "type": "object",
      "additionalProperties": true
    },
    "telemetry": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/telemetry_ref"
      }
    },
    "completeness": {
      "$ref": "#/$defs/completeness"
    },
    "refs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ref"
      }
    },
    "export_manifest_ref": {
      "type": "string"
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,255}$"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "ref": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "ref_id": {
          "$ref": "#/$defs/id"
        },
        "kind": {
          "type": "string"
        },
        "uri": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "media_type": {
          "type": "string"
        },
        "schema_ref": {
          "type": "string"
        }
      }
    },
    "scope": {
      "type": "object",
      "additionalProperties": true,
      "minProperties": 1,
      "properties": {
        "scope_id": {
          "$ref": "#/$defs/id"
        },
        "runtime_id": {
          "$ref": "#/$defs/id"
        },
        "session_id": {
          "$ref": "#/$defs/id"
        },
        "thread_id": {
          "$ref": "#/$defs/id"
        },
        "turn_id": {
          "$ref": "#/$defs/id"
        },
        "task_id": {
          "$ref": "#/$defs/id"
        },
        "run_id": {
          "$ref": "#/$defs/id"
        },
        "artifact_id": {
          "$ref": "#/$defs/id"
        },
        "answer_id": {
          "$ref": "#/$defs/id"
        },
        "review_id": {
          "$ref": "#/$defs/id"
        },
        "external_case_id": {
          "type": "string"
        }
      }
    },
    "producer": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "type": {
          "type": "string",
          "enum": [
            "runtime",
            "service",
            "worker",
            "host",
            "exporter",
            "reviewer",
            "policy",
            "tool",
            "peer",
            "other"
          ]
        },
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      }
    },
    "missing_fact": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "reason"
      ],
      "properties": {
        "fact": {
          "type": "string"
        },
        "reason": {
          "type": "string",
          "enum": [
            "unknown",
            "unavailable",
            "redacted",
            "expired",
            "not_applicable",
            "not_collected"
          ]
        },
        "owner": {
          "type": "string"
        },
        "details": {
          "type": "string"
        },
        "observed_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "completeness_entry": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "complete",
            "partial",
            "missing",
            "unknown",
            "not_applicable",
            "not_collected"
          ]
        },
        "missing_facts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/missing_fact"
          }
        },
        "notes": {
          "type": "string"
        },
        "last_checked_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "completeness": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/completeness_entry"
      },
      "properties": {
        "runtime": {
          "$ref": "#/$defs/completeness_entry"
        },
        "telemetry": {
          "$ref": "#/$defs/completeness_entry"
        },
        "sources": {
          "$ref": "#/$defs/completeness_entry"
        },
        "claims": {
          "$ref": "#/$defs/completeness_entry"
        },
        "artifacts": {
          "$ref": "#/$defs/completeness_entry"
        },
        "verification": {
          "$ref": "#/$defs/completeness_entry"
        },
        "privacy": {
          "$ref": "#/$defs/completeness_entry"
        },
        "replay": {
          "$ref": "#/$defs/completeness_entry"
        }
      }
    },
    "selector": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "type": {
          "type": "string"
        },
        "exact": {
          "type": "string"
        },
        "prefix": {
          "type": "string"
        },
        "suffix": {
          "type": "string"
        },
        "start": {
          "type": "integer",
          "minimum": 0
        },
        "end": {
          "type": "integer",
          "minimum": 0
        },
        "json_pointer": {
          "type": "string"
        },
        "line_start": {
          "type": "integer",
          "minimum": 1
        },
        "line_end": {
          "type": "integer",
          "minimum": 1
        },
        "timestamp": {
          "type": "string"
        },
        "fragment": {
          "type": "string"
        }
      }
    },
    "source_ref": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "source_id",
        "source_kind"
      ],
      "properties": {
        "source_id": {
          "$ref": "#/$defs/id"
        },
        "source_kind": {
          "type": "string"
        },
        "uri": {
          "type": "string"
        },
        "ref": {
          "type": "string"
        },
        "selector": {
          "$ref": "#/$defs/selector"
        },
        "snippet": {
          "type": "string"
        },
        "snippet_ref": {
          "type": "string"
        },
        "retrieval": {
          "type": "object",
          "additionalProperties": true
        },
        "freshness": {
          "type": "object",
          "additionalProperties": true
        },
        "trust": {
          "type": "object",
          "additionalProperties": true
        },
        "privacy": {
          "type": "object",
          "additionalProperties": true
        }
      }
    },
    "claim": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "claim_id",
        "status"
      ],
      "properties": {
        "claim_id": {
          "$ref": "#/$defs/id"
        },
        "claim_type": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "range_ref": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "supported",
            "partially_supported",
            "unsupported",
            "contradicted",
            "unverified",
            "not_applicable"
          ]
        },
        "confidence": {
          "oneOf": [
            {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            {
              "type": "string"
            },
            {
              "type": "object",
              "additionalProperties": true
            }
          ]
        },
        "risk": {
          "type": "string"
        },
        "owner_ref": {
          "type": "string"
        },
        "support_edges": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "anyOf": [
        {
          "required": [
            "text"
          ]
        },
        {
          "required": [
            "range_ref"
          ]
        }
      ]
    },
    "support_edge": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "edge_id",
        "claim_id",
        "relationship"
      ],
      "properties": {
        "edge_id": {
          "$ref": "#/$defs/id"
        },
        "claim_id": {
          "$ref": "#/$defs/id"
        },
        "source_id": {
          "$ref": "#/$defs/id"
        },
        "verification_id": {
          "$ref": "#/$defs/id"
        },
        "review_id": {
          "$ref": "#/$defs/id"
        },
        "artifact_id": {
          "$ref": "#/$defs/id"
        },
        "provenance_node_id": {
          "$ref": "#/$defs/id"
        },
        "relationship": {
          "type": "string",
          "enum": [
            "supports",
            "partially_supports",
            "contradicts",
            "qualifies",
            "background",
            "generated_from",
            "verified_by",
            "reviewed_by",
            "derived_from",
            "generated_by",
            "used",
            "attributed_to",
            "associated_with",
            "redacted_from"
          ]
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "notes": {
          "type": "string"
        }
      }
    },
    "telemetry_ref": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "trace_id": {
          "type": "string"
        },
        "span_id": {
          "type": "string"
        },
        "span_kind": {
          "type": "string"
        },
        "event_id": {
          "type": "string"
        },
        "runtime_id": {
          "type": "string"
        },
        "session_id": {
          "type": "string"
        },
        "thread_id": {
          "type": "string"
        },
        "turn_id": {
          "type": "string"
        },
        "task_id": {
          "type": "string"
        },
        "run_id": {
          "type": "string"
        },
        "tool_call_id": {
          "type": "string"
        },
        "artifact_id": {
          "type": "string"
        },
        "backend_ref": {
          "type": "string"
        }
      }
    },
    "verification_result": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "verification_id",
        "check_type",
        "status"
      ],
      "properties": {
        "verification_id": {
          "$ref": "#/$defs/id"
        },
        "check_type": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "passed",
            "failed",
            "warning",
            "skipped",
            "not_applicable",
            "error"
          ]
        },
        "coverage": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "severity": {
          "type": "string",
          "enum": [
            "info",
            "low",
            "medium",
            "high",
            "critical"
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ref"
          }
        },
        "issues": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "checked_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "review_verdict": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "review_id",
        "verdict"
      ],
      "properties": {
        "review_id": {
          "$ref": "#/$defs/id"
        },
        "verdict": {
          "type": "string",
          "enum": [
            "approved",
            "rejected",
            "needs_changes",
            "escalated",
            "waived",
            "informational"
          ]
        },
        "reviewer": {
          "type": "object",
          "additionalProperties": true
        },
        "rubric_ref": {
          "type": "string"
        },
        "notes": {
          "type": "string"
        },
        "scope": {
          "$ref": "#/$defs/scope"
        },
        "verification_refs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "reviewed_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "redaction_record": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "redaction_id",
        "target_ref",
        "redaction_kind",
        "reason"
      ],
      "properties": {
        "redaction_id": {
          "$ref": "#/$defs/id"
        },
        "target_ref": {
          "type": "string"
        },
        "redaction_kind": {
          "type": "string",
          "enum": [
            "remove",
            "mask",
            "hash",
            "tokenize",
            "summarize",
            "withhold",
            "expire"
          ]
        },
        "reason": {
          "type": "string"
        },
        "applied_by": {
          "type": "string"
        },
        "replacement_ref": {
          "type": "string"
        },
        "applied_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}
