{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/determinism-class-v1.json",
  "title": "Determinism Class Declaration v1",
  "description": "Determinism Class Declaration receipt. A pipeline declares itself deterministic, seeded stochastic, or declared nondeterministic, and the service recomputes whether that declaration is internally consistent with what else is in the body: a seeded stochastic pipeline has to carry a seed commitment, and a declared nondeterministic pipeline has to enumerate what makes it nondeterministic. A pipeline that declares itself nondeterministic gets a not replayable as declared result later on, which is a stated limit and never an adverse finding. It does not re-execute the pipeline; replay_executed_by_service is fixed to false.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_determinism\\.class_[0-9]{10,}_[0-9a-f]{12}$"
    },
    "payload_sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "sig_b64u": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{86}$"
    },
    "key_id": {
      "type": "string",
      "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$"
    },
    "algorithm": {
      "type": "string",
      "const": "Ed25519"
    },
    "ts": {
      "type": "integer",
      "minimum": 1000000000
    },
    "signed_body": {
      "type": "object",
      "required": [
        "receipt_type",
        "schema",
        "pipeline_instance_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "determinism_class",
        "replay_window_from",
        "replay_window_to",
        "replay_environment_runtime_ref",
        "replay_environment_accelerator_class",
        "replay_environment_library_digests",
        "declaring_key_id"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "determinism.class"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "pipeline_instance_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9._:-]{1,256}$"
        },
        "evidence_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the caller-held evidence bundle this receipt attests was recorded. The service never receives or inspects the underlying evidence, only its digest."
        },
        "recorded_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
        },
        "verdict": {
          "type": "object",
          "description": "Service-computed honesty boundary fields. Never caller overridable; recomputed and checked at verify time.",
          "required": [
            "replay_executed_by_service",
            "declaration_internally_consistent",
            "nondeterminism_source_count",
            "replay_permitted_by_declaration",
            "replay_window_ordered",
            "library_digest_count"
          ],
          "additionalProperties": false,
          "properties": {
            "replay_executed_by_service": {
              "type": "boolean",
              "const": false
            },
            "declaration_internally_consistent": {
              "type": "boolean"
            },
            "nondeterminism_source_count": {
              "type": "integer",
              "minimum": 0
            },
            "replay_permitted_by_declaration": {
              "type": "boolean"
            },
            "replay_window_ordered": {
              "type": "boolean"
            },
            "library_digest_count": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Determinism Class Declaration receipt. A pipeline declares itself deterministic, seeded stochastic, or declared nondeterministic, and the service recomputes whether that declaration is internally consistent with what else is in the body: a seeded stochastic pipeline has to carry a seed commitment, and a declared nondeterministic pipeline has to enumerate what makes it nondeterministic. A pipeline that declares itself nondeterministic gets a not replayable as declared result later on, which is a stated limit and never an adverse finding. It does not re-execute the pipeline; replay_executed_by_service is fixed to false."
        },
        "determinism_class": {
          "type": "string",
          "enum": [
            "deterministic",
            "seeded_stochastic",
            "declared_nondeterministic"
          ]
        },
        "seed_commitment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Required when the class is seeded_stochastic. Commitment to the seed."
        },
        "nondeterminism_sources": {
          "type": "array",
          "minItems": 0,
          "maxItems": 64,
          "description": "Required to be nonempty when the class is declared_nondeterministic.",
          "items": {
            "type": "object",
            "required": [
              "component_ref",
              "reason"
            ],
            "additionalProperties": false,
            "properties": {
              "component_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Component that introduces the nondeterminism."
              },
              "reason": {
                "type": "string",
                "enum": [
                  "floating_hosted_model_version",
                  "concurrency_ordering",
                  "hardware_arithmetic_difference",
                  "sampling_parameter",
                  "external_service"
                ]
              }
            }
          }
        },
        "replay_window_from": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$",
          "description": "Start of the window in which replay is offered."
        },
        "replay_window_to": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$",
          "description": "End of that window."
        },
        "replay_environment_runtime_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Runtime a replay would have to instantiate."
        },
        "replay_environment_accelerator_class": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Accelerator class a replay would have to instantiate."
        },
        "replay_environment_library_digests": {
          "type": "array",
          "minItems": 1,
          "maxItems": 128,
          "items": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "Digest of one library in the replay environment."
          }
        },
        "declaring_key_id": {
          "type": "string",
          "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$",
          "description": "Key of the party making this declaration, so a falsified determinism claim names someone."
        }
      }
    }
  }
}
