{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://start.kiwelaunch.com/schemas/authoring-journey.schema.json",
  "title": "Preview receipt and Seam source handoff",
  "description": "AI authoring evidence. This never grants native save or production authority; the compiler independently validates the actual project and target.",
  "oneOf": [{ "$ref": "#/$defs/preview" }, { "$ref": "#/$defs/handoff" }],
  "$defs": {
    "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "inventory": {
      "type": "array", "minItems": 1, "maxItems": 2000,
      "items": { "type": "object", "additionalProperties": false, "required": ["path", "sha256", "bytes"], "properties": {
        "path": { "type": "string", "maxLength": 512, "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$" },
        "sha256": { "$ref": "#/$defs/hash" }, "bytes": { "type": "integer", "minimum": 0 }
      }}
    },
    "proof": { "type": "object", "additionalProperties": false, "required": ["status", "receipt"], "properties": {
      "status": { "const": "passed" }, "receipt": { "type": "string", "minLength": 1, "maxLength": 512 }
    }},
    "viewport": { "type": "object", "additionalProperties": false, "required": ["width", "height", "proof"], "properties": {
      "width": { "type": "integer", "minimum": 240, "maximum": 7680 }, "height": { "type": "integer", "minimum": 240, "maximum": 4320 }, "proof": { "$ref": "#/$defs/proof" }
    }},
    "viewports": { "type": "object", "additionalProperties": false, "required": ["desktop", "phone"], "properties": { "desktop": { "$ref": "#/$defs/viewport" }, "phone": { "$ref": "#/$defs/viewport" } } },
    "preview": { "type": "object", "additionalProperties": false, "required": ["schema", "approvedBriefSha256", "inventory", "viewports", "semanticMap", "runtime"], "properties": {
      "schema": { "const": "kiwe.preview-receipt.v1" }, "approvedBriefSha256": { "$ref": "#/$defs/hash" }, "inventory": { "$ref": "#/$defs/inventory" }, "viewports": { "$ref": "#/$defs/viewports" }, "semanticMap": { "$ref": "#/$defs/proof" }, "runtime": { "$ref": "#/$defs/proof" }
    }},
    "handoff": { "type": "object", "additionalProperties": false, "required": ["schema", "frameworkMode", "accepted", "transformed", "library", "mapPath", "nativeIntentCoverage", "gaps", "validation", "comparison"], "properties": {
      "schema": { "const": "kiwe.seam-source-handoff.v1" }, "frameworkMode": { "const": true }, "accepted": { "$ref": "#/$defs/inventory" }, "transformed": { "$ref": "#/$defs/inventory" },
      "library": { "type": "object", "additionalProperties": false, "required": ["releaseId", "resources"], "properties": { "releaseId": { "type": "string", "pattern": "^[0-9.]+-[a-f0-9]{12}$" }, "resources": { "type": "array", "minItems": 1, "maxItems": 500, "items": { "type": "object", "additionalProperties": false, "required": ["source", "sha256"], "properties": { "source": { "type": "string", "minLength": 1 }, "sha256": { "$ref": "#/$defs/hash" } } } } } },
      "mapPath": { "const": "seam/seam-map.json" }, "nativeIntentCoverage": { "type": "object", "additionalProperties": false, "required": ["fields", "queries", "interactions", "conditions", "elements", "actions"], "properties": { "fields": { "$ref": "#/$defs/coverage" }, "queries": { "$ref": "#/$defs/coverage" }, "interactions": { "$ref": "#/$defs/coverage" }, "conditions": { "$ref": "#/$defs/coverage" }, "elements": { "$ref": "#/$defs/coverage" }, "actions": { "$ref": "#/$defs/coverage" } } },
      "gaps": { "type": "array", "maxItems": 0 }, "validation": { "$ref": "#/$defs/proof" }, "comparison": { "$ref": "#/$defs/viewports" }
    }},
    "coverage": { "type": "string", "enum": ["verified-in-map", "not-used"] }
  }
}
