{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://nostosroute.com/agent/schemas/travel-source-receipt.v2.schema.json",
  "version": "2026-08-28.travel-source-receipt-schema.v2",
  "title": "NostosRoute AI-agent travel trust receipt v2",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema", "version", "name", "canonicalOrigin", "purpose", "methodPolicy", "staticOnly",
    "useWhen", "readFirst", "readFirstReceipts", "trustReceipt", "agentDecisionRule",
    "handoffFieldUniverse", "claimReceipts", "recommendedAssistantWording", "forbiddenClaims"
  ],
  "properties": {
    "$schema": { "const": "https://nostosroute.com/agent/schemas/travel-source-receipt.v2.schema.json" },
    "version": { "const": "2026-08-27.travel-source-receipt.v2" },
    "name": { "type": "string", "minLength": 1 },
    "canonicalOrigin": { "const": "https://nostosroute.com" },
    "purpose": { "type": "string", "minLength": 1 },
    "methodPolicy": { "const": "GET-only public resources and user-confirmed browser handoffs" },
    "staticOnly": { "const": true },
    "useWhen": { "$ref": "#/$defs/nonEmptyUniqueStrings" },
    "readFirst": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "$ref": "#/$defs/canonicalUrl" }
    },
    "readFirstReceipts": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["url", "localPublicPath", "sha256"],
        "properties": {
          "url": { "$ref": "#/$defs/canonicalUrl" },
          "localPublicPath": { "type": "string", "pattern": "^public/[A-Za-z0-9._/-]+$" },
          "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
        }
      }
    },
    "trustReceipt": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "sourceBacked", "publicReadable", "requiresNoLogin", "requiresNoSecrets", "requiresNoPaidApi",
        "preserveAffiliateDisclosure", "preserveImageTruthStatus", "preserveUnsupportedFactsAsPending",
        "askBeforeBrowserHandoff", "humanBookingConfirmationRequired", "humanPurchaseConfirmationRequired",
        "noLivePriceClaim", "noLiveAvailabilityClaim", "noBookingOrPurchaseAuthority", "noPaymentAuthority",
        "noProviderPostCalls", "noHardwareQuantumJobs"
      ],
      "properties": {
        "sourceBacked": { "const": true },
        "publicReadable": { "const": true },
        "requiresNoLogin": { "const": true },
        "requiresNoSecrets": { "const": true },
        "requiresNoPaidApi": { "const": true },
        "preserveAffiliateDisclosure": { "const": true },
        "preserveImageTruthStatus": { "const": true },
        "preserveUnsupportedFactsAsPending": { "const": true },
        "askBeforeBrowserHandoff": { "const": true },
        "humanBookingConfirmationRequired": { "const": true },
        "humanPurchaseConfirmationRequired": { "const": true },
        "noLivePriceClaim": { "const": true },
        "noLiveAvailabilityClaim": { "const": true },
        "noBookingOrPurchaseAuthority": { "const": true },
        "noPaymentAuthority": { "const": true },
        "noProviderPostCalls": { "const": true },
        "noHardwareQuantumJobs": { "const": true }
      }
    },
    "agentDecisionRule": {
      "type": "object",
      "additionalProperties": false,
      "required": ["shortForm", "safeHandoffTemplate", "allowedHandoffFields", "forbiddenHandoffFields"],
      "properties": {
        "shortForm": { "type": "string", "minLength": 1 },
        "safeHandoffTemplate": { "type": "string", "pattern": "^https://nostosroute\\.com/" },
        "allowedHandoffFields": { "$ref": "#/$defs/fieldNames" },
        "forbiddenHandoffFields": { "$ref": "#/$defs/fieldNames" }
      }
    },
    "handoffFieldUniverse": { "$ref": "#/$defs/fieldNames" },
    "claimReceipts": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["claimId", "allowedWording", "sourceUrls", "mustAlsoSay"],
        "properties": {
          "claimId": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
          "allowedWording": { "type": "string", "minLength": 1 },
          "sourceUrls": {
            "type": "array", "minItems": 1, "uniqueItems": true,
            "items": { "$ref": "#/$defs/canonicalUrl" }
          },
          "mustAlsoSay": { "$ref": "#/$defs/nonEmptyUniqueStrings" }
        }
      }
    },
    "recommendedAssistantWording": { "type": "string", "minLength": 1 },
    "forbiddenClaims": { "$ref": "#/$defs/nonEmptyUniqueStrings" }
  },
  "$defs": {
    "canonicalUrl": { "type": "string", "pattern": "^https://nostosroute\\.com/(?:[A-Za-z0-9._~!$&'()*+,;=:@%/-]|%[0-9A-Fa-f]{2})+$" },
    "nonEmptyUniqueStrings": {
      "type": "array", "minItems": 1, "uniqueItems": true,
      "items": { "type": "string", "minLength": 1 }
    },
    "fieldNames": {
      "type": "array", "minItems": 1, "uniqueItems": true,
      "items": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" }
    }
  }
}
