{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sunterminal.net/schemas/consult-response-v1.schema.json",
  "title": "Sun Terminal consultation success response v1",
  "description": "A final Rider–Waite Tarot result containing card identities and upright or reversed orientations, with its encounter receipt.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "encounter_id",
    "status",
    "instrument",
    "raw_result",
    "receipt",
    "instrument_url"
  ],
  "properties": {
    "schema_version": {
      "const": "sun-terminal.consult-response@1"
    },
    "encounter_id": {
      "type": "string",
      "pattern": "^enc_[0-9a-f]{32}$"
    },
    "status": {
      "const": "final"
    },
    "instrument": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "version",
        "manifest_digest"
      ],
      "properties": {
        "id": {
          "const": "tarot.rider-waite"
        },
        "version": {
          "const": 1
        },
        "manifest_digest": {
          "$ref": "./encounter-receipt-v1.schema.json#/$defs/digest"
        }
      }
    },
    "raw_result": {
      "$ref": "./encounter-receipt-v1.schema.json#/$defs/raw_result"
    },
    "receipt": {
      "$ref": "./encounter-receipt-v1.schema.json"
    },
    "instrument_url": {
      "const": "https://sunterminal.net/instruments/tarot-rider-waite"
    }
  },
  "examples": [
    {
      "schema_version": "sun-terminal.consult-response@1",
      "encounter_id": "enc_00000000000000000000000000000005",
      "status": "final",
      "instrument": {
        "id": "tarot.rider-waite",
        "version": 1,
        "manifest_digest": {
          "algorithm": "sha-256",
          "value": "cf2f783870880f60d35b8274039e577501c998d8cbf67eef8888fb1ea8220f0b"
        }
      },
      "raw_result": {
        "schema_version": "sun-terminal.tarot.raw-result@1",
        "structural_inputs": {
          "count": 3,
          "position_labels": [
            "position-1",
            "position-2",
            "position-3"
          ]
        },
        "positions": [
          {
            "position": {
              "index": 1,
              "label": "position-1"
            },
            "card_id": "pentacles-03",
            "orientation": "upright"
          },
          {
            "position": {
              "index": 2,
              "label": "position-2"
            },
            "card_id": "swords-01",
            "orientation": "upright"
          },
          {
            "position": {
              "index": 3,
              "label": "position-3"
            },
            "card_id": "major-13",
            "orientation": "reversed"
          }
        ],
        "permutation_commitment": {
          "kernel": {
            "id": "committed-permutation",
            "version": 2
          },
          "deck": {
            "id": "rider-waite",
            "version": 1
          },
          "derivation": {
            "id": "hkdf-sha256-counter-stream",
            "version": 1,
            "hash": "sha-256",
            "seedEncoding": "32-byte-raw-from-64-lowercase-hex",
            "saltUtf8": "sun-terminal/tarot/hkdf-sha256-counter-stream/v1",
            "shuffleInfoPrefixUtf8": "sun-terminal/tarot/committed-permutation@2/rider-waite@1/shuffle/fisher-yates-rejection@1",
            "orientationInfoPrefixUtf8": "sun-terminal/tarot/committed-permutation@2/rider-waite@1/orientation/position-word-parity@1",
            "infoEncoding": "utf8-prefix-nul-uint32-be-page-counter",
            "shuffleStream": "shuffle",
            "orientationStream": "orientation",
            "pageBytes": 512,
            "pageCounterStart": 0,
            "wordEncoding": "uint32-be"
          },
          "shuffle": {
            "id": "fisher-yates-rejection",
            "version": 1
          },
          "orientation": {
            "id": "position-word-parity",
            "version": 1
          },
          "canonicalization": {
            "id": "sun-terminal-tarot-permutation-json",
            "version": 2
          },
          "permutationHash": {
            "algorithm": "sha-256",
            "value": "c9d9d1909297ba936913b6c78162faeb733eb426ef234cfc35b6139fda3a5d2b"
          }
        },
        "raw_result_hash": {
          "algorithm": "sha-256",
          "canonicalization": {
            "id": "sun-terminal-tarot-raw-result-json",
            "version": 1
          },
          "value": "9fffa308351b95bb79bd68dd2a2aefc5cbcfb3c2cd3d0e6f6518e673021b1c43"
        }
      },
      "receipt": {
        "schema_version": "sun-terminal.encounter-receipt@1",
        "encounter": {
          "id": "enc_00000000000000000000000000000005",
          "status": "final",
          "committed_at": "2026-08-01T00:00:00.000Z",
          "finalized_at": "2026-08-01T00:00:01.000Z"
        },
        "draw_facts": {
          "instrument": {
            "id": "tarot.rider-waite",
            "version": 1
          },
          "raw_result": {
            "schema_version": "sun-terminal.tarot.raw-result@1",
            "structural_inputs": {
              "count": 3,
              "position_labels": [
                "position-1",
                "position-2",
                "position-3"
              ]
            },
            "positions": [
              {
                "position": {
                  "index": 1,
                  "label": "position-1"
                },
                "card_id": "pentacles-03",
                "orientation": "upright"
              },
              {
                "position": {
                  "index": 2,
                  "label": "position-2"
                },
                "card_id": "swords-01",
                "orientation": "upright"
              },
              {
                "position": {
                  "index": 3,
                  "label": "position-3"
                },
                "card_id": "major-13",
                "orientation": "reversed"
              }
            ],
            "permutation_commitment": {
              "kernel": {
                "id": "committed-permutation",
                "version": 2
              },
              "deck": {
                "id": "rider-waite",
                "version": 1
              },
              "derivation": {
                "id": "hkdf-sha256-counter-stream",
                "version": 1,
                "hash": "sha-256",
                "seedEncoding": "32-byte-raw-from-64-lowercase-hex",
                "saltUtf8": "sun-terminal/tarot/hkdf-sha256-counter-stream/v1",
                "shuffleInfoPrefixUtf8": "sun-terminal/tarot/committed-permutation@2/rider-waite@1/shuffle/fisher-yates-rejection@1",
                "orientationInfoPrefixUtf8": "sun-terminal/tarot/committed-permutation@2/rider-waite@1/orientation/position-word-parity@1",
                "infoEncoding": "utf8-prefix-nul-uint32-be-page-counter",
                "shuffleStream": "shuffle",
                "orientationStream": "orientation",
                "pageBytes": 512,
                "pageCounterStart": 0,
                "wordEncoding": "uint32-be"
              },
              "shuffle": {
                "id": "fisher-yates-rejection",
                "version": 1
              },
              "orientation": {
                "id": "position-word-parity",
                "version": 1
              },
              "canonicalization": {
                "id": "sun-terminal-tarot-permutation-json",
                "version": 2
              },
              "permutationHash": {
                "algorithm": "sha-256",
                "value": "c9d9d1909297ba936913b6c78162faeb733eb426ef234cfc35b6139fda3a5d2b"
              }
            },
            "raw_result_hash": {
              "algorithm": "sha-256",
              "canonicalization": {
                "id": "sun-terminal-tarot-raw-result-json",
                "version": 1
              },
              "value": "9fffa308351b95bb79bd68dd2a2aefc5cbcfb3c2cd3d0e6f6518e673021b1c43"
            }
          }
        },
        "provenance": {
          "request_fingerprint": {
            "algorithm": "sha-256",
            "canonicalization": {
              "id": "sun-terminal-consult-request-json",
              "version": 1
            },
            "value": "5555555555555555555555555555555555555555555555555555555555555555"
          },
          "instrument_manifest": {
            "id": "tarot.rider-waite",
            "version": 1,
            "digest": {
              "algorithm": "sha-256",
              "value": "cf2f783870880f60d35b8274039e577501c998d8cbf67eef8888fb1ea8220f0b"
            },
            "deck_digest": {
              "algorithm": "sha-256",
              "value": "f5c0a09c2e012f3716ca8b43c8976040054ced76cab350545d6b1f53b1b02c4e"
            },
            "kernel_profile_digest": {
              "algorithm": "sha-256",
              "value": "40c5cc0973a8ab47a9aa261f63a44cdfbe3e82ccc92ac807358a9f7775ab7d34"
            }
          },
          "kernel": {
            "identity": {
              "id": "committed-permutation",
              "version": 2
            },
            "profile_digest": {
              "algorithm": "sha-256",
              "value": "40c5cc0973a8ab47a9aa261f63a44cdfbe3e82ccc92ac807358a9f7775ab7d34"
            }
          },
          "deck": {
            "identity": {
              "id": "rider-waite",
              "version": 1
            },
            "content_digest": {
              "algorithm": "sha-256",
              "value": "f5c0a09c2e012f3716ca8b43c8976040054ced76cab350545d6b1f53b1b02c4e"
            }
          },
          "entropy": {
            "source": "web-crypto-get-random-values",
            "bits": 256,
            "draw_samples": 1,
            "seed_disclosure": "not-disclosed",
            "seed_persistence": "not-persisted",
            "independent_noncuration_proof": false
          },
          "runtime": {
            "id": "sun-terminal-worker",
            "version": 1,
            "authenticity": "unsigned-service-assertion",
            "independent_origin_verification": false
          }
        },
        "rendering": {
          "instrument_url": "https://sunterminal.net/instruments/tarot-rider-waite"
        },
        "interpretations": [],
        "policy": {
          "replay": {
            "classification": "stored-final-result-retrieval-only",
            "independent_exact_replay": false,
            "terminal_exact_rederivation": false
          },
          "privacy": {
            "question_text_accepted": false,
            "question_text_retained": false,
            "seed_disclosed": false,
            "encounter_public": false,
            "receipt_payload_in_telemetry": false
          },
          "retention": {
            "profile": "anonymous-idempotency-24h",
            "active_record_expires_at": "2026-08-02T00:00:00.000Z",
            "retained": [
              "idempotency-key-digest",
              "request-fingerprint",
              "resolved-manifest",
              "final-response"
            ],
            "not_retained": [
              "raw-idempotency-key",
              "question-text",
              "draw-seed",
              "auth-headers"
            ]
          }
        }
      },
      "instrument_url": "https://sunterminal.net/instruments/tarot-rider-waite"
    }
  ]
}
