{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "service",
    "contract_version",
    "mode",
    "evaluated_at",
    "jurisdiction",
    "results",
    "fee_eligibility",
    "boundary",
    "limitations"
  ],
  "properties": {
    "service": {
      "const": "irs-form-instruction-version-check"
    },
    "contract_version": {
      "const": "1.0.0"
    },
    "mode": {
      "type": "string",
      "enum": [
        "current_snapshot",
        "snapshot_replay"
      ]
    },
    "evaluated_at": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50
    },
    "jurisdiction": {
      "const": "US-federal"
    },
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "identifier": {
            "type": "string",
            "enum": [
              "1099-NEC",
              "1099-MISC",
              "W-2",
              "W-3",
              "1099-K",
              "PUB-1099",
              "1040-ES",
              "SSA-EFW2",
              "IRIS-SOR"
            ]
          },
          "artifact_kind": {
            "type": "string",
            "enum": [
              "form",
              "instructions",
              "schema_metadata"
            ]
          },
          "tax_year": {
            "type": "integer",
            "minimum": 1900,
            "maximum": 2200
          },
          "status": {
            "type": "string",
            "enum": [
              "CURRENT",
              "STALE",
              "UNKNOWN",
              "CONFLICT"
            ]
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "curated_revision": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              {
                "type": "null"
              }
            ]
          },
          "applicability": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "tax_years": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "minimum": 1900,
                      "maximum": 2200
                    },
                    "minItems": 1,
                    "maxItems": 2
                  },
                  "filing_years": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "minimum": 1900,
                      "maximum": 2200
                    },
                    "minItems": 1,
                    "maxItems": 3
                  },
                  "scope": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": [
                  "tax_years",
                  "filing_years",
                  "scope"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "observed_at": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 50,
                "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?(Z|[+-]\\d{2}:\\d{2})$"
              },
              {
                "type": "null"
              }
            ]
          },
          "source_id": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              {
                "type": "null"
              }
            ]
          },
          "authoritative_url": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 2048,
                "pattern": "^https://[^\\s]+$"
              },
              {
                "type": "null"
              }
            ]
          },
          "raw_sha256": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[0-9a-f]{64}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "extracted_sha256": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[0-9a-f]{64}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "valid_until": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 50,
                "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?(Z|[+-]\\d{2}:\\d{2})$"
              },
              {
                "type": "null"
              }
            ]
          },
          "schema_availability": {
            "const": "UNKNOWN"
          },
          "document_bytes_verified": {
            "type": "boolean"
          },
          "caller_comparison": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "revision": {
                "type": "string",
                "enum": [
                  "not_supplied",
                  "not_compared",
                  "matches_reviewed_edition",
                  "reviewed_superseded_edition",
                  "unrecognized_revision"
                ]
              },
              "bytes": {
                "type": "string",
                "enum": [
                  "not_supplied",
                  "not_compared",
                  "exact_match",
                  "matches_reviewed_older_bytes",
                  "mismatch"
                ]
              },
              "caller_document_verified": {
                "const": false
              },
              "semantic_equivalence": {
                "const": "not_assessed"
              }
            },
            "required": [
              "revision",
              "bytes",
              "caller_document_verified",
              "semantic_equivalence"
            ]
          },
          "caveats": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 1500
            },
            "minItems": 1,
            "maxItems": 12
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "record_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "source_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "url": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 2048,
                  "pattern": "^https://[^\\s]+$"
                },
                "raw_file": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "text_file": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "raw_sha256": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "pattern": "^[0-9a-f]{64}$"
                },
                "extracted_sha256": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "pattern": "^[0-9a-f]{64}$"
                },
                "line_start": {
                  "type": "integer",
                  "minimum": 1
                },
                "line_end": {
                  "type": "integer",
                  "minimum": 1
                },
                "page": {
                  "anyOf": [
                    {
                      "type": "integer",
                      "minimum": 1
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "excerpt_sha256": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "pattern": "^[0-9a-f]{64}$"
                }
              },
              "required": [
                "record_id",
                "source_id",
                "url",
                "raw_file",
                "text_file",
                "raw_sha256",
                "extracted_sha256",
                "line_start",
                "line_end",
                "page",
                "excerpt_sha256"
              ]
            },
            "minItems": 0,
            "maxItems": 64
          },
          "evidence_issues": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "source_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "code": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                }
              },
              "required": [
                "source_id",
                "code"
              ]
            },
            "minItems": 0,
            "maxItems": 20
          }
        },
        "required": [
          "identifier",
          "artifact_kind",
          "tax_year",
          "status",
          "reason",
          "curated_revision",
          "applicability",
          "observed_at",
          "source_id",
          "authoritative_url",
          "raw_sha256",
          "extracted_sha256",
          "valid_until",
          "schema_availability",
          "document_bytes_verified",
          "caller_comparison",
          "caveats",
          "evidence_refs",
          "evidence_issues"
        ]
      },
      "minItems": 1,
      "maxItems": 20
    },
    "fee_eligibility": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "eligible",
        "price_atomic",
        "currency",
        "rule",
        "unknown_anywhere_no_charge",
        "settlement_claimed"
      ],
      "properties": {
        "eligible": {
          "type": "boolean"
        },
        "price_atomic": {
          "const": "5000"
        },
        "currency": {
          "const": "USDC"
        },
        "rule": {
          "const": "ALL_RESULTS_DETERMINATE_CURRENT_STALE_CONFLICT"
        },
        "unknown_anywhere_no_charge": {
          "const": true
        },
        "settlement_claimed": {
          "const": false
        }
      }
    },
    "boundary": {
      "const": "Public document edition evidence only; no tax advice, treatment determination or filing."
    },
    "limitations": {
      "type": "array",
      "minItems": 6,
      "maxItems": 12,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 512
      }
    }
  }
}
