{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.dharma-ai.io/codex-setup-intent/v1",
  "title": "Host-admitted public Codex setup intent (not enrollment authority)",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "operationId", "setupReference", "organizationId", "recipientMembershipId", "origin", "repositoryFingerprint", "policyRevision", "scopeDigest", "contractDigest", "hostContextId", "issuedAt", "expiresAt"],
  "properties": {
    "schema": { "const": "dharma.codex-setup-intent/v1" },
    "operationId": { "$ref": "#/$defs/id" },
    "setupReference": { "$ref": "#/$defs/id" },
    "recipientMembershipId": { "$ref": "#/$defs/id" },
    "hostContextId": { "$ref": "#/$defs/id" },
    "organizationId": { "type": "string", "pattern": "^org_[A-Za-z0-9]+$(?![\\s\\S])" },
    "origin": { "type": "string", "format": "uri", "pattern": "^https://[^/?#@\\\\\\s]+$(?![\\s\\S])" },
    "repositoryFingerprint": { "$ref": "#/$defs/digest" },
    "scopeDigest": { "$ref": "#/$defs/digest" },
    "contractDigest": { "$ref": "#/$defs/digest" },
    "policyRevision": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$(?![\\s\\S])" },
    "issuedAt": { "type": "string", "format": "date-time" },
    "expiresAt": { "type": "string", "format": "date-time" }
  },
  "$defs": {
    "id": { "type": "string", "format": "uuid", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$(?![\\s\\S])" },
    "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$(?![\\s\\S])" }
  }
}
