{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://coulomb.social/schemas/railiance/custody-broker-readiness.v1.json",
  "title": "Railiance custody broker readiness receipt v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "interface", "version", "workplan_id", "owner", "reviewer", "decision",
    "created_at", "engagement_id", "target_id", "projection_contract_digest",
    "projection_receipt_interface", "interface_artifacts", "required_roles", "mount_paths",
    "secret_values_observed"
  ],
  "properties": {
    "interface": {"const": "railiance.custody-broker-readiness"},
    "version": {"const": 1},
    "workplan_id": {"const": "RAILIANCE-WP-0025"},
    "owner": {"const": "whitehat-security"},
    "reviewer": {"type": "string", "minLength": 2, "maxLength": 128},
    "decision": {"enum": ["approve", "request-changes"]},
    "created_at": {"type": "string", "format": "date-time"},
    "engagement_id": {"type": "string"},
    "target_id": {"type": "string"},
    "projection_contract_digest": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "projection_receipt_interface": {"const": "railiance.custody-projection-receipt"},
    "interface_artifacts": {
      "type": "object",
      "minProperties": 4,
      "additionalProperties": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
    },
    "required_roles": {"const": ["attacker", "owner"]},
    "mount_paths": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "string", "pattern": "^/"}},
    "adapter": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repo", "revision", "path", "sha256", "tests_passed"],
      "properties": {
        "repo": {"const": "whitehat-security"},
        "revision": {"type": "string", "pattern": "^[0-9a-f]{40}$"},
        "path": {"type": "string", "minLength": 1},
        "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
        "tests_passed": {"const": true}
      }
    },
    "cleanup_request_supported": {"const": true},
    "note": {"type": "string", "minLength": 1, "maxLength": 2000},
    "secret_values_observed": {"const": false}
  },
  "allOf": [
    {
      "if": {"properties": {"decision": {"const": "approve"}}},
      "then": {"required": ["adapter", "cleanup_request_supported"]},
      "else": {"required": ["note"]}
    }
  ]
}
