{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://vclaw.dev/schemas/video/artifacts/cinema-generation-quote.schema.json",
  "title": "CinemaGenerationQuoteArtifact",
  "type": "object",
  "required": ["schemaVersion", "quoteId", "projectSlug", "routeId", "accountClass", "capabilitySnapshotId", "capabilitySnapshotHash", "createdAt", "expiresAt", "jobs", "totalCost", "maximumBalanceDebit", "balanceEnvelope", "contentHash"],
  "additionalProperties": false,
  "properties": {
    "schemaVersion": { "const": 1 },
    "quoteId": { "type": "string", "minLength": 1 },
    "projectSlug": { "type": "string", "minLength": 1 },
    "routeId": { "type": "string", "minLength": 1 },
    "accountClass": { "enum": ["subscription-unlimited", "provider-credits", "api-credits", "free", "local"] },
    "capabilitySnapshotId": { "type": "string", "minLength": 1 },
    "capabilitySnapshotHash": { "$ref": "#/definitions/Sha256" },
    "createdAt": { "type": "string", "format": "date-time" },
    "expiresAt": { "type": "string", "format": "date-time" },
    "jobs": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/Job" } },
    "totalCost": { "$ref": "#/definitions/Money" },
    "maximumBalanceDebit": { "$ref": "#/definitions/Money" },
    "balanceEnvelope": {
      "type": "object",
      "required": ["observedBefore", "minimumBefore", "maximumBefore"],
      "additionalProperties": false,
      "properties": {
        "observedBefore": { "$ref": "#/definitions/Money" },
        "minimumBefore": { "$ref": "#/definitions/Money" },
        "maximumBefore": { "$ref": "#/definitions/Money" }
      }
    },
    "contentHash": { "$ref": "#/definitions/Sha256" }
  },
  "definitions": {
    "Sha256": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "Money": {
      "type": "object", "required": ["currency", "amount"], "additionalProperties": false,
      "properties": { "currency": { "type": "string", "minLength": 1 }, "amount": { "type": "number", "minimum": 0 } }
    },
    "Job": {
      "type": "object",
      "required": ["jobId", "taskKind", "payloadHash", "sourceHashes", "providerArgumentsHash", "quantity", "unitCost", "maximumCost"],
      "additionalProperties": false,
      "properties": {
        "jobId": { "type": "string", "minLength": 1 },
        "taskKind": { "enum": ["image-generate", "image-repair", "video-generate", "audio-generate", "visual-qc", "identity-qc", "continuity-qc", "editorial-qc", "post-process", "assemble"] },
        "payloadHash": { "$ref": "#/definitions/Sha256" },
        "sourceHashes": { "type": "array", "items": { "$ref": "#/definitions/Sha256" } },
        "providerArgumentsHash": { "$ref": "#/definitions/Sha256" },
        "quantity": { "type": "integer", "minimum": 1 },
        "unitCost": { "$ref": "#/definitions/Money" },
        "maximumCost": { "$ref": "#/definitions/Money" }
      }
    }
  }
}
