{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.proofxray.com/spec/llms-signature/1/schema.json",
  "title": "llms-signature/1 document",
  "description": "Document publié à /.well-known/llms-signature.json. Le schéma décrit la structure ; la vérification cryptographique (digest, signature, hachage des fichiers) reste à faire selon la spécification.",
  "type": "object",
  "required": ["format", "status", "payload", "digest", "signature"],
  "properties": {
    "format": { "const": "llms-signature/1" },
    "status": { "enum": ["signed", "unsigned"] },
    "reason": { "type": "string" },
    "payload": {
      "type": "object",
      "required": ["type", "format", "issuer", "signedAt", "validUntil", "hashAlgorithm", "keyId", "jwksUrl", "files"],
      "properties": {
        "type": { "const": "llms-signature" },
        "format": { "const": "llms-signature/1" },
        "issuer": { "type": "string", "format": "uri", "pattern": "^https?://[^/]+$" },
        "signedAt": { "type": "string", "format": "date-time" },
        "validUntil": { "type": "string", "format": "date-time" },
        "hashAlgorithm": { "const": "SHA-256" },
        "keyId": { "type": "string", "minLength": 1 },
        "jwksUrl": { "type": "string", "format": "uri" },
        "files": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["path", "sha256"],
            "properties": {
              "path": { "type": "string", "pattern": "^/" },
              "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
              "bytes": { "type": "integer", "minimum": 0 }
            },
            "additionalProperties": false
          }
        }
      },
      "not": { "anyOf": [ { "required": ["expiresAt"] }, { "required": ["domain"] }, { "required": ["score"] }, { "required": ["certified"] }, { "required": ["auditedAt"] }, { "required": ["scanId"] }, { "required": ["claimRoot"] }, { "required": ["tier"] } ] }
    },
    "digest": { "type": ["string", "null"], "pattern": "^[0-9a-f]{64}$" },
    "signature": {
      "type": ["object", "null"],
      "required": ["alg", "kid", "context", "value"],
      "properties": {
        "alg": { "const": "Ed25519" },
        "kid": { "type": "string", "minLength": 1 },
        "jwksUrl": { "type": "string", "format": "uri" },
        "context": { "type": "string", "minLength": 1 },
        "value": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" }
      }
    },
    "countersignatures": { "type": "array" },
    "scope": { "type": "string" },
    "howToVerify": { "type": "array", "items": { "type": "string" } }
  },
  "if": { "properties": { "status": { "const": "signed" } } },
  "then": { "required": ["digest", "signature"], "properties": { "digest": { "type": "string" }, "signature": { "type": "object" } } }
}
