{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentreceipts.app/.well-known/parse-decision-schema.json",
  "title": "AgentReceipts Parse Decision",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "contract_version",
    "parse_run_id",
    "scenario_id",
    "base_url",
    "started_at",
    "completed_at",
    "source_documents",
    "source_hashes",
    "discovered_capabilities",
    "decision",
    "decision_reason",
    "call_agentreceipts",
    "selected_object_types",
    "selected_tool_or_operation",
    "selected_template",
    "verification_method",
    "signal_option",
    "warnings",
    "errors",
    "result_status"
  ],
  "properties": {
    "contract_version": { "const": "agentreceipts.parse-decision.v1" },
    "parse_run_id": { "type": "string", "pattern": "^parse_[a-f0-9]{24}$" },
    "scenario_id": { "type": "string", "minLength": 1 },
    "base_url": { "type": "string", "format": "uri" },
    "started_at": { "type": "string", "format": "date-time" },
    "completed_at": { "type": "string", "format": "date-time" },
    "source_documents": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["route", "canonical_url", "content_type", "status"],
        "properties": {
          "route": { "type": "string", "pattern": "^/" },
          "canonical_url": { "type": "string", "format": "uri" },
          "content_type": { "type": "string", "minLength": 1 },
          "status": { "type": "integer", "minimum": 100, "maximum": 599 }
        }
      }
    },
    "source_hashes": {
      "type": "object",
      "additionalProperties": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
    },
    "discovered_capabilities": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
    "decision": {
      "enum": [
        "call_agentreceipts",
        "verify_existing_receipt",
        "emit_metadata_signal_only",
        "do_not_call",
        "fail_closed"
      ]
    },
    "decision_reason": { "type": "string", "minLength": 1 },
    "call_agentreceipts": { "type": "boolean" },
    "selected_object_types": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
    "selected_tool_or_operation": { "type": ["string", "null"] },
    "selected_template": { "type": ["string", "null"] },
    "verification_method": { "type": ["string", "null"] },
    "signal_option": { "enum": ["optional_metadata_only", "metadata_only_only", "none"] },
    "warnings": { "type": "array", "items": { "type": "string" } },
    "errors": { "type": "array", "items": { "type": "string" } },
    "result_status": { "enum": ["PASS", "FAIL", "ERROR"] }
  }
}
