{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/usap-pbs-v2.json",
  "title": "Provenance-Bonded Sandbox v1",
  "description": "Compares supplied runtime observations with a declared sandbox policy. It does not prove isolation or complete runtime monitoring.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_usap\\.pbs_[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",
        "sandbox_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "sandbox_policy_sha256",
        "policy_committed_at",
        "runtime_event_id",
        "runtime_observed_at",
        "declared_process_images",
        "declared_filesystem_scopes",
        "declared_syscall_classes",
        "declared_network_scopes",
        "declared_resource_limits",
        "observed_process_image",
        "observed_filesystem_scopes",
        "observed_syscall_classes",
        "observed_network_scopes",
        "observed_resources",
        "process_image_relation",
        "filesystem_scope_relation",
        "syscall_scope_relation",
        "network_scope_relation",
        "resource_limit_relation",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "usap.pbs"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "sandbox_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": [
            "outcome"
          ],
          "additionalProperties": false,
          "properties": {
            "outcome": {
              "type": "string",
              "enum": [
                "within_declared_sandbox",
                "outside_declared_sandbox",
                "indeterminate"
              ]
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Compares supplied runtime observations with a declared sandbox policy. It does not prove isolation or complete runtime monitoring."
        },
        "sandbox_policy_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "policy_committed_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$"
        },
        "runtime_event_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "runtime_observed_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$"
        },
        "declared_process_images": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "minItems": 1,
          "maxItems": 128
        },
        "declared_filesystem_scopes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "minItems": 1,
          "maxItems": 128
        },
        "declared_syscall_classes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:/]+$"
          },
          "minItems": 1,
          "maxItems": 128
        },
        "declared_network_scopes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "minItems": 1,
          "maxItems": 128
        },
        "declared_resource_limits": {
          "type": "object",
          "required": [
            "cpu_time_ms",
            "memory_bytes",
            "process_count"
          ],
          "additionalProperties": false,
          "properties": {
            "cpu_time_ms": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400000
            },
            "memory_bytes": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1125899906842624
            },
            "process_count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000
            }
          }
        },
        "observed_process_image": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "observed_filesystem_scopes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "minItems": 1,
          "maxItems": 128
        },
        "observed_syscall_classes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:/]+$"
          },
          "minItems": 1,
          "maxItems": 128
        },
        "observed_network_scopes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "minItems": 1,
          "maxItems": 128
        },
        "observed_resources": {
          "type": "object",
          "required": [
            "cpu_time_ms",
            "memory_bytes",
            "process_count"
          ],
          "additionalProperties": false,
          "properties": {
            "cpu_time_ms": {
              "type": "integer",
              "minimum": 0,
              "maximum": 86400000
            },
            "memory_bytes": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1125899906842624
            },
            "process_count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000
            }
          }
        },
        "process_image_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "filesystem_scope_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "syscall_scope_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "network_scope_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "resource_limit_relation": {
          "type": "string",
          "enum": [
            "within_policy",
            "outside_policy"
          ]
        },
        "elements": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "process_image_mismatch",
              "filesystem_scope_mismatch",
              "syscall_scope_mismatch",
              "network_scope_mismatch",
              "resource_limit_exceeded"
            ]
          },
          "minItems": 0,
          "maxItems": 5
        },
        "outcome": {
          "type": "string",
          "enum": [
            "within_declared_sandbox",
            "outside_declared_sandbox",
            "indeterminate"
          ]
        }
      }
    }
  }
}
